r4 - 02 Feb 2007 - 03:05:41 - UpDownYou are here: Developer's TWiki >  Coding Web  > AxiomMathLibAPI



Namespace List

The namespaces specified in this document are:

Namespace Assembly
Axiom.MathLib? MathLib?
Axiom.MathLib.Collections? MathLib?

Namespace : MathLib?



MathLib? Type List

Enumerations

Type Summary
Intersection? Type of intersection detected between 2 object.
PlaneSide? The "positive side" of the plane is the half space to which the plane normal points. The "negative side" is the other half space. The flag "no side" indicates the plane itself.

Structs

Type Summary
IntersectResult? Simple struct to allow returning a complex intersection result.
Matrix3? A 3x3 matrix which can represent rotations around axes.
Matrix4? Class encapsulating a standard 4x4 homogenous matrix.
Plane? Defines a plane in 3D space.
Quaternion? Summary description for Quaternion.
Vector2? 2 dimensional vector.
Vector3? Standard 3-dimensional vector.
Vector4? 4D homogeneous vector.

Classes

Type Summary
AxisAlignedBox? A 3D box aligned with the x/y/z axes.
MathUtil? This is a class which exposes static methods for various common math functions. Currently, the methods simply wrap the methods of the System.Math class (with the exception of a few added extras). This is in case the implementation needs to be swapped out with a faster C++ implementation, if deemed that the System.Math methods are not up to far speed wise.
PlaneBoundedVolume? Represents a convex volume bounded by planes.
PositionalSpline? A Catmull-Rom spline that can be used for interpolating translation movements.
Ray? Representation of a ray in space, ie a line with an origin and direction.
RotationalSpline? A class used to interpolate orientations (rotations) along a spline using derivatives of quaternions.
Sphere? A standard sphere, used mostly for bounds checking.


MathLib? Enumerations

Intersection Enumeration

Summary

public enumeration Intersection

Type of intersection detected between 2 object.

Remarks

Type of intersection detected between 2 object.

Enumeration Members

Field Summary
Contained An object is fully contained within another object.
Contains An object fully contains another object.
None The objects are not intersecting.
Partial The objects are partially intersecting each other.

PlaneSide Enumeration

Summary

public enumeration PlaneSide?

The "positive side" of the plane is the half space to which the plane normal points. The "negative side" is the other half space. The flag "no side" indicates the plane itself.

Remarks

The "positive side" of the plane is the half space to which the plane normal points. The "negative side" is the other half space. The flag "no side" indicates the plane itself.

Enumeration Members

Field Summary
Negative
None
Positive


MathLib? Structs

Vector2 Structure

Summary

public structure Vector2

2 dimensional vector.

Remarks

2 dimensional vector.

Constructor Members

Name Access Summary
Vector2() public Constructor.

Field Members

Name Access Summary
x : Single public
y : Single public

Method Members

Name Access Summary
Add() : Vector2 public Used when a Vector2 is added to another Vector2.
Multiply() : Vector2 public Used when a Vector2 is multiplied by a scalar value.
Multiply() : Vector2 public Used when a scalar value is multiplied by a Vector2.
Negate() : Vector2 public Used to negate the elements of a vector.
Subtract() : Vector2 public Used to subtract a Vector2 from another Vector2.

Quaternion Structure

Summary

public structure Quaternion

Summary description for Quaternion.

Remarks

Summary description for Quaternion.

Constructor Members

Name Access Summary
Quaternion() public Creates a new Quaternion.

Field Members

Name Access Summary
w : Single public
x : Single public
y : Single public
z : Single public

Property Members

Name Access Summary
Identity : Quaternion public An Identity Quaternion.
Norm : Single public Squared 'length' of this quaternion.
XAxis : Vector3 public Local X-axis portion of this rotation.
YAxis : Vector3 public Local Y-axis portion of this rotation.
ZAxis : Vector3 public Local Z-axis portion of this rotation.
Zero : Quaternion public A Quaternion with all elements set to 0.0f;

Method Members

Name Access Summary
Add() : Quaternion public Used when a Quaternion is added to another Quaternion.
Dot() : Single public Performs a Dot Product operation on 2 Quaternions.
Equals() : Boolean public
Exp() : Quaternion public Calculates the Exponent of a Quaternion.
FromAngleAxis?() : Quaternion public Creates a Quaternion from a supplied angle and axis.
FromAxes?() : Void public
FromRotationMatrix?() : Void public
GetHashCode?() : Int32 public
Inverse() : Quaternion public Computes the inverse of a Quaternion.
Log() : Quaternion public Calculates the logarithm of a Quaternion.
Multiply() : Quaternion public Used to multiply 2 Quaternions together.
Multiply() : Vector3 public
Multiply() : Quaternion public Used when a Quaternion is multiplied by a float value.
Multiply() : Quaternion public Used when a float value is multiplied by a Quaternion.
Normalize() : Void public Normalizes elements of this quaterion to the range [0,1].
Slerp() : Quaternion public
Slerp() : Quaternion public
Squad() : Quaternion public
Squad() : Quaternion public Performs spherical quadratic interpolation.
ToAngleAxis?() : Void public
ToAxes?() : Void public
ToRotationMatrix?() : Matrix3 public Gets a 3x3 rotation matrix from this Quaternion.
ToString?() : String public Overrides the ToString?() method to provide a text representation of a Quaternion.

Plane Structure

Summary

public structure Plane

Defines a plane in 3D space.

Remarks

A plane is defined in 3D space by the equation Ax + By + Cz + D = 0 This equates to a vector (the normal of the plane, whose x, y and z components equate to the coefficients A, B and C respectively), and a constant (D) which is the distance along the normal you have to go to move the plane back to the origin.

Constructor Members

Name Access Summary
Plane() public
Plane() public
Plane() public Construct a plane from 3 coplanar points.
Plane() public Construct a plane through a normal, and a distance to move the plane along the normal.

Field Members

Name Access Summary
D : Single public Distance from the origin.
Normal : Vector3 public Direction the plane is facing.

Method Members

Name Access Summary
Equals() : Boolean public Object method for testing equality.
GetDistance?() : Single public This is a pseudodistance. The sign of the return value is positive if the point is on the positive side of the plane, negative if the point is on the negative side, and zero if the point is on the plane. The absolute value of the return value is the true distance only when the plane normal is a unit length vector.
GetHashCode?() : Int32 public Gets the hashcode for this Plane.
GetSide?() : PlaneSide? public
Redefine() : Void public Construct a plane from 3 coplanar points.
ToString?() : String public Returns a string representation of this Plane.

IntersectResult Structure

Summary

public structure IntersectResult?

Simple struct to allow returning a complex intersection result.

Remarks

Simple struct to allow returning a complex intersection result.

Constructor Members

Name Access Summary
IntersectResult?() public Constructor.

Field Members

Name Access Summary
Distance : Single public If Hit was true, this will hold a query specific distance value. i.e. for a Ray-Box test, the distance will be the distance from the start point of the ray to the point of intersection.
Hit : Boolean public Did the intersection test result in a hit?

Method Members

Name Access Summary

Matrix4 Structure

Summary

public structure Matrix4

Class encapsulating a standard 4x4 homogenous matrix.

Remarks

The engine uses column vectors when applying matrix multiplications, This means a vector is represented as a single column, 4-row matrix. This has the effect that the tranformations implemented by the matrices happens right-to-left e.g. if vector V is to be transformed by M1 then M2 then M3, the calculation would be M3 * M2 * M1 * V. The order that matrices are concatenated is vital since matrix multiplication is not cummatative, i.e. you can get a different result if you concatenate in the wrong order.

The use of column vectors and right-to-left ordering is the standard in most mathematical texts, and is the same as used in OpenGL?. It is, however, the opposite of Direct3D, which has inexplicably chosen to differ from the accepted standard and uses row vectors and left-to-right matrix multiplication.

The engine deals with the differences between D3D and OpenGL? etc. internally when operating through different render systems. The engine users only need to conform to standard maths conventions, i.e. right-to-left matrix multiplication, (The engine transposes matrices it passes to D3D to compensate).

The generic form M * V which shows the layout of the matrix entries is shown below:

| m[0][0] m[0][1] m[0][2] m[0][3] | {x} | m[1][0] m[1][1] m[1][2] m[1][3] | {y} | m[2][0] m[2][1] m[2][2] m[2][3] | {z} | m[3][0] m[3][1] m[3][2] m[3][3] | {1}

Constructor Members

Name Access Summary
Matrix4() public Creates a new Matrix4 with all the specified parameters.

Field Members

Name Access Summary
m00 : Single public
m01 : Single public
m02 : Single public
m03 : Single public
m10 : Single public
m11 : Single public
m12 : Single public
m13 : Single public
m20 : Single public
m21 : Single public
m22 : Single public
m23 : Single public
m30 : Single public
m31 : Single public
m32 : Single public
m33 : Single public

Property Members

Name Access Summary
ClipSpace2DToImageSpace? : Matrix4 public
Determinant : Single public Gets the determinant of this matrix.
Identity : Matrix4 public Returns a matrix with the following form: 1,0,0,0   0,1,0,0   0,0,1,0   0,0,0,1  
Item : Single public Allows the Matrix to be accessed linearly (m[0] -> m[15]).
Item : Single public Allows the Matrix to be accessed like a 2d array (i.e. matrix[2,3])
Scale : Vector3 public Gets/Sets the Translation portion of the matrix. Sx 0 0 0   0 Sy 0 0   0 0 Sz 0   0 0 0 0  
Translation : Vector3 public Gets/Sets the Translation portion of the matrix. 0 0 0 Tx   0 0 0 Ty   0 0 0 Tz   0 0 0 1  
Zero : Matrix4 public Returns a matrix with all elements set to 0.

Method Members

Name Access Summary
Add() : Matrix4 public Used to add two matrices together.
Equals() : Boolean public Compares this Matrix to another object. This should be done because the equality operators (=, ) have been overriden by this class.
FromMatrix3?() : Matrix4 public Used to allow assignment from a Matrix3 to a Matrix4 object.
GetHashCode?() : Int32 public Provides a unique hash code based on the member variables of this class. This should be done because the equality operators (=, ) have been overriden by this class. The standard implementation is a simple XOR operation between all local member variables.
GetMatrix3?() : Matrix3 public Returns a 3x3 portion of this 4x4 matrix.
Inverse() : Matrix4 public Returns an inverted 4d matrix.
MakeFloatArray?() : Void public
Multiply() : Matrix4 public Used to multiply (concatenate) two 4x4 Matrices.
Multiply() : Plane public Transforms a plane using the specified transform.
Multiply() : Vector3 public Transforms the given 3-D vector by the matrix, projecting the result back into w = 1. This means that the initial w is considered to be 1.0, and then all the tree elements of the resulting 3-D vector are divided by the resulting w.
Subtract() : Matrix4 public Used to subtract two matrices.
ToString?() : String public Overrides the ToString?() method to provide a text representation of a Matrix4.
Transpose() : Matrix4 public Swap the rows of the matrix with the columns.

Matrix3 Structure

Summary

public structure Matrix3

A 3x3 matrix which can represent rotations around axes.

Remarks

A 3x3 matrix which can represent rotations around axes.

Constructor Members

Name Access Summary
Matrix3() public Create a new Matrix from 3 Vertex3 objects.
Matrix3() public Creates a new Matrix3 with all the specified parameters.

Field Members

Name Access Summary
m00 : Single public
m01 : Single public
m02 : Single public
m10 : Single public
m11 : Single public
m12 : Single public
m20 : Single public
m21 : Single public
m22 : Single public

Property Members

Name Access Summary
Determinant : Single public
Identity : Matrix3 public Identity Matrix
Item : Single public Allows the Matrix to be accessed linearly (m[0] -> m[8]).
Item : Single public Indexer for accessing the matrix like a 2d array (i.e. matrix[2,3]).
Zero : Matrix3 public Zero matrix.

Method Members

Name Access Summary
Add() : Matrix3 public Used to add two matrices together.
Equals() : Boolean public Compares this Matrix to another object. This should be done because the equality operators (=, ) have been overriden by this class.
FromAxes?() : Void public Creates a Matrix3 from 3 axes.
FromEulerAnglesXYZ?() : Void public Constructs this Matrix from 3 euler angles, in degrees.
GetColumn?() : Vector3 public Gets a matrix column by index.
GetHashCode?() : Int32 public Provides a unique hash code based on the member variables of this class. This should be done because the equality operators (=, ) have been overriden by this class. The standard implementation is a simple XOR operation between all local member variables.
Multiply() : Matrix3 public Multiply (concatenate) two Matrix3 instances together.
Multiply() : Vector3 public matrix * vector [3x3 * 3x1 = 3x1]
Multiply() : Matrix3 public Multiplies all the items in the Matrix3 by a scalar value.
Multiply() : Vector3 public vector * matrix [1x3 * 3x3 = 1x3]
Multiply() : Matrix3 public Multiplies all the items in the Matrix3 by a scalar value.
Negate() : Matrix3 public Negates all the items in the Matrix.
SetColumn?() : Void public Sets one of the columns of the Matrix with a Vector3.
Subtract() : Matrix3 public Used to subtract two matrices.
ToString?() : String public Overrides the ToString?() method to provide a text representation of a Matrix4.
Transpose() : Matrix3 public Swap the rows of the matrix with the columns.

Vector4 Structure

Summary

public structure Vector4

4D homogeneous vector.

Remarks

4D homogeneous vector.

Constructor Members

Name Access Summary
Vector4() public Creates a new 4 dimensional Vector.

Field Members

Name Access Summary
w : Single public
x : Single public
y : Single public
z : Single public

Property Members

Name Access Summary
Item : Single public Used to access a Vector by index 0 = this.x, 1 = this.y, 2 = this.z, 3 = this.w.

Method Members

Name Access Summary
Dot() : Single public Calculates the dot (scalar) product of this vector with another.
Equals() : Boolean public Compares this Vector to another object. This should be done because the equality operators (=, ) have been overriden by this class.
GetHashCode?() : Int32 public Provides a unique hash code based on the member variables of this class. This should be done because the equality operators (=, ) have been overriden by this class. The standard implementation is a simple XOR operation between all local member variables.
Multiply() : Vector4 public
ToString?() : String public Overrides the ToString?() method to provide a text representation of a Vector4.

Vector3 Structure

Summary

public structure Vector3

Standard 3-dimensional vector.

Remarks

A direction in 3D space represented as distances along the 3 orthoganal axes (x, y, z). Note that positions, directions and scaling factors can be represented by a vector, depending on how you interpret the values.

Constructor Members

Name Access Summary
Vector3() public Creates a new 3 dimensional Vector.

Field Members

Name Access Summary
x : Single public X component.
y : Single public Y component.
z : Single public Z component.

Property Members

Name Access Summary
Item : Single public Used to access a Vector by index 0 = x, 1 = y, 2 = z.
Length : Single public Gets the length (magnitude) of this Vector3. The Sqrt operation is expensive, so only use this if you need the exact length of the Vector. If vector lengths are only going to be compared, use LengthSquared? instead.
LengthSquared? : Single public Returns the length (magnitude) of the vector squared.
NegativeUnitX? : Vector3 public Gets a Vector3 with the X set to -1, and the others set to 0.
NegativeUnitY? : Vector3 public Gets a Vector3 with the Y set to -1, and the others set to 0.
NegativeUnitZ? : Vector3 public Gets a Vector3 with the Z set to -1, and the others set to 0.
UnitScale? : Vector3 public Gets a Vector3 with all components set to 1.
UnitX? : Vector3 public Gets a Vector3 with the X set to 1, and the others set to 0.
UnitY? : Vector3 public Gets a Vector3 with the Y set to 1, and the others set to 0.
UnitZ? : Vector3 public Gets a Vector3 with the Z set to 1, and the others set to 0.
Zero : Vector3 public Gets a Vector3 with all components set to 0.

Method Members

Name Access Summary
Add() : Vector3 public Used when a Vector3 is added to another Vector3.
Ceil() : Void public Compares the supplied vector and updates it's x/y/z components of they are higher in value.
Cross() : Vector3 public Performs a Cross Product operation on 2 vectors, which returns a vector that is perpendicular to the intersection of the 2 vectors. Useful for finding face normals.
Divide() : Vector3 public Used to divide a vector by a scalar value.
Dot() : Single public Performs a Dot Product operation on 2 vectors, which produces the angle between them.
Equals() : Boolean public Compares this Vector to another object. This should be done because the equality operators (=, ) have been overriden by this class.
Floor() : Void public Compares the supplied vector and updates it's x/y/z components of they are lower in value.
GetHashCode?() : Int32 public Provides a unique hash code based on the member variables of this class. This should be done because the equality operators (=, ) have been overriden by this class. The standard implementation is a simple XOR operation between all local member variables.
GetRotationTo?() : Quaternion public Gets the shortest arc quaternion to rotate this vector to the destination vector.
MidPoint?() : Vector3 public Finds the midpoint between the supplied Vector and this vector.
Multiply() : Vector3 public Used when a Vector3 is multiplied by another vector.
Multiply() : Vector3 public Used when a Vector3 is multiplied by a scalar value.
Multiply() : Vector3 public Used when a scalar value is multiplied by a Vector3.
Negate() : Vector3 public Used to negate the elements of a vector.
Normalize() : Single public Normalizes the vector.
Perpendicular() : Vector3 public Finds a vector perpendicular to this one.
RandomDeviant?() : Vector3 public
Reflect() : Vector3 public Calculates a reflection vector to the plane with the given normal.
Subtract() : Vector3 public Used to subtract a Vector3 from another Vector3.
ToString?() : String public Overrides the ToString?() method to provide a text representation of a Vector3.


MathLib? Classes

AxisAlignedBox Class

Summary

public class AxisAlignedBox? : System.ICloneable

A 3D box aligned with the x/y/z axes.

Remarks

This class represents a simple box which is aligned with the axes. Internally it only stores 2 points as the extremeties of the box, one which is the minima of all 3 axes, and the other which is the maxima of all 3 axes. This class is typically used for an axis-aligned bounding box (AABB) for collision and visibility determination.

Constructor Members

Name Access Summary
AxisAlignedBox?() public Initializes a new instance of the class.
AxisAlignedBox?() public

Property Members

Name Access Summary
Center : Vector3 public Gets the center point of this bounding box.
Corners : Vector3[] public Returns an array of 8 corner points, useful for collision vs. non-aligned objects.
IsNull? : Boolean public Gets/Sets the value of whether this box is null (i.e. not dimensions, etc).
Maximum : Vector3 public Gets/Sets the maximum corner of the box.
Minimum : Vector3 public Gets/Sets the minimum corner of the box.
Null : AxisAlignedBox? public Returns a null box

Method Members

Name Access Summary
Clone() : Object public
Intersects() : Boolean public Returns whether or not this box intersects another.
Intersects() : Boolean public
Intersects() : Boolean public Tests whether this box intersects a sphere.
Intersects() : Boolean public Tests whether the vector point is within this box.
Merge() : Void public Allows for merging two boxes together (combining).
Scale() : Void public Scales the size of the box by the supplied factor.
SetExtents?() : Void public Sets both Minimum and Maximum at once, so that UpdateCorners? only needs to be called once as well.
Transform() : Void public

RotationalSpline Class

Summary

public class RotationalSpline?

A class used to interpolate orientations (rotations) along a spline using derivatives of quaternions.

Remarks

Like the PositionalSpline? class, this class is about interpolating values smoothly over a spline. Whilst PositionalSpline? deals with positions (the normal sense we think about splines), this class interpolates orientations. The theory is identical, except we're now in 4-dimensional space instead of 3.

In positional splines, we use the points and tangents on those points to generate control points for the spline. In this case, we use quaternions and derivatives of the quaternions (i.e. the rate and direction of change at each point). This is the same as PositionalSpline? since a tangent is a derivative of a position. We effectively generate an extra quaternion in between each actual quaternion which when take with the original quaternion forms the 'tangent' of that quaternion.

Constructor Members

Name Access Summary
RotationalSpline?() public Creates a new Rotational Spline.

Property Members

Name Access Summary
AutoCalculate? : Boolean public Specifies whether or not to recalculate tangents as each control point is added.
PointCount? : Int32 public Gets the number of control points in this spline.

Method Members

Name Access Summary
AddPoint?() : Void public Adds a control point to the end of the spline.
Clear() : Void public Removes all current control points from this spline.
Interpolate() : Quaternion public
Interpolate() : Quaternion public Interpolates a single segment of the spline given a parametric value.
Interpolate() : Quaternion public
Interpolate() : Quaternion public Returns an interpolated point based on a parametric value over the whole series.
RecalculateTangents?() : Void public Recalculates the tangents associated with this spline.

Sphere Class

Summary

public class Sphere

A standard sphere, used mostly for bounds checking.

Remarks

A sphere in math texts is normally represented by the function x^2 + y^2 + z^2 = r^2 (for sphere's centered on the origin). We store spheres simply as a center point and a radius.

Constructor Members

Name Access Summary
Sphere() public Creates a unit sphere centered at the origin.
Sphere() public Creates an arbitrary spehere.

Property Members

Name Access Summary
Center : Vector3 public Gets/Sets the center of the sphere.
Radius : Single public Gets/Sets the radius of the sphere.

Method Members

Name Access Summary
Intersects() : Boolean public Returns whether or not this sphere interects a box.
Intersects() : Boolean public Returns whether or not this sphere interects a plane.
Intersects() : Boolean public Tests for intersection between this sphere and another sphere.
Intersects() : Boolean public Returns whether or not this sphere interects a Vector3.

PositionalSpline Class

Summary

public class PositionalSpline?

A Catmull-Rom spline that can be used for interpolating translation movements.

Remarks

A Catmull-Rom spline is a derivitive of the Hermite spline. The difference is that the Hermite spline allows you to specifiy 2 endpoints and 2 tangents, then the spline is generated. A Catmull-Rom spline allows you to just supply 1-n number of points and the tangents will be automatically calculated.

Derivation of the hermite polynomial can be found here: Hermite splines.

Constructor Members

Name Access Summary
PositionalSpline?() public Creates a new Positional Spline.

Property Members

Name