class LM_Vector3

The Vector3 class is used to represent a 3D vector or point.

Member Variables

x (float)

The x (or horizontal) coordinate of the vector.


y (float)

The y (or vertical) coordinate of the vector.


z (float)

The z (or depth) coordinate of the vector.

Member Functions

void Set(x, y, z)

Set the value of a vector. This function is an alternative to setting the x, y and z values individually.

x (float): the x value you wish to set
y (float): the y value you wish to set
z (float): the z value you wish to set
Return value: none

void Set(vec)

Set the value of a vector by copying an existing vector.

vec (Vector3): another Vector3 object whose value you wish to copy
Return value: none

float Dot(vec)

Computes the dot product of this vector and a second one.

vec (Vector3): a Vector3 object
Return value (float): the dot product of the calling vector and the passed in argument

Vector3 Cross(vec)

Computes the cross product of this vector and a second one.

vec (Vector3): a Vector3 object
Return value (Vector3): a new vector that is the cross product of the calling vector and the passed in argument

float Mag()

Computes the magnitude of a vector.

Return value (float): the vector's magnitude (length)

float SquaredMag()

Computes the squared magnitude of a vector.

Return value (float): the vector's squared magnitude

Vector3 Norm()

Returns a normalized copy of the vector. The vector object is unchanged, and normalized copy is returned. The normalized vector will have a length of 1.0.

Return value (Vector3): a normalized copy of the original vector

void NormMe()

Normalizes a vector. The vector is normalized (adjusted so that it points in the same direction, but has a length of one) in place, adjusting the x, y and z values as necessary.

Return value: none

void GetOrthogonals(vecU, vecV)

Returns two vectors that are orthogonal to the original vector.

vecU (Vector3): this vector will be filled in so that it is orthogonal to the original vector
vecV (Vector3): this vector will be filled in so that it is orthogonal to both the original vector and vecU
Return value: none

void Rotate(axis, angle)

Rotates the vector around the specified axis by the specified angle.

axis (int): the angle (in radians) to rotate the vector (axis constants can be found here)
angle (float): the angle (in radians) to rotate the vector
Return value: none

Vector3 operator+(vec)

Adds two vectors and returns the result as a new vector. This operator makes it possible to add two vectors as if they were regular numbers. Example: c = a + b.

vec (Vector3): a vector to add to the first one
Return value (Vector3): the sum of two vectors

Vector3 operator-(vec)

Subtracts one vector from another and returns the result as a new vector. This operator makes it possible to subtract vectors as if they were regular numbers. Example: c = a - b.

vec (Vector3): a vector to subtract from the first one
Return value (Vector3): the difference of two vectors

Vector3 operator*(num)

Multiplies a vector by a number, returning the result as a new vector. Example: v2 = v * 3.

num (float): a number to multiply the vector by
Return value (Vector3): the original vector, multiplied by the number "num"

Vector3 operator/(num)

Divides a vector by a number, returning the result as a new vector. Example: v2 = v / 3.

num (float): a number to divide the vector by
Return value (Vector3): the original vector, divided by the number "num"
class LM_Vector3 @ Vector3 {
  LM_Vector3();
  ~LM_Vector3();
 
  void Set(real vx, real vy, real vz);
  void Set(const LM_Vector3 &vec2);
 
  real Dot(const LM_Vector3 &vec2);
  LM_Vector3 Cross(const LM_Vector3 &vec2);
 
  real Mag();
  real SquaredMag();
 
  LM_Vector3 Norm();
  void NormMe();
 
  void GetOrthogonals(LM_Vector3 *vecU, LM_Vector3 *vecV);
  void Rotate(int32 axis, real angle);
 
  LM_Vector3 operator+(const LM_Vector3 &vec2);
  LM_Vector3 operator-(const LM_Vector3 &vec2);
  LM_Vector3 operator*(real f);
  LM_Vector3 operator/(real f);
 
  real  x;
  real  y;
  real  z;
};