OxMVector3 Class
Represents a position or direction in 3D space. The OxMVector3 class supports a range of mathematical operators for more natural expressions ( + - * / ) that can be used both with 3D vectors and scalars. The class also provides methods to perform these calculations in-place to reduce object overhead.
Constructors
Expand All | Collapse All
-
OxMVector3
Default constructor, sets the vector to (0,0,0). -
OxMVector3 ( vx As Double, vy As Double, vz As Double )
Set the vector using three Double values. -
OxMVector3 ( v As OxMVector3 )
Set the vector to a copy of the passed vector.
Properties
Methods
Expand All | Collapse All
-
Add ( n As Double )
-
Add ( v As OxMVector3 )
Adds the passed vector to this vector, storing the result. This is equivalent to:
self = self + v
-
Angle ( v As OxMVector3 ) As Double
Returns the angle in radians between the passed vector and this vector. -
CloseEnough ( v As OxMVector3, within As Double = 0.01 ) As Boolean
Compares this vector with the passed vector and returns True if all the components fall within the requested tolerance (default 0.01). -
Copy ( v As OxMVector3 )
Sets this vector to a copy of the passed vector. -
Cross ( v As OxMVector3 )
Performs a cross-product of this vector with the passed vector and stores the result in this vector. -
CrossProduct ( v As OxMVector3 ) As OxMVector3
Returns the cross-product (perpendicular vector) of this vector and passed vector. -
Distance ( v As OxMVector3 ) As Double
Returns the distance between the passed vector and this vector. -
DistanceSquared ( v As OxMVector3 ) As Double
Returns the squared distance between the passed vector and this vector. This is faster to compute than Distance as it avoids calling Sqrt, but the result is typically only useful when being compared to other squared values. -
Divide ( n As Double )
-
Divide ( v As OxMVector3 )
Divides this vector by the passed vector, storing the result. This is equivalent to:
self = self / v
-
DotProduct ( v As OxMVector3 ) As Double
Returns the dot product of this vector and the passed vector. -
Equals ( v As OxMVector3 ) As Boolean
Returns True if the vector has the exact same value as the passed vector.
Note: This is not generally useful due to floating point errors, however it can be handy to compare a vector's current state with a previously stored state. -
Equals ( v As OxMVector3, decimalplaces As UInt32 ) As Boolean
Rounds the vector components to the requested decimal places (decimalplaces = 1 is tenths, 2 is hundredths, etc.) and returns True if the rounded vectors have the exact same value.
Note: This can be a fairly CPU-intensive comparison. The CloseEnough method provides a similar result with much less work. -
Length As Double
Returns the length (or magnitude) of the vector. -
LengthSquared As Double
Returns the squared length (or magnitude) of the vector. This is faster to compute than Length as it avoids calling Sqrt, but the result is typically only useful when being compared to other squared values. -
Multiply ( n As Double )
-
Multiply ( v As OxMVector3 )
Multiplies the passed vector to this vector, storing the result. This is equivalent to:
self = self * v
-
Normalize
Scales the vector to unit length (1.0). -
Rotate ( q As OxMQuaternion )
Rotate this vector by the rotation defined in a quaternion. -
RotateInverse ( q As OxMQuaternion )
Rotate this vector by the inverted (opposite) rotation defined in a quaternion. -
SetRotate ( vX As Double, vY As Double, vZ As Double, q As OxMQuaternion )
Rotate a vector defined by three Double values by a quaternion and store the result in this vector. -
SetRotate ( v As OxMVector3, q As OxMQuaternion )
Rotate the vector passed by the quaternion passed and store the result in this vector. -
SetRotateInverse ( v As OxMVector3, q As OxMQuaternion )
Rotate the vector passed by the inverted (opposite) value of the quaternion passed and store the result in this vector. -
SetToDifference ( v1 As OxMVector3, v2 As OxMVector3 )
Subtracts v1 from v2 and stores the result in this vector. This is equivalent to:
self = v1 - v2
-
SetToProduct ( v1 As OxMVector3, v2 As OxMVector3 )
Multiplies v1 by v2 and stores the result in this vector. This is equivalent to:
self = v1 * v2
-
SetToQuotient ( v1 As OxMVector3, v2 As OxMVector3 )
Divides v1 by v2 and stores the result in this vector. This is equivalent to:
self = v1 / v2
-
SetToSum ( v1 As OxMVector3, v2 As OxMVector3 )
Adds v1 with v2 and stores the result in this vector. This is equivalent to:
self = v1 + v2
-
SetVector ( vx As Double, vy As Double, vz As Double )
Set the vector using three Double values. -
Subtract ( n As Double )
-
Subtract ( v As OxMVector3 )
Subtracts the passed vector from this vector, storing the result. This is equivalent to:
self = self - v