Try my new website: www.urcho.com - the new SIMPLE social network
blitz code snippets Sign up | 357 members | 125 snippets
Search for:

Username:
Password:


Non-Type Based Vector Lib by Jonathan Nguyen

[back]
Author: Archive | Viewed: 927 times | Language: BlitzBasic 3D | Category: Maths/Physics
Author Comments:
Basically instead of having to deal with type declarations (ie. the myVector.Vector) you can use handles to banks instead (ie. just myVector). Ive written it with some basis on "temporary" vectors which are deleted automatically when used in a non-value-returning vector function. This is primarily for when you want to add a vector with another arbitrary vector but you dont want to actually create another vector (or subtract, dot product, cross, whatever). So instead of: myVector1=CreateVector(1,2,3) myVector2=CreateVector(2,3,4) myVector3=CreateVector(3,4,5) AddVectors(myVector1,myVector2) myVector4=CrossProduct(myVector1,myVector3) UnitVector(myVector4) myVector5=CreateVector() CopyVector(myVector5,myVector4) It would simplify to something like this: myVector5=CreateVector() CopyVector(myVector5,TUnitVector(TCrossProduct(TAddVectors(TVector(1,2,3),TVector(2,3,4)),TVector(3,4,5)))) So thats that. Ive also added functions to find the pitch and yaw of a vector, two methods of finding the angle between two vectors, and all three projections.
Login or create an account to comment on this snippet