Unit Geometry

Classes

Functions

ConvertRotation - mixed functions

------------------------------------------------------------------------------
CreateRotationMatrix - ------------------------------------------------------------------------------
CreateRotationMatrixX - matrix functions

------------------------------------------------------------------------------
CreateRotationMatrixY - ------------------------------------------------------------------------------
CreateRotationMatrixZ - ------------------------------------------------------------------------------
CreateScaleMatrix - ------------------------------------------------------------------------------
CreateTranslationMatrix - ------------------------------------------------------------------------------
MakeAffineDblVector - miscellaneous functions

------------------------------------------------------------------------------
MakeAffineVector - ------------------------------------------------------------------------------
MakeDblVector - ------------------------------------------------------------------------------
MakeVector - ------------------------------------------------------------------------------
MatrixAdjoint - ------------------------------------------------------------------------------
MatrixAffineDeterminant - ------------------------------------------------------------------------------
MatrixAffineTranspose - ------------------------------------------------------------------------------
MatrixDecompose - ------------------------------------------------------------------------------
MatrixDeterminant - ------------------------------------------------------------------------------
MatrixInvert - ------------------------------------------------------------------------------
MatrixMultiply - ------------------------------------------------------------------------------
MatrixScale - ------------------------------------------------------------------------------
MatrixTranspose - ------------------------------------------------------------------------------
PointInPolygon - ------------------------------------------------------------------------------
QuaternionConjugate - quaternion functions

------------------------------------------------------------------------------
QuaternionFromPoints - ------------------------------------------------------------------------------
QuaternionMultiply - ------------------------------------------------------------------------------
QuaternionSlerp - ------------------------------------------------------------------------------
QuaternionToMatrix - ------------------------------------------------------------------------------
QuaternionToPoints - ------------------------------------------------------------------------------
VectorAdd - ------------------------------------------------------------------------------ vector functions

------------------------------------------------------------------------------
VectorAffineAdd - ------------------------------------------------------------------------------
VectorAffineCombine - ------------------------------------------------------------------------------
VectorAffineDblToFlt - ------------------------------------------------------------------------------
VectorAffineDotProduct - ------------------------------------------------------------------------------
VectorAffineFltToDbl - ------------------------------------------------------------------------------
VectorAffineLerp - ------------------------------------------------------------------------------
VectorAffineSubtract - ------------------------------------------------------------------------------
VectorAffineTransform - ------------------------------------------------------------------------------
VectorAngle - ------------------------------------------------------------------------------
VectorCombine - ------------------------------------------------------------------------------
VectorCrossProduct - ------------------------------------------------------------------------------
VectorDblToFlt - ------------------------------------------------------------------------------
VectorDotProduct - ------------------------------------------------------------------------------
VectorFltToDbl - ------------------------------------------------------------------------------
VectorLength - ------------------------------------------------------------------------------
VectorLerp - ------------------------------------------------------------------------------
VectorNegate - ------------------------------------------------------------------------------
VectorNorm - ------------------------------------------------------------------------------
VectorNormalize - ------------------------------------------------------------------------------
VectorPerpendicular - ------------------------------------------------------------------------------
VectorReflect - ------------------------------------------------------------------------------
VectorScale - ------------------------------------------------------------------------------
VectorSubtract - ------------------------------------------------------------------------------
VectorTransform - ------------------------------------------------------------------------------

Types

PAffineByteVector
PAffineDblVector
PAffineExtVector
PAffineFltVector
PAffineIntVector
PAffineMatrix
PAffinePtrVector
PAffineVector
PAffineWordVector
PByte
PByteVector
PDblVector
PDouble
PExtended
PFloat
PFloatVector
PHomogeneousByteVector
PHomogeneousDblVector
PHomogeneousExtVector
PHomogeneousFltVector
PHomogeneousIntVector
PHomogeneousMatrix
PHomogeneousPtrVector
PHomogeneousVector
PHomogeneousWordVector
PInteger
PIntVector
PMatrix
PPointer
PVector
PVectorArray
PWord
PWordVector
TAffineByteMatrix
TAffineByteVector
TAffineDblMatrix
TAffineDblVector
TAffineExtMatrix
TAffineExtVector
TAffineFltMatrix
TAffineFltVector
TAffineIntMatrix
TAffineIntVector
TAffineMatrix
TAffinePtrVector
TAffineVector
TAffineWordMatrix
TAffineWordVector
TByteVector
TDblVector
TFloatVector
THomogeneousByteMatrix
THomogeneousByteVector
THomogeneousDblMatrix
THomogeneousDblVector
THomogeneousExtMatrix
THomogeneousExtVector
THomogeneousFltMatrix
THomogeneousFltVector
THomogeneousIntMatrix
THomogeneousIntVector
THomogeneousMatrix
THomogeneousPtrVector
THomogeneousVector
THomogeneousWordMatrix
THomogeneousWordVector
TIntVector
TMatrix
TMatrix3b
TMatrix3d
TMatrix3e
TMatrix3f
TMatrix3i
TMatrix3w
TMatrix4b
TMatrix4d
TMatrix4e
TMatrix4f
TMatrix4i
TMatrix4w
TQuaternion
TRectangle
TTransformations
TTransType
TVector
TVector3b
TVector3d
TVector3e
TVector3f
TVector3i
TVector3p
TVector3w
TVector4b
TVector4d
TVector4e
TVector4f
TVector4i
TVector4p
TVector4w
TVectorArray
TWordVector

Constants

EmptyMatrix
EPSILON
EPSILON2
IdentityMatrix
NullVector
XVector
YVector
ZVector

Variables


Functions


function ConvertRotation(Angles: TAffineVector): TVector;

mixed functions

------------------------------------------------------------------------------


function CreateRotationMatrix(Axis: TAffineVector; Angle: Single): TMatrix;

------------------------------------------------------------------------------

function CreateRotationMatrixX(Sine, Cosine: Single): TMatrix;

matrix functions

------------------------------------------------------------------------------


function CreateRotationMatrixY(Sine, Cosine: Single): TMatrix;

------------------------------------------------------------------------------

function CreateRotationMatrixZ(Sine, Cosine: Single): TMatrix;

------------------------------------------------------------------------------

function CreateScaleMatrix(V: TAffineVector): TMatrix;

------------------------------------------------------------------------------

function CreateTranslationMatrix(V: TAffineVector): TMatrix;

------------------------------------------------------------------------------

function MakeAffineDblVector(V: array of Double): TAffineDblVector;

miscellaneous functions

------------------------------------------------------------------------------


function MakeAffineVector(V: array of Single): TAffineVector;

------------------------------------------------------------------------------

function MakeDblVector(V: array of Double): THomogeneousDblVector;

------------------------------------------------------------------------------

function MakeVector(V: array of Single): TVector;

------------------------------------------------------------------------------

procedure MatrixAdjoint(var M: TMatrix);

------------------------------------------------------------------------------

function MatrixAffineDeterminant(M: TAffineMatrix): Single;

------------------------------------------------------------------------------

procedure MatrixAffineTranspose(var M: TAffineMatrix);

------------------------------------------------------------------------------

function MatrixDecompose(M: TMatrix; var Tran: TTransformations): Boolean;

------------------------------------------------------------------------------

function MatrixDeterminant(M: TMatrix): Single;

------------------------------------------------------------------------------

procedure MatrixInvert(var M: TMatrix);

------------------------------------------------------------------------------

function MatrixMultiply(M1, M2: TMatrix): TMatrix;

------------------------------------------------------------------------------

procedure MatrixScale(var M: TMatrix; Factor: Single);

------------------------------------------------------------------------------

procedure MatrixTranspose(var M: TMatrix);

------------------------------------------------------------------------------

function PointInPolygon(xp, yp : array of Single; x,y: Single): Boolean;

------------------------------------------------------------------------------

function QuaternionConjugate(Q: TQuaternion): TQuaternion;

quaternion functions

------------------------------------------------------------------------------


function QuaternionFromPoints(V1,V2: TAffineVector): TQuaternion;

------------------------------------------------------------------------------

function QuaternionMultiply(qL, qR: TQuaternion): TQuaternion;

------------------------------------------------------------------------------

function QuaternionSlerp(QStart,QEnd: TQuaternion; Spin: Integer; t: Single): TQuaternion;

------------------------------------------------------------------------------

function QuaternionToMatrix(Q: TQuaternion): TMatrix;

------------------------------------------------------------------------------

procedure QuaternionToPoints(Q: TQuaternion; var ArcFrom, ArcTo: TVector);

------------------------------------------------------------------------------

function VectorAdd(V1,V2: TVector): TVector;

------------------------------------------------------------------------------ vector functions

------------------------------------------------------------------------------


function VectorAffineAdd(V1,V2: TAffineVector): TAffineVector;

------------------------------------------------------------------------------

function VectorAffineCombine(V1,V2: TAffineVector; F1,F2: Single): TAffineVector;

------------------------------------------------------------------------------

function VectorAffineDblToFlt(V: TAffineDblVector): TAffineVector;

------------------------------------------------------------------------------

function VectorAffineDotProduct(V1,V2: TAffineVector): Single;

------------------------------------------------------------------------------

function VectorAffineFltToDbl(V: TAffineVector): TAffineDblVector;

------------------------------------------------------------------------------

function VectorAffineLerp(V1,V2: TAffineVector; t: Single): TAffineVector;

------------------------------------------------------------------------------

function VectorAffineSubtract(V1,V2: TAffineVector): TAffineVector;

------------------------------------------------------------------------------

function VectorAffineTransform(V: TAffineVector; M: TAffineMatrix): TAffineVector;

------------------------------------------------------------------------------

function VectorAngle(V1,V2: TAffineVector): Single;

------------------------------------------------------------------------------

function VectorCombine(V1,V2: TVector; F1,F2: Single): TVector;

------------------------------------------------------------------------------

function VectorCrossProduct(V1,V2: TAffineVector): TAffineVector;

------------------------------------------------------------------------------

function VectorDblToFlt(V: THomogeneousDblVector): THomogeneousVector;

------------------------------------------------------------------------------

function VectorDotProduct(V1,V2: TVector): Single;

------------------------------------------------------------------------------

function VectorFltToDbl(V: TVector): THomogeneousDblVector;

------------------------------------------------------------------------------

function VectorLength(V: array of Single): Single;

------------------------------------------------------------------------------

function VectorLerp(V1,V2: TVector; t: Single): TVector;

------------------------------------------------------------------------------

procedure VectorNegate(V: array of Single);

------------------------------------------------------------------------------

function VectorNorm(V: array of Single): Single;

------------------------------------------------------------------------------

function VectorNormalize(V: array of Single): Single;

------------------------------------------------------------------------------

function VectorPerpendicular(V,N: TAffineVector): TAffineVector;

------------------------------------------------------------------------------

function VectorReflect(V, N: TAffineVector): TAffineVector;

------------------------------------------------------------------------------

procedure VectorScale(V: array of Single; Factor: Single);

------------------------------------------------------------------------------

function VectorSubtract(V1,V2: TVector): TVector;

------------------------------------------------------------------------------

function VectorTransform(V: TVector; M: TMatrix): TVector;

------------------------------------------------------------------------------

Types


PAffineByteVector      = ^TAffineByteVector

PAffineDblVector       = ^TAffineDblVector

PAffineExtVector       = ^TAffineExtVector

PAffineFltVector       = ^TAffineFltVector

PAffineIntVector       = ^TAffineIntVector

PAffineMatrix          = ^TAffineMatrix

PAffinePtrVector       = ^TAffinePtrVector

PAffineVector          = ^TAffineVector

PAffineWordVector      = ^TAffineWordVector

PByte            = ^Byte
data types needed for 3D graphics calculation, included are 'C like' aliases for each type (to be conformal with OpenGL types
PByteVector = ^TByteVector
types to specify continous streams of a specific type switch off range checking to access values beyond the limits
PDblVector = ^TDblVector

PDouble          = ^Double

PExtended        = ^Extended

PFloat           = ^Single

PFloatVector = ^TFloatVector

PHomogeneousByteVector = ^THomogeneousByteVector
common vector and matrix types indices correspond like: x -> 0 y -> 1 z -> 2 w -> 3
PHomogeneousDblVector  = ^THomogeneousDblVector

PHomogeneousExtVector  = ^THomogeneousExtVector

PHomogeneousFltVector  = ^THomogeneousFltVector

PHomogeneousIntVector  = ^THomogeneousIntVector

PHomogeneousMatrix     = ^THomogeneousMatrix

PHomogeneousPtrVector  = ^THomogeneousPtrVector

PHomogeneousVector     = ^THomogeneousVector

PHomogeneousWordVector = ^THomogeneousWordVector

PInteger         = ^Integer

PIntVector = ^TIntVector

PMatrix                = ^TMatrix
some simplified names
PPointer         = ^Pointer

PVector                = ^TVector
some simplified names
PVectorArray           = ^TVectorArray

PWord            = ^Word

PWordVector = ^TWordVector

TAffineByteMatrix      = array[0..2] of TAffineByteVector;

TAffineByteVector      = array[0..2] of Byte;

TAffineDblMatrix       = array[0..2] of TAffineDblVector;

TAffineDblVector       = array[0..2] of Double;

TAffineExtMatrix       = array[0..2] of TAffineExtVector;

TAffineExtVector       = array[0..2] of Extended;

TAffineFltMatrix       = array[0..2] of TAffineFltVector;

TAffineFltVector       = array[0..2] of Single;

TAffineIntMatrix       = array[0..2] of TAffineIntVector;

TAffineIntVector       = array[0..2] of Integer;

TAffineMatrix          = TAffineFltMatrix

TAffinePtrVector       = array[0..2] of Pointer;

TAffineVector          = TAffineFltVector

TAffineWordMatrix      = array[0..2] of TAffineWordVector;

TAffineWordVector      = array[0..2] of Word;

TByteVector = array[Word] of Byte;

TDblVector = array[Word] of Double;

TFloatVector = array[Word] of Single;

THomogeneousByteMatrix = array[0..3] of THomogeneousByteVector;
matrices
THomogeneousByteVector = array[0..3] of Byte;

THomogeneousDblMatrix  = array[0..3] of THomogeneousDblVector;

THomogeneousDblVector  = array[0..3] of Double;

THomogeneousExtMatrix  = array[0..3] of THomogeneousExtVector;

THomogeneousExtVector  = array[0..3] of Extended;

THomogeneousFltMatrix  = array[0..3] of THomogeneousFltVector;

THomogeneousFltVector  = array[0..3] of Single;

THomogeneousIntMatrix  = array[0..3] of THomogeneousIntVector;

THomogeneousIntVector  = array[0..3] of Integer;

THomogeneousMatrix     = THomogeneousFltMatrix

THomogeneousPtrVector  = array[0..3] of Pointer;

THomogeneousVector     = THomogeneousFltVector

THomogeneousWordMatrix = array[0..3] of THomogeneousWordVector;

THomogeneousWordVector = array[0..3] of Word;

TIntVector = array[Word] of Integer;

TMatrix                = THomogeneousFltMatrix

TMatrix3b              = TAffineByteMatrix

TMatrix3d              = TAffineDblMatrix

TMatrix3e              = TAffineExtMatrix

TMatrix3f              = TAffineFltMatrix

TMatrix3i              = TAffineIntMatrix

TMatrix3w              = TAffineWordMatrix

TMatrix4b              = THomogeneousByteMatrix

TMatrix4d              = THomogeneousDblMatrix

TMatrix4e              = THomogeneousExtMatrix

TMatrix4f              = THomogeneousFltMatrix

TMatrix4i              = THomogeneousIntMatrix

TMatrix4w              = THomogeneousWordMatrix

TQuaternion = record
end;
q=([x,y,z],w
TRectangle = record
Left : Integer;
Top : Integer;
Width : Integer;
Height : Integer;
end;

TTransformations  = array[TTransType] of Extended;
used to describe a sequence of transformations in following order: [Sx][Sy][Sz][ShearXY][ShearXZ][ShearZY][Rx][Ry][Rz][Tx][Ty][Tz][P(x,y,z,w)] constants are declared for easier access (see MatrixDecompose below
TTransType = (ttScaleX,ttScaleY,ttScaleZ,
                   ttShearXY,ttShearXZ,ttShearYZ,
                   ttRotateX,ttRotateY,ttRotateZ,
                   ttTranslateX,ttTranslateY,ttTranslateZ,
                   ttPerspectiveX,ttPerspectiveY,ttPerspectiveZ,ttPerspectiveW);

TVector                = THomogeneousFltVector

TVector3b              = TAffineByteVector

TVector3d              = TAffineDblVector

TVector3e              = TAffineExtVector

TVector3f              = TAffineFltVector

TVector3i              = TAffineIntVector

TVector3p              = TAffinePtrVector

TVector3w              = TAffineWordVector

TVector4b              = THomogeneousByteVector

TVector4d              = THomogeneousDblVector

TVector4e              = THomogeneousExtVector

TVector4f              = THomogeneousFltVector

TVector4i              = THomogeneousIntVector

TVector4p              = THomogeneousPtrVector

TVector4w              = THomogeneousWordVector

TVectorArray           = array[Word] of TAffineVector;

TWordVector = array[Word] of Word;

Constants

EmptyMatrix = ((0,0,0,0), (0,0,0,0), (0,0,0,0), (0,0,0,0))

EPSILON = 1E-100

some very small numbers

EPSILON2 = 1E-50

IdentityMatrix = ((1,0,0,0), (0,1,0,0), (0,0,1,0), (0,0,0,1))

NullVector = (0,0,0)

XVector = (1,0,0)

useful constants standard vectors

YVector = (0,1,0)

ZVector = (0,0,1)


Variables