math/ matrix.bi | |
License | Copyright © 2009, FreeBASIC Extended Library Development Group |
ext.math | |
matrix | Standard OpenGL style (column major) matrix class for 3D programming. |
Functions | |
constructor | Default constructor initializing the matrix to 0 |
constructor | Constructor used to set matrix values to a set of vectors. |
constructor | Constructs a matrix from another. |
LoadIdentity | “Resets” a transformation matrix with no rotation, translation, scaling or skewing. |
Identity | Returns the identity matrix, a matrix whose axis are normalized on the x, y and z axis, and whose position is at the origin (0, 0, 0). |
LookAt | Simplifies the construction of camera systems commonly used in 3d games. |
PointAt | Simplifies the creation of aligned matrices |
Inverse | This function is useful if you need the inverse matrix for calculating the local position of a vector, such as a light source. |
Invert | Inverts the matrix. |
Invert_copy | Returns the inverse of the matrix. |
PlanarProjection | Builds a planar projection matrix using vector4d and plane(vector4d). |
InfiniteProjection | Builds an infinite projection matrix using fov(field of view), aspectratio( aspect ratio ) and znear( znear ) |
AxisAngle | |
Translate | generic translation function |
Rotate | generic rotation function |
Rotate | generic rotation function |
Scale | Scales each axis of the matrix by scalar |
Scale | Scales each axis of the matrix independently |
Gram_Scmidt | Calculates an orthonormal matrix with the forward vector aligned with vector “d”, while “vectors “up” and “right” are calculated using the “Gram Schmidt” method. |
Properties | |
Right | setter for the right vector component |
Up | setter for the up vector component |
Forward | setter for the forward vector component |
Position | setter for the position vector component |
Right | getter for the right vector component |
Up | getter for the up vector component |
Forward | getter for the forward vector component |
Position | getter for the position vector component |
GetArrayData | Returns a pointer to the matrix data for passing to OpenGL functions. |
Copyright © 2009, FreeBASIC Extended Library Development Group
Distributed under the FreeBASIC Extended Library Group license. See accompanying file LICENSE.txt or copy at http://code.google.com- /p- /fb-extended-lib- /wiki- /License
Standard OpenGL style (column major) matrix class for 3D programming.
For simplicity, any reference to plane, will be vector4d for this library.
Functions | |
constructor | Default constructor initializing the matrix to 0 |
constructor | Constructor used to set matrix values to a set of vectors. |
constructor | Constructs a matrix from another. |
LoadIdentity | “Resets” a transformation matrix with no rotation, translation, scaling or skewing. |
Identity | Returns the identity matrix, a matrix whose axis are normalized on the x, y and z axis, and whose position is at the origin (0, 0, 0). |
LookAt | Simplifies the construction of camera systems commonly used in 3d games. |
PointAt | Simplifies the creation of aligned matrices |
Inverse | This function is useful if you need the inverse matrix for calculating the local position of a vector, such as a light source. |
Invert | Inverts the matrix. |
Invert_copy | Returns the inverse of the matrix. |
PlanarProjection | Builds a planar projection matrix using vector4d and plane(vector4d). |
InfiniteProjection | Builds an infinite projection matrix using fov(field of view), aspectratio( aspect ratio ) and znear( znear ) |
AxisAngle | |
Translate | generic translation function |
Rotate | generic rotation function |
Rotate | generic rotation function |
Scale | Scales each axis of the matrix by scalar |
Scale | Scales each axis of the matrix independently |
Gram_Scmidt | Calculates an orthonormal matrix with the forward vector aligned with vector “d”, while “vectors “up” and “right” are calculated using the “Gram Schmidt” method. |
Properties | |
Right | setter for the right vector component |
Up | setter for the up vector component |
Forward | setter for the forward vector component |
Position | setter for the position vector component |
Right | getter for the right vector component |
Up | getter for the up vector component |
Forward | getter for the forward vector component |
Position | getter for the position vector component |
GetArrayData | Returns a pointer to the matrix data for passing to OpenGL functions. |
declare sub LookAt( byref v1 as vector3d, byref v2 as vector3d, byref vup as vector3d )
Simplifies the construction of camera systems commonly used in 3d games.
v1 | center of rotation: an example would be to send the player’s position vector |
v2 | view vector: an example would be to send the player’s forward vector |
vup | up vector: in a first person shooter, this would amost always be a <vector3d>(0,1,0) |
declare function Inverse() as matrix
This function is useful if you need the inverse matrix for calculating the local position of a vector, such as a light source. It’s commonly used for such things as shadow volume projection and bump mapping in 3d scenes. This function is especially useful because the OpenGL API does not provide an inverse matrix function.
The inverse of the matrix.
declare sub Invert()
Inverts the matrix. The new matrix value, when multiplied by it’s previous value, results in the identity matrix.
This function is useful if you need the inverse matrix for calculating the local position of a vector, such as a light source. It’s commonly used for such things as shadow volume projection and bump mapping in 3d scenes. This function is especially useful because the OpenGL API does not provide an inverse matrix function.
declare function PlanarProjection( byref lightpos as vector4d, byref plane as vector4D ) as matrix
Builds a planar projection matrix using vector4d and plane(vector4d). For simplicity, this library has no “plane” type, it uses vector4d.
lightpos | position of light source(vector4d) |
plane | plane to project onto. |
the new planar projection matrix
declare sub InfiniteProjection( byref fov as single, byref aspectratio as single, byref znear as single )
Builds an infinite projection matrix using fov(field of view), aspectratio( aspect ratio ) and znear( znear )
fov field of view... in opengl, use the same value you would bnormally build your projection matrix with aspectratio... again, in opengl, use the same value you would normally build your projection matrix with znear... and again, in opengl, use the same value you would normally build your projection matrix with
nothing
Default constructor initializing the matrix to 0
declare constructor( byref c as single = 0 )
“Resets” a transformation matrix with no rotation, translation, scaling or skewing.
declare sub LoadIdentity()
Returns the identity matrix, a matrix whose axis are normalized on the x, y and z axis, and whose position is at the origin (0, 0, 0).
declare static function Identity ( ) as matrix
Simplifies the construction of camera systems commonly used in 3d games.
declare sub LookAt( byref v1 as vector3d, byref v2 as vector3d, byref vup as vector3d )
Simplifies the creation of aligned matrices
declare sub PointAt( byref v1 as vector3d, byref v2 as vector3d )
This function is useful if you need the inverse matrix for calculating the local position of a vector, such as a light source.
declare function Inverse() as matrix
Inverts the matrix.
declare sub Invert()
Returns the inverse of the matrix.
declare function Invert_copy() as matrix
Builds a planar projection matrix using vector4d and plane(vector4d).
declare function PlanarProjection( byref lightpos as vector4d, byref plane as vector4D ) as matrix
Builds an infinite projection matrix using fov(field of view), aspectratio( aspect ratio ) and znear( znear )
declare sub InfiniteProjection( byref fov as single, byref aspectratio as single, byref znear as single )
declare sub AxisAngle( byref v as vector3d, byref angle as single )
generic translation function
declare sub Translate( byref x as single, byref y as single, byref z as single )
generic rotation function
declare sub Rotate( byref anglex as single, byref angley as single, byref anglez as single )
Scales each axis of the matrix by scalar
declare sub Scale( byref scalar as single )
setter for the right vector component
declare property Right( byref v as vector3d )
setter for the up vector component
declare property Up( byref v as vector3d )
setter for the forward vector component
declare property Forward( byref v as vector3d )
setter for the position vector component
declare property Position( byref v as vector3d )
Returns a pointer to the matrix data for passing to OpenGL functions.
declare property GetArrayData() as single ptr