Gorilla.Utils.Math
Unit Gorilla.Utils.Math.pasRecords
- record TSize3D
- record TMatrixUtils
- record TTransformationMatrixUtils
- record TRotationMatrixUtils
- record TEulerUtils
Enumerations
- enum TRotationOrder = ( EULER_XYZ, EULER_YXZ, EULER_ZXY, EULER_ZYX, EULER_YZX, EULER_XZY, SPHERIC_XYZ ) ;
Constants
- const GORILLA_SINGLE_EPSILON : Double = 1e-07;
- const GORILLA_DOUBLE_EPSILON : Double = 1e-12;
- const GORILLA_FLOAT_EPSILON : Double = 1e-07;
- const GORILLA_SINGLE_MIN : Double = 1.18e-38;
- const GORILLA_SINGLE_MAX : Double = 3.4e+38;
- const GORILLA_SINGLE_INF : Double = 3.49e+38;
- const cPI : Single = ;
- const cPIdiv180 : Single = ;
- const c180divPI : Single = ;
- const c2PI : Single = ;
- const cPIdiv2 : Single = ;
- const cPIdiv4 : Single = ;
- const c3PIdiv2 : Single = ;
- const c3PIdiv4 : Single = ;
- const cInv2PI : Single = ;
- const cInv360 : Single = ;
- const c180 : Single = ;
- const c360 : Single = ;
- const cOneHalf : Single = ;
- const cLn10 : Single = ;
- const XVector : TPoint3D = ;
- const YVector : TPoint3D = ;
- const ZVector : TPoint3D = ;
- const REFERENCE_UP : TPoint3D = ;
- const REFERENCE_RIGHT : TPoint3D = ;
- const REFERENCE_FORWARD : TPoint3D = ;
Mics. types
- type TMatrix3DArray = array [0..15] of Single;
Functions / Procedures
- public function Size3D ( AX : Integer; AY : Integer; AZ : Integer ) : TSize3D ; overload;
- public function Size3D ( AX : Single; AY : Single; AZ : Single ) : TSize3D ; overload;
- public function SingleEquals ( const AVal1 : Single; const AVal2 : Single ) : Boolean ;
- public function DoubleEquals ( const AVal1 : Double; const AVal2 : Double ) : Boolean ;
- public function __QuaternionToEuler ( Q : TVector3D ) : TPoint3D ; overload;
- public function __QuaternionToEuler ( Q : TQuaternion3D ) : TPoint3D ; overload;
- public function __QuaternionToRotationMatrix ( const AQuat : TVector3D ) : TMatrix3D ; overload;
- public function __QuaternionToRotationMatrix ( const X : Single; const Y : Single; const Z : Single; const W : Single ) : TMatrix3D ; overload;
- public function __QuaternionToRotationMatrix ( const AQuat : TQuaternion3D ) : TMatrix3D ; overload;
- public function __RotationMatrixToEulerAngles ( const AMatrix : TMatrix3D ) : TPoint3D ; overload;
- public function __RotationMatrixToEulerAngles ( const AMatrix : TMatrix ) : TPoint3D ; overload;
- public function __RotationMatrixToVector3D ( const AMatrix : TMatrix3D ) : TVector3D ;
- public function __GetQuaternionFromTransformationMatrix ( const AMatrix : TMatrix3D ) : TQuaternion3D ;
- public function __RotationMatrixToQuaternion3D ( const AMatrix : TMatrix3D ) : TQuaternion3D ;
- public function __GetTranslationFromMatrix ( const AMatrix : TMatrix3D ) : TPoint3D ;
- public function __GetQuaternionFromRotationMatrix ( const AMatrix : TMatrix3D ) : TQuaternion3D ; overload;
- public function __GetQuaternionFromRotationMatrix ( const AMatrix : TMatrix ) : TQuaternion3D ; overload;
- public function __GetVector3DFromRotationMatrix ( const AMatrix : TMatrix3D ) : TVector3D ; overload;
- public function __GetVector3DFromRotationMatrix ( const AMatrix : TMatrix ) : TVector3D ; overload;
- public function __GetRotationMatrix3DFromMatrix ( const AMatrix : TMatrix3D ) : TMatrix3D ;
- public function __GetRotationMatrixFromMatrix ( const AMatrix : TMatrix3D ) : TMatrix ;
- public function __GetScalingFromMatrix ( const AMatrix : TMatrix3D ) : TPoint3D ;
- public function __Matrix3DToMatrix ( const AMatrix : TMatrix3D ) : TMatrix ;
- public function __MatrixToMatrix3D ( const AMatrix : TMatrix ) : TMatrix3D ;
- public procedure __Vector3DToEulerianAngles ( const q : TVector3D; out roll : Single; out pitch : Single; out yaw : Single ) ;
- public function __EulerianAnglesToVector3D ( const roll : Single; const pitch : Single; const yaw : Single ) : TVector3D ;
- public function __EulerianAnglesToQuaternion3D ( const AAngles : TPoint3D; ADegToRad : Boolean; AOrder : TRotationOrder ) : TQuaternion3D ; overload;
- public function __EulerianAnglesToQuaternion3D ( const AAngles : TVector3D; ADegToRad : Boolean; AOrder : TRotationOrder ) : TQuaternion3D ; overload;
- public function __EulerianAnglesToMatrix3D ( const AAngles : TPoint3D; ADegToRad : Boolean; AOrder : TRotationOrder ) : TMatrix3D ; overload;
- public function __EulerianAnglesToMatrix3D ( const AAngles : TVector3D; ADegToRad : Boolean; AOrder : TRotationOrder ) : TMatrix3D ; overload;
- public function __Matrix3DToEulerianAngles ( AMat : TMatrix3D ) : TPoint3D ;
- public function RotationBetweenVectors ( const APoint : TPoint3D; const ADir : TPoint3D ) : TQuaternion3D ;
- public function RotatePointAroundAxisRad ( Angle : Single; const Point : TPoint3D; const Axis : TPoint3D ) : TPoint3D ;
- public function Matrix3DToDoubleArray ( const AMatrix : TMatrix3D ) : TDoubleDynArray ;
- public function Matrix3DToSingleArray ( const AMatrix : TMatrix3D ) : TSingleDynArray ;
- public function Lerp ( const A : Single; const V1 : Single; const V2 : Single ) : Single ; overload;
- public function Lerp ( const A : Single; const V1 : TPointF; const V2 : TPointF ) : TPointF ; overload;
- public function Lerp ( const A : Single; const V1 : TPoint3D; const V2 : TPoint3D ) : TPoint3D ; overload;
- public function Lerp ( const A : Single; const V1 : TVector3D; const V2 : TVector3D ) : TVector3D ; overload;
- public function Lerp ( const A : Single; const V1 : TAlphaColorF; const V2 : TAlphaColorF ) : TAlphaColorF ; overload;
- public function SCurve ( const A : Single ) : Single ;
- public function RandomFloatRange ( const A : Single; const B : Single ) : Single ;
- public function Zero ( const f1 : Single ) : Boolean ; overload;
- public function Zero ( const f1 : Double ) : Boolean ; overload;
- public function Zero ( const f1 : Single; const EqEpsilon : Single ) : Boolean ; overload;
- public function Zero ( const f1 : Double; const EqEpsilon : Double ) : Boolean ; overload;
- public function IsZero ( const A : Extended; const EqEpsilon : Single = 1e-07 ) : Boolean ; overload;
- public function IsZero ( const A : Double; const EqEpsilon : Single = 1e-07 ) : Boolean ; overload;
- public function IsZero ( const A : Single; const EqEpsilon : Single = 1e-07 ) : Boolean ; overload;
- public function IsZero ( const v1 : TPointF; const EqEpsilon : Single = 1e-07 ) : Boolean ; overload;
- public function IsZero ( const v1 : TPoint3D; const EqEpsilon : Single = 1e-07 ) : Boolean ; overload;
- public function IsZero ( const v1 : TVector3D; const EqEpsilon : Single = 1e-07 ) : Boolean ; overload;
- public function IsZero ( const c : TAlphaColorF; const ACheckAlpha : Boolean = True ) : Boolean ; overload;
- public function GetSign ( const AValue : Integer ) : ShortInt ; overload;
- public function GetSign ( const AValue : Int64 ) : ShortInt ; overload;
- public function GetSign ( const AValue : Single ) : ShortInt ; overload;
- public function GetSign ( const AValue : Double ) : ShortInt ; overload;
- public function GetSign ( const AValue : Extended ) : ShortInt ; overload;
- public function Clamped ( const a : Int64; const vBegin : Int64; const vEnd : Int64 ) : Int64 ; overload;
- public function Clamped ( const a : UInt64; const vBegin : UInt64; const vEnd : UInt64 ) : UInt64 ; overload;
- public function Clamped ( const a : Integer; const vBegin : Integer; const vEnd : Integer ) : Integer ; overload;
- public function Clamped ( const a : Cardinal; const vBegin : Cardinal; const vEnd : Cardinal ) : Cardinal ; overload;
- public function Clamped ( const a : Single; const vBegin : Single; const vEnd : Single ) : Single ; overload;
- public function Clamped ( const a : Double; const vBegin : Double; const vEnd : Double ) : Double ; overload;
- public function Clamp ( const AValue : Integer; const AMinVal : Integer; const AMaxVal : Integer ) : Integer ; overload;
- public function Clamp ( const AValue : Single; const AMinVal : Single; const AMaxVal : Single ) : Single ; overload;
- public function Clamp ( const AValue : TPointF; const AMinVal : TPointF; const AMaxVal : TPointF ) : TPointF ; overload;
- public function Clamp ( const AValue : TPoint3D; const AMinVal : TPoint3D; const AMaxVal : TPoint3D ) : TPoint3D ; overload;
- public function Clamp ( const AValue : TVector3D; const AMinVal : TVector3D; const AMaxVal : TVector3D ) : TVector3D ; overload;
- public function SmoothStep ( const AEdge0 : Single; const AEdge1 : Single; const AX : Single ) : Single ; overload;
- public function SmoothStep ( const AEdge0 : TPointF; const AEdge1 : TPointF; const AX : TPointF ) : TPointF ; overload;
- public function SmoothStep ( const AEdge0 : TPoint3D; const AEdge1 : TPoint3D; const AX : TPoint3D ) : TPoint3D ; overload;
- public function SmoothStep ( const AEdge0 : TVector3D; const AEdge1 : TVector3D; const AX : TVector3D ) : TVector3D ; overload;
- public function SmoothStep ( const AEdge0 : TQuaternion3D; const AEdge1 : TQuaternion3D; const AX : TQuaternion3D ) : TQuaternion3D ; overload;
- public function SingleCut ( const v : TPoint3D ) : TPointF ; overload;
- public function SingleCut ( const v : TVector3D ) : TPoint3D ; overload;
- public function OuterProduct ( const U : TPoint3D; const V : TPoint3D ) : TMatrix ; overload;
- public function OuterProduct ( const U : TVector3D; const V : TVector3D ) : TMatrix3D ; overload;
- public function MatrixAdd ( const M1 : TMatrix3D; const M2 : TMatrix3D ) : TMatrix3D ; overload;
- public function MatrixAdd ( const M1 : TMatrix; const M2 : TMatrix ) : TMatrix ; overload;
- public function MatrixSubtract ( const M1 : TMatrix3D; const M2 : TMatrix3D ) : TMatrix3D ; overload;
- public function MatrixSubtract ( const M1 : TMatrix; const M2 : TMatrix ) : TMatrix ; overload;
- public function MatrixMultiply ( const AMatrix : TMatrix3D; const AFactor : Single ) : TMatrix3D ; overload;
- public function MatrixMultiply ( const AMatrix : TMatrix; const AFactor : Single ) : TMatrix ; overload;
- public function MatrixTranspose ( const AMatrix : TMatrix3D ) : TMatrix3D ; overload;
- public function MatrixTranspose ( const AMatrix : TMatrix ) : TMatrix ; overload;
- public function MatrixRow ( const AMatrix : TMatrix; const ARow : Byte ) : TPoint3D ;
- public function MatrixRowVector ( const AMatrix : TMatrix; const ARow : Byte ) : TVector ;
- public function MatrixCol ( const AMatrix : TMatrix; const ACol : Byte ) : TPoint3D ;
- public function CreateMatrixDiagonal ( const AVector : TPoint3D ) : TMatrix ; overload;
- public function CreateMatrixDiagonal ( const AVector : TVector3D ) : TMatrix3D ; overload;
- public function CreateMatrixFromRows ( const AVec1 : TPoint3D; const AVec2 : TPoint3D; const AVec3 : TPoint3D ) : TMatrix ;
- public function Point3DSquare ( const APoint : TPoint3D ) : Single ;
- public function Point3DSquareLength ( const APoint : TPoint3D ) : Single ;
- public function Vector3DSquareLength ( const AV3D : TVector3D ) : Single ;
- public function Point3DMinIndex ( const APoint : TPoint3D ) : Integer ;
- public function Point3DInverse ( const APoint : TPoint3D ) : TPoint3D ;
- public function Point3DNormalizeAndReturnNormal ( var APoint : TPoint3D ) : Single ;
- public function MatrixIsIdentity ( const AMatrix : TMatrix3D ) : Boolean ;
- public function MatrixIsNull ( const AMatrix : TMatrix3D ) : Boolean ;
- public function EqualMatrices ( const M1 : TMatrix3D; const M2 : TMatrix3D ) : Boolean ;
- public procedure CameraVectorsFromViewMatrix ( AMatrix : TMatrix3D; out APosition : TPoint3D; out ADirection : TPoint3D; out AUp : TPoint3D; out ARight : TPoint3D ) ;
- public function GetViewDirectionFromViewMatrix ( AMatrix : TMatrix3D ) : TPoint3D ;
- public function Magnitude
(
const
AVector :
TPoint3D
)
: Double
;
overload;
Returns the length of this vector (Read Only). The length of the vector is square root of (x*x+y*y). If you only need to compare magnitudes of some vectors, you can compare squared magnitudes of them using sqrMagnitude (computing squared magnitudes is faster).
- public function Magnitude ( const AVector : TVector3D ) : Double ; overload;
- public function SquareMagnitude
(
const
AVector :
TPoint3D
)
: Double
;
overload;
Returns the squared length of this vector (Read Only). The magnitude of a vector v is calculated as Mathf.Sqrt(Vector3.Dot(v, v)). However, the Sqrt calculation is quite complicated and takes longer to execute than the normal arithmetic operations. Calculating the squared magnitude instead of using the magnitude property is much faster - the calculation is basically the same only without the slow Sqrt call. If you are using magnitudes simply to compare distances, then you can just as well compare squared magnitudes against the squares of distances since the comparison will give the same result.
- public function SquareMagnitude ( const AVector : TVector3D ) : Double ; overload;
- public function BoundingBoxRayCastIntersect
(
const
ABox :
TBoundingBox; const
ARayPos :
TVector3D; const
ARayDir :
TVector3D
)
: Single
;
Checks a ray and a boundingbox for intersection.
- public function NormalizeAngle
(
const
AValue :
Single; const
AStart :
Single; const
AEnd :
Single
)
: Single
;
Normalizes any number to an arbitrary range by assuming the range wraps around when going below min or above max
- public function NormalizeDegAngle ( Angle : Single ) : Single ;
- public function AlignUp
(
AValue :
Integer; ABase :
Integer
)
: Integer
;
This function can be used to align integer values to a multiple of ABase. For example if you want to align to multiples of 2 for texture sizes, use AlignedWidth := AlignUp(CurrentWidth, 2);
- public procedure Swap ( var A : Single; var B : Single ) ; overload;
- public procedure Swap ( var A : Double; var B : Double ) ; overload;
- public procedure Swap ( var A : Integer; var B : Integer ) ; overload;
- public procedure Swap ( var A : Int64; var B : Int64 ) ; overload;
- public procedure Swap ( var A : Boolean; var B : Boolean ) ; overload;
- public procedure Swap ( var A : TPointF; var B : TPointF ) ; overload;
- public procedure Swap ( var A : TPoint3D; var B : TPoint3D ) ; overload;
- public procedure Swap ( var A : TVector3D; var B : TVector3D ) ; overload;
- public procedure Swap ( var A : TQuaternion3D; var B : TQuaternion3D ) ; overload;
- public procedure Swap ( var A : TMatrix; var B : TMatrix ) ; overload;
- public procedure Swap ( var A : TMatrix3D; var B : TMatrix3D ) ; overload;
- public procedure Reverse ( var A : Single; var B : Single; var C : Single ) ; overload;
- public procedure Reverse ( var A : Double; var B : Double; var C : Double ) ; overload;
- public procedure Reverse ( var A : Integer; var B : Integer; var C : Integer ) ; overload;
- public procedure Reverse ( var A : Int64; var B : Int64; var C : Int64 ) ; overload;
- public procedure Reverse ( var A : Boolean; var B : Boolean; var C : Boolean ) ; overload;
- public procedure Reverse ( var A : TPointF; var B : TPointF; var C : TPointF ) ; overload;
- public procedure Reverse ( var A : TPoint3D; var B : TPoint3D; var C : TPoint3D ) ; overload;
- public procedure Reverse ( var A : TVector3D; var B : TVector3D; var C : TVector3D ) ; overload;
- public procedure Reverse ( var A : TQuaternion3D; var B : TQuaternion3D; var C : TQuaternion3D ) ; overload;
- public procedure Reverse ( var A : TMatrix; var B : TMatrix; var C : TMatrix ) ; overload;
- public procedure Reverse ( var A : TMatrix3D; var B : TMatrix3D; var C : TMatrix3D ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
- public procedure ReverseArray ( var A : ; AOfs : Integer; ACount : Integer = $FFFFFFFF ) ; overload;
TSize3D
TTransformationMatrixUtils
Methods
- public function GetTranslationFromTransformationMatrix ( const ATransf : TMatrix3D ) : TPoint3D ; static;
- public function GetScalingFromTransformationMatrix ( const ATransf : TMatrix3D ) : TPoint3D ; static;
- public function GetRotationMatrixFromTransformationMatrix ( const ATransf : TMatrix3D ) : TMatrix ; static;
- public function GetQuaternion3DFromTransformationMatrix ( const ATransf : TMatrix3D ) : TQuaternion3D ; static;
- public function GetVector3DFromTransformationMatrix ( const ATransf : TMatrix3D ) : TVector3D ; static;
- public function GetEulerianAnglesFromTransformationMatrix ( const ATransf : TMatrix3D; AOrder : TRotationOrder ) : TPoint3D ; static;
- public function GetModelViewProjectionMatrix ( const AModel : TMatrix3D; const AView : TMatrix3D; const AProj : TMatrix3D ) : TMatrix3D ; static;
TRotationMatrixUtils
Methods
- public function RotationMatrixToQuaternion3D ( ARotMat : TMatrix ) : TQuaternion3D ; static;
- public function Quaternion3DToRotationMatrix ( AQuat : TQuaternion3D ) : TMatrix ; static;
- public function RotationMatrixToVector3D ( ARotMat : TMatrix ) : TVector3D ; static;
- public function Vector3DToRotationMatrix ( AV3D : TVector3D ) : TMatrix ; static;
- public function RotationMatrixToEulerianAngles ( ARotMat : TMatrix; AOrder : TRotationOrder ) : TPoint3D ; static;
- public function EulerianAnglesToRotationMatrix ( AAngles : TPoint3D; AOrder : TRotationOrder ) : TMatrix ; static;
- public function Quaternion3DToEulerianAngles ( AQuat : TQuaternion3D; AOrder : TRotationOrder ) : TPoint3D ; static;
- public function EulerianAnglesToQuaternion3D ( AAngles : TPoint3D; AOrder : TRotationOrder ) : TQuaternion3D ; static;
- public function TransformationMatrixToRotationMatrix ( ATransf : TMatrix3D ) : TMatrix ; static;
- public function RotationMatrixToTransformationMatrix ( ARotMat : TMatrix ) : TMatrix3D ; static;
TEulerUtils
Methods
- public function EulerianAnglesToQuaternion3D ( AAngles : TPoint3D; AOrder : TRotationOrder ) : TQuaternion3D ; static;
- public function Quaternion3DToEulerianAngles ( AQuat : TQuaternion3D; AOrder : TRotationOrder ) : TPoint3D ; static;
- public function EulerianAnglesToVector3D ( AAngles : TPoint3D; AOrder : TRotationOrder ) : TVector3D ; static;
- public function Vector3DToEulerianAngles ( AV3D : TVector3D; AOrder : TRotationOrder ) : TPoint3D ; static;
- public function EulerianAnglesToRotationMatrix ( AAngles : TPoint3D; AOrder : TRotationOrder ) : TMatrix ; static;
- public function RotationMatrixToEulerianAngles ( ARotMat : TMatrix; AOrder : TRotationOrder ) : TPoint3D ; static;