matrix.c File Reference

#include "matrix.h"

Go to the source code of this file.

Data Structures

struct  MATRIXINTERNAL

Defines

#define ASSERTMATRIX(x)

Enumerations

enum  MATRIXFLAGS { MatrixIdentity = 0x01, MatrixTranslation = 0x02, MatrixScaling = 0x04, MatrixUnknown = 0x08 }

Functions

static void AssertMatrix (MATRIX *matrix, char *file, int line)
BOOL MatrixEquals (MATRIX *matrix, MATRIX *matrix2)
 Determines whether the matrix equals another matrix.
BOOL MatrixAreClose (MATRIX *matrix, MATRIX *matrix2)
 Determines whether the matrix is close to another matrix.
void MatrixTransformPoints (MATRIX *matrix, double *pts, DWORD numpts)
 Transforms an array of points using the specified matrix.
void MatrixTransformVectors (MATRIX *matrix, double *pts, DWORD numpts)
 Transforms an array of distance vectors using the specified matrix, ignoring the translation components of the matrix.
double MatrixDeterminant (MATRIX *matrix)
 Gets the determinant of the matrix, or the ratio by which an object transformed by this matrix changes in size.
static void MatrixUpdate (MATRIX *matrix)
double MatrixGetValue (MATRIX *matrix, MATRIXELEMENT elem)
 Gets a matrix element from the matrix.
BOOL MatrixSetValue (MATRIX *matrix, MATRIXELEMENT elem, double value)
 Sets a matrix element in the matrix to _value_.
BOOL MatrixGetValueArray (MATRIX *matrix, double *values)
 Gets the elements in the matrix.
BOOL MatrixSetValueArray (MATRIX *matrix, double *values)
 Sets all elements in the matrix at once.
BOOL MatrixIsInvertible (MATRIX *matrix)
 Determines whether the matrix can be inverted.
BOOL MatrixInvert (MATRIX *matrixDst, MATRIX *matrixSrc)
 Inverts _matSrc_ and stores the result in _matDst_.
BOOL MatrixIsIdentity (MATRIX *matrix)
 Determines whether the matrix equals the identity matrix.
void MatrixSetIdentity (MATRIX *matrix)
 Sets this matrix to the identity matrix.
void MatrixSetValues (MATRIX *matrix, double m11, double m12, double m21, double m22, double dx, double dy)
 Sets all elements in the matrix at once.
static void DebugOutMatrixInternal (MATRIXINTERNAL *mat)
void MatrixMultiply (MATRIX *matrixResult, MATRIX *matrixLeft, MATRIX *matrixRight)
 Multiplies two matrices (matLeft and matRight) and stores the result in matResult.
static void MatrixApply (MATRIX *matrix, MATRIXINTERNAL *matSrc, MATRIXMODE mode)
void MatrixTranslate (MATRIX *matrix, double x, double y, MATRIXMODE mode)
 Adds a translation transform to the matrix.
void MatrixRotate (MATRIX *matrix, double degrees, MATRIXMODE mode)
 Adds a rotation to this matrix.
void MatrixRotateAt (MATRIX *matrix, double degrees, double x, double y, MATRIXMODE mode)
 Adds a rotation to this matrix with the specified origin.
void MatrixScale (MATRIX *matrix, double x, double y, MATRIXMODE mode)
 Adds a scaling transform to this matrix.
void MatrixScaleAt (MATRIX *matrix, double x, double y, double centerX, double centerY, MATRIXMODE mode)
 Adds a scaling transform to this matrix with the specified origin.
void MatrixSkew (MATRIX *matrix, double angleX, double angleY, MATRIXMODE mode)
 Adds a skew transform to the matrix.
void MatrixShear (MATRIX *matrix, double shearX, double shearY, MATRIXMODE mode)
 Adds a shear transform to the matrix.
void MatrixParallelogram (MATRIX *matrix, double *rect, double *points, MATRIXMODE mode)
 Adds a transform to this matrix based on the conversion of a rectangle to a parallelogram.


Define Documentation

#define ASSERTMATRIX  ) 
 

Definition at line 32 of file matrix.c.


Enumeration Type Documentation

enum MATRIXFLAGS
 

Enumerator:
MatrixIdentity 
MatrixTranslation 
MatrixScaling 
MatrixUnknown 

Definition at line 10 of file matrix.c.


Function Documentation

static void AssertMatrix MATRIX matrix,
char *  file,
int  line
[static]
 

Definition at line 34 of file matrix.c.

static void DebugOutMatrixInternal MATRIXINTERNAL mat  )  [static]
 

Definition at line 266 of file matrix.c.

static void MatrixApply MATRIX matrix,
MATRIXINTERNAL matSrc,
MATRIXMODE  mode
[static]
 

Definition at line 351 of file matrix.c.

BOOL MatrixAreClose MATRIX matrix,
MATRIX matrix2
 

Determines whether the matrix is close to another matrix.

Definition at line 72 of file matrix.c.

double MatrixDeterminant MATRIX mat  ) 
 

Gets the determinant of the matrix, or the ratio by which an object transformed by this matrix changes in size.

If this value equals 0, then the matrix is one that maps coordinates to a single point or line and can't be inverted.

Definition at line 133 of file matrix.c.

BOOL MatrixEquals MATRIX matrix,
MATRIX matrix2
 

Determines whether the matrix equals another matrix.

Definition at line 58 of file matrix.c.

double MatrixGetValue MATRIX matrix,
MATRIXELEMENT  elem
 

Gets a matrix element from the matrix.

Definition at line 161 of file matrix.c.

BOOL MatrixGetValueArray MATRIX mat,
double *  values
 

Gets the elements in the matrix.

Parameters:
mat A matrix structure.
pts An array of six double values.
Returns:
TRUE if successful, FALSE otherwise.

Definition at line 175 of file matrix.c.

BOOL MatrixInvert MATRIX matDst,
MATRIX matSrc
 

Inverts _matSrc_ and stores the result in _matDst_.

The inverted matrix, when combined with the source matrix, results in the identity matrix.

Parameters:
matDst The matrix to store the result.
matSrc The input matrix.
Returns:
TRUE if the matrix was inverted, FALSE if matDst or matSrc is NULL or matSrc is not invertible.

Definition at line 206 of file matrix.c.

BOOL MatrixIsIdentity MATRIX matrix  ) 
 

Determines whether the matrix equals the identity matrix.

Definition at line 233 of file matrix.c.

BOOL MatrixIsInvertible MATRIX mat  ) 
 

Determines whether the matrix can be inverted.

A matrix is invertible if its determinant is not equal to 0.

Definition at line 200 of file matrix.c.

void MatrixMultiply MATRIX matrixResult,
MATRIX matrixLeft,
MATRIX matrixRight
 

Multiplies two matrices (matLeft and matRight) and stores the result in matResult.

Definition at line 270 of file matrix.c.

void MatrixParallelogram MATRIX mat,
double *  rect,
double *  points,
MATRIXMODE  mode
 

Adds a transform to this matrix based on the conversion of a rectangle to a parallelogram.

Parameters:
mat A matrix structure.
rect An array of four Double values specifying the X, Y, width, and height of a rectangle.
points An array of six Double values in three pairs that specify the upper-left, upper-right, and lower-left corners of a parallelogram.
mode Specifies how the calculated matrix is combined with this matrix. See MATRIXMODE for details.

Definition at line 482 of file matrix.c.

void MatrixRotate MATRIX mat,
double  degrees,
MATRIXMODE  mode
 

Adds a rotation to this matrix.

Parameters:
mat A matrix structure.
degrees The angle of the rotation, in degrees.
mode Specifies how the calculated matrix is combined with this matrix. See MATRIXMODE for details.

Definition at line 391 of file matrix.c.

void MatrixRotateAt MATRIX mat,
double  degrees,
double  x,
double  y,
MATRIXMODE  mode
 

Adds a rotation to this matrix with the specified origin.

Parameters:
mat A matrix structure.
degrees The angle of the rotation, in degrees.
x X coordinate for the rotation's center.
y Y coordinate for the rotation's center.
mode Specifies how the calculated matrix is combined with this matrix. See MATRIXMODE for details.

Definition at line 409 of file matrix.c.

void MatrixScale MATRIX mat,
double  x,
double  y,
MATRIXMODE  mode
 

Adds a scaling transform to this matrix.

Parameters:
mat A matrix structure.
x X scaling factor.
y Y scaling factor.
mode Specifies how the calculated matrix is combined with this matrix. See MATRIXMODE for details.

Definition at line 427 of file matrix.c.

void MatrixScaleAt MATRIX mat,
double  x,
double  y,
double  centerX,
double  centerY,
MATRIXMODE  mode
 

Adds a scaling transform to this matrix with the specified origin.

Parameters:
mat A matrix structure.
x X scaling factor.
y Y scaling factor.
centerX X coordinate for the scaling transform's center.
centerY Y coordinate for the scaling transform's center.
mode Specifies how the calculated matrix is combined with this matrix. See MATRIXMODE for details.

Definition at line 440 of file matrix.c.

void MatrixSetIdentity MATRIX matrix  ) 
 

Sets this matrix to the identity matrix.

Definition at line 243 of file matrix.c.

BOOL MatrixSetValue MATRIX matrix,
MATRIXELEMENT  elem,
double  value
 

Sets a matrix element in the matrix to _value_.

Definition at line 167 of file matrix.c.

BOOL MatrixSetValueArray MATRIX mat,
double *  values
 

Sets all elements in the matrix at once.

Parameters:
mat A matrix structure.
pts An array of six double values.
Returns:
TRUE if successful, FALSE otherwise.

Definition at line 187 of file matrix.c.

void MatrixSetValues MATRIX matrix,
double  m11,
double  m12,
double  m21,
double  m22,
double  dx,
double  dy
 

Sets all elements in the matrix at once.

Definition at line 255 of file matrix.c.

void MatrixShear MATRIX mat,
double  shearX,
double  shearY,
MATRIXMODE  mode
 

Adds a shear transform to the matrix.

Parameters:
mat A matrix structure.
shearX The shear factor along the X axis.
shearY The shear factor along the Y axis.
mode Specifies how the calculated matrix is combined with this matrix. See MATRIXMODE for details.

Definition at line 468 of file matrix.c.

void MatrixSkew MATRIX mat,
double  angleX,
double  angleY,
MATRIXMODE  mode
 

Adds a skew transform to the matrix.

Parameters:
mat A matrix structure.
angleX The skew angle along the X axis. The X shearing factor will equal the tangent of this angle.
angleY The skew angle along the Y axis. The Y shearing factor will equal the tangent of this angle.
mode Specifies how the calculated matrix is combined with this matrix. See MATRIXMODE for details.

Definition at line 453 of file matrix.c.

void MatrixTransformPoints MATRIX mat,
double *  pts,
DWORD  numpts
 

Transforms an array of points using the specified matrix.

See also MatrixTransformVectors().

Parameters:
mat A matrix for transforming the points.
pts An array of points. Each point is a pair of double values, where the first value is the X coordinate and the second is the Y coordinate.
numpts The number of points (pairs of _double_ floating point values) in the array.

Definition at line 86 of file matrix.c.

void MatrixTransformVectors MATRIX mat,
double *  pts,
DWORD  numpts
 

Transforms an array of distance vectors using the specified matrix, ignoring the translation components of the matrix.

See also MatrixTransformPoints().

Parameters:
mat A matrix for transforming the vectors. The translation coordinates (Dx and Dy) are ignored.
pts An array of vectors. Each vector is a pair of double values, where the first value is the X coordinate and the second is the Y coordinate.
numpts The number of vectors (pairs of _double_ floating point values) in the array.

Definition at line 113 of file matrix.c.

void MatrixTranslate MATRIX mat,
double  x,
double  y,
MATRIXMODE  mode
 

Adds a translation transform to the matrix.

Parameters:
mat A matrix structure.
x The X-offset of the translation.
y The Y-offset of the translation.
mode Specifies how the calculated matrix is combined with this matrix. See MATRIXMODE for details.

Definition at line 361 of file matrix.c.

static void MatrixUpdate MATRIX matrix  )  [inline, static]
 

Definition at line 146 of file matrix.c.


Generated on Thu Mar 27 01:46:56 2008 for Item Arrays by  doxygen 1.4.6-NO