# LM Classes

## class LM_BBox

### New Feature

## class LM_ColorVector

The ColorVector class is used to represent a color. The rgb_color class is also used to represent colors, but ColorVector's are useful when you need to perform mathematical operations on colors.

## Member Variables

r (float)

The red component of the color. Values can range from 0 to 1.

g (float)

The green component of the color. Values can range from 0 to 1.

b (float)

The blue component of the color. Values can range from 0 to 1.

a (float)

The alpha (or opacity) component of the color. Values can range from 0 to 1. An alpha of 0 is a totally transparent color, while a value of 1 indicates a totally opaque color.

## Member Functions

void Set(r, g, b, a=1.0)

Set the value of a color. This function is an alternative to setting the r, g, b and a values individually. If you leave out the a value, it will default to 1.0.

r (float): the r value you wish to set g (float): the g value you wish to set b (float): the b value you wish to set a (float): the a value you wish to set (defaults to 1.0) Return value: none

void Set(color)

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

vec (rgb_color): an rgb_color object whose value you wish to copy Return value: none

void Set(color)

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

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

float Mag()

Computes the magnitude of a color vector.

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

float SquaredMag()

Computes the squared magnitude of a color vector.

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

void Normalize()

Normalizes a ColorVector. This process ensures that each of the r, g, b and a values is within the range 0 to 1.

Return value: none

void Invert()

Inverts a color.

Return value: none

bool IsBlack()

Returns true if a color is pure black, false otherwise.

Return value (bool): true if the color is pure black, false otherwise

bool IsWhite()

Returns true if a color is pure white, false otherwise.

Return value (bool): true if the color is pure white, false otherwise

bool IsOpaque()

Returns true if a color is totally opaque, false otherwise.

Return value (bool): true if the color is totally opaque, false otherwise

bool IsTransparent()

Returns true if a color is totally transparent, false otherwise.

Return value (bool): true if the color is totally transparent, false otherwise

rgb_color AsColorStruct()

Converts a ColorVector into an rgb_color object, returning the new object.

Return value (rgb_color): a new rgb_color object with the equivalent color values as the original ColorVector

ColorVector operator+(color)

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

color (ColorVector): a color to add to the first one Return value (ColorVector): the sum of two colors

ColorVector operator-(color)

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

color (ColorVector): a color to subtract from the first one Return value (ColorVector): the difference of two colors

ColorVector operator*(color)

Multiplies one color by another and returns the result as a new color. This operator makes it possible to multiply colors as if they were regular numbers. Example: c = a * b.

color (ColorVector): a color to multiply by the first one Return value (ColorVector): the result of mutliplying two colors

ColorVector operator*(num)

Multiplies a color by a number, returning the result as a new color. Example: c2 = c * 3.

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

ColorVector operator/(num)

Divides a color by a number, returning the result as a new color. Example: c2 = c / 3.

num (float): a number to divide the color by Return value (ColorVector): the original color, divided by the number "num"

## class LM_Matrix

The Matrix class is used to represent a 4x4 transformation matrix. Matrix objects are used to transform points in 3D space.

## Member Variables

(none)

## Member Functions

void Set(mat)

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

mat (Matrix): another Matrix object whose value you wish to copy Return value: none

void Multiply(mat)

Multiplies two matrices. The calling object is multiplied by the matrix "mat".

mat (Matrix): a Matrix object to multiply into the calling object Return value: none

void Transform(vec2)

Apply a matrix transformation to a 2D vector object.

vec2 (Vector2): a vector to transform Return value: none

void Transform(vec3)

Apply a matrix transformation to a 3D vector object.

vec3 (Vector3): a vector to transform Return value: none

void Invert()

Invert the matrix.

Return value: none

void Identity()

Set the matrix to be an identity matrix. An identity matrix has no transformation - any vectors transformed by it will retain their original positions. Use this function to reset a matrix before creating a different transformation.

Return value: none

void Translate(dx, dy, dz)

Prepend a translation onto the current matrix.

dx (float): the x value of the translation dy (float): the y value of the translation dz (float): the z value of the translation Return value: none

void Scale(sx, sy, sz)

Prepend a scale onto the current matrix.

sx (float): the x value of the scale sy (float): the y value of the scale sz (float): the z value of the scale Return value: none

void Rotate(axis, angle)

Prepend a rotation onto the current matrix.

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

void Perspective(alpha, near, far, aspect)

Prepend a perspective transform onto the current matrix.

alpha (float): the field of view angle (in radians) near (float): distance from the virtual eye to the near clipping plane far (float): distance from the virtual eye to the far clipping plane aspect (float): aspect ratio of the final viewing plane Return value: none

## class LM_Point

The Point class is used to indicate a pixel location on the screen.

## Member Variables

x (int)

The horizontal location of the pixel.

y (int)

The vertical location of the pixel.

## Member Functions

void Set(x, y)

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

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

void Set(point)

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

point (Point): another Point object whose value you wish to copy Return value: none

## class LM_Rect

The Rect class is used to represent a rectangular shape in screen coordinates.

## Member Variables

left (int)

The left-most pixel in the rectangle.

top (int)

The top-most pixel in the rectangle.

right (int)

The right-most pixel in the rectangle.

bottom (int)

The bottom-most pixel in the rectangle.

## Member Functions

void Normalize()

This function "normalizes" a rectangle to ensure that the left value is smaller than the right, and the top value is smaller than the bottom. This should always be true of a well-behaved rectangle, and this function makes sure that is the case.

Return value: none

bool Contains(point)

Tests whether the rectangle contains the given point.

point (Point): a point that is being tested for inclusion in the rectangle Return value (bool): true if the point is contained in the rectangle, otherwise false

## class LM_String

### New Feature

## class LM_Vector2

The Vector2 class is used to represent a 2D 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.

## Member Functions

void Set(x, y)

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

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

void Set(vec)

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

vec (Vector2): another Vector2 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 (Vector2): a Vector2 object Return value (float): the dot 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

Vector2 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 (Vector2): 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 and y values as necessary.

Return value: none

Vector2 GetOrthogonal()

Returns a vector that points 90 degrees away from the orignal vector.

Return value (Vector2): a new vector, pointing 90 degrees away from the original

void Rotate(angle)

Rotates the vector by the specified angle.

angle (float): the angle (in radians) to rotate the vector Return value: none

Vector2 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 (Vector2): a vector to add to the first one Return value (Vector2): the sum of two vectors

Vector2 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 (Vector2): a vector to subtract from the first one Return value (Vector2): the difference of two vectors

Vector2 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 (Vector2): the original vector, multiplied by the number "num"

Vector2 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 (Vector2): the original vector, divided by the number "num"

## 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 rgb_color

The rgb_color class is a basic structure for storing a color value, including opacity/transparency.

## Member Variables

r (int)

The red component of the color. Values can range from 0 to 255.

g (int)

The green component of the color. Values can range from 0 to 255.

b (int)

The blue component of the color. Values can range from 0 to 255.

a (int)

The alpha (or opacity) component of the color. Values can range from 0 to 255. An alpha of 0 is a totally transparent color, while a value of 255 indicates a totally opaque color.

## Member Functions

(none)