Vector3
Script Reference | Vector3 Functions |
Vector3 is a basic math type that is made up of 3 real numbers typically used to represent positions, velocities, and directions. As of 0.65, Vector3 objects in scripting have gotten a significant optimization to eliminate their previous need to allocate memory that would then need garbage collected. As a result, scripts that use them heavily, especially in mathematical operations, should not trigger garbage collection cycles, and should also run a bit faster.
Vector3 Methods
Concave
b = v.Concave(v1,v2);
CrossProduct
v2 = v.CrossProduct(v1); // result is perpendicular to v and v1
Distance
f = v.Distance(v1);
Distance2
f = v.Distance2(v1); // squared distance
DistanceXY
f = v.DistanceXY(v1); // squared 2D distance
DotProduct
f = v.DotProduct(v1); // v.x * v1.x + v.y * v1.y + v.z * v1.z
GetPitch
f = v.GetPitch(); // asin(v.z)
GetYaw
f = v.GetYaw(); // -atan2(-v.x, v.y)
IsZero
b = v.IsZero();
Length
f = v.Length();
Length2
f = v.Length2(); // squared length
Normalize
v2 = v.Normalize();
Reflection
v2 = v.Reflection(v1);
Set, SetXYZ
v2 = v.Set(x,y,z);
Vector3 Functions
Vec3, Vector3
v = Vec3(x,y,z);
Vec2, Vector2
v = Vec2(x,y);
AngleAxis
v = AngleAxis(fAngleDEG,vAxis);
Area
f = Area(v1,v2,v3);
ComputeNormal
v = ComputeNormal(vA,vB,vC);
Cross, CrossProduct
v = CrossProduct(v1,v2);
DotProduct
f = DotProduct(v1,v2);
Lerp
v = Lerp(v1,v2,fSlerp);
NearestPointInLine
v = NearestPointInLine(vPt,v1,v2);
NearestPointInLineSegment
v = NearestPointInLineSegment(vPt,v1,v2);
NearestPointInPlane
v = NearestPointInPlane(vPt,v1,v2,v3);
v = NearestPointInPlane(vPt,v0,vNormal);
PointInTriangle
v = PointInTriangle(vPt,v1,v2,v3);
Reflection
v = Reflection(v1,v2);
Vec3FromSpherical
v = Vec3FromSpherical(fHeading,fPitch,fRadius);