Eyeon:Script/Reference/Applications/Fuse/Classes/Vector4

From VFXPedia

< Eyeon:Script | Reference | Applications | Fuse | Classes
Revision as of 02:03, 23 February 2008 by Izyk (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Parent Class: None

Vector4.

Contents

Methods:

Vector4Construct a new Vector4 object
Length
Normalize
Mul
Div
Dot3
Dot4
Cross
Lerp
Set
Distance
Scale

Members:

Other:

Attributes


Tips for Vector4 (edit)

Vector4 Documentation

Refer to Vector4.h and Matrix4.h of the SDK for a description of the various methods. The LUA implementation, however, differs slightly from the C++ methods.

Vector4 can be used to symbolize RGBA values or points in 3D space (where the Z and W components are either 0 or 1, depending on the use case). If you want to use it for 2D coordinates, Z and W should be zero so length and distance calculations work correctly. Keep in mind the nature of Fusion's squashed coordinate system if you place 2D points into a Vector4 (see here).

Vector4 is preferred to Vector2 and Vector3f if you want to use dot and cross products (not available in the other classes). To create a Vector4 object and access its components, use the following syntax:

v = Vector4(x_value, y_value, z_value, w_value)
print("Vector: ", v.X, v.Y, v.Z, v.W)

Vector4 objects support addition and multiplication:

sum = Vector4(1,1,0,0) + Vector4(2,2,0,0)   -- (3/3/0/0)
mult = Vector4(10,10,0,0) * 0.5             -- (5/5/0/0), vector object must come first!
mult = 0.5 * Vector4(2,2,0,0)               -- invalid
mult = Vector4(1,1,0,0) * Vector4(2,2,0,0)  -- not implemented, use :Cross() 

Vector4 Methods

Length()
returns length if vector is a point in 3D space: sqrt(x*x + y*y + z*z), 4th component is ignored.
Normalize()
divides each component by the vector's length
Mul(another_vector)
per-component multiplication between this object and another vector. Doesn't modify itself but returns a result vector where X = X * another_vector.X and so forth.
Div(another_vector)
per-component division. Returns a vector where X = X / another_vector.X and so forth.
Dot3(vec)
dot-product between X, Y and Z components: X * vec.X + Y * vec.Y + Z * vec.Z. If you use the dot product on the vector itself, it will return its length squared (faster than calling v:Length()*v:Length())
Dot4(vec)
dot-product between all 4 components.
Cross(another_vector)
cross-product between two vectors.
Lerp(t, another_vector)
interpolates between the vector and another_vector. Returns a position vector between both points if t is between 0 and 1 (result = vector * (1-t) + another_vector * t)
Set(x,y,z,w)
shortcut to set all components of the vector after it has been created.
Distance(another_vector)
returns distance between itself and another_vector in 3D space (4th component is ignored).
Scale(tx,ty,tz,tw)
multiplies the components of a vector by tx, ty, tz and tw respectively. Returns a vector (doesn't modify itself).