Unit CastleVectors

Description

Vector and matrix types and operations. Includes operations on basic geometric objects (2D and 3D), like collision-checking routines.

Representation of geometric objects in this unit :

  • Plane in 3D space is a vector TVector4*. Such vector [A, B, C, D] defines a surface that consists of all points satisfying equation A * x + B * y + C * z + D = 0. At least one of A, B, C must be different than zero.

    Vector [A, B, C] is called PlaneDir in many places. Or PlaneNormal when it's guaranteed (or required to be) normalized, i.e. scaled to have length 1.

  • Line in 3D space is represented by two 3D vectors: Line0 and LineVector. They determine a line consisting of all points that can be calculated as Line0 + R * LineVector where R is any real value.

    LineVector must not be a zero vector.

  • Line in 2D space is sometimes represented as 2D vectors Line0 and LineVector (analogously like line in 3D).

    And sometimes it's represented as a 3-items vector, like TVector3Single (for [A, B, C] line consists of all points satisfying A * x + B * y + C = 0). At least one of A, B must be different than zero.

  • A tunnel is an object that you get by moving a sphere along the line segment. In other words, this is like a cylinder, but ended with a hemispheres. The tunnel is represented in this unit as two points Tunnel1, Tunnel2 (this defines a line segment) and a TunnelRadius.

  • A ray is defined just like a line: two vectors RayOrigin and RayDirection, RayDirection must be nonzero. Ray consists of all points RayOrigin + R * RayDirection for R being any real value >= 0.

  • A simple plane in 3D is a plane parallel to one of the three basic planes. This is a plane defined by the equation X = Const or Y = Count or Z = Const. Such plane is represented as PlaneConstCoord integer value equal to 0, 1 or 2 and PlaneConstValue.

    Note that you can always represent the same plane using a more general plane 3D equation, just take

    Plane[0..2 / PlaneConstCoord] = 0,
    Plane[PlaneConstCoord] = -1,
    Plane[3] = PlaneConstValue.

    On such "simple plane" we can perform many calculations much faster.

  • A line segment (often referred to as just segment) is represented by two points Pos1 and Pos2. For some routines the order of points Pos1 and Pos2 is significant (but this is always explicitly stated in the interface, so don't worry).

    Sometimes line segment is also represented as Segment0 and SegmentVector, this consists of all points Segment0 + SegmentVector * t for t in [0..1]. SegmentVector must not be a zero vector.

    Conversion between the two representations above is trivial, just take Pos1 = Segment0 and Pos2 = Segment0 + SegmentVector.

In descriptions of geometric objects above, I often stated some requirements, e.g. the triangle must not be "degenerated" to a line segment, RayDirection must not be a zero vector, etc. You should note that these requirements are generally not checked by routines in this unit (for the sake of speed) and passing wrong values to many of the routines may lead to serious bugs — maybe the function will raise some arithmetic exception, maybe it will return some nonsensible result. In other words: when calling these functions, always make sure that values you pass satisfy the requirements.

(However, wrong input values should never lead to some serious bugs like access violations or range check errors — in cases when it would be possible, we safeguard against this. That's because sometimes you simply cannot guarantee for 100% that input values are correct, because of floating-point precision problems – see below.)

As for floating-point precision:

  • Well, floating-point inaccuracy is, as always, a problem. This unit always uses FloatsEqual and variables SingleEqualityEpsilon, DoubleEqualityEpsilon and ExtendedEpsilonEquality when comparison of floating-point values is needed. In some cases you may be able to adjust these variables to somewhat fine-tune the comparisons.

  • For collision-detecting routines, the general strategy in case of uncertainty (when we're not sure whether there is a collision or the objects are just very very close to each other) is to say that there is a collision.

    This means that we may detect a collision when in fact the precise mathematical calculation says that there is no collision.

    This approach should be suitable for most use cases.

A design question about this unit: Right now I must declare two variables to define a sphere (like SphereCenter: vector; SphereRadius: scalar;) Why not wrap all the geometric objects (spheres, lines, rays, tunnels etc.) inside some records ? For example, define a sphere as

TSphere = record Center: vector; Radius: scalar; end;

The answer: this is not so good idea, because it would create a lot of such types into unit, and I would have to implement simple functions that construct and convert between these types. Consider e.g. when I have a tunnel (given as Tunnel1, Tunnel2 points and TunnelRadius vector) and I want to "extract" the properties of the sphere at the 1st end of this tunnel. Right now, it's simple: just consider Tunnel1 as a sphere center, and TunnelRadius is obviously a sphere radius. Computer doesn't have to actually do anything, you just have to think in a different way about Tunnel1 and TunnelRadius. But if I would have tunnel wrapped in a type like TTunnel and a sphere wrapped in a type like TSphere, then I would have to actually implement this trivial conversion. And then doing such trivial conversion at run-time would take some time, because you have to copy 6 floating-point values. This would be a very serious waste of time at run-time. Well, on the other hand, routines could take less parameters (e.g. only 1 parameter TTunnel, instead of three vector parameters), but (overall) we would still loose a lot of time.

In many places where I have to return collision with a line segment, a line or a ray there are alternative versions that return just a scalar "T" instead of a calculated point. The actual collision point can be calculated then like RayOrigin + T * RayDirection. Of course for rays you can be sure that T is >= 0, for line segments you can be sure that 0 <= T <= 1. The "T" is often useful, because it allows you to easily calculate collision point, and also the distance to the collision (you can e.g. compare T1 and T2 to compare which collision is closer, and when your RayDirection is normalized then the T gives you the exact distance). Thanks to this you can often entirely avoid calculating the actual collision point (RayOrigin + T * RayDirection).

Contains some stuff useful for integration with FPC's Matrix unit. For now, there are some "glueing" functions here like Vector_Get_Normalized that allow you to comfortably perform operations on Matrix unit object types. Most important is also the overload of ":=" operator that allows you to switch between CastleVectors arrays and Matrix objects without any syntax obfuscation. Although note that this overload is a little dangerous, since now code like

V3 := VectorProduct(V1, V2);

compiles and works both when all three V1, V2 and V3 are TVector3Single arrays or TVector3_Single objects. However, for the case when they are all TVector3_Single objects, this is highly un-optimal, and

V3 := V1 >< V2;

is much faster, since it avoids the implicit conversions (unnecessary memory copying around).

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TVector3SingleList  
Class TVector2SingleList  
Class TVector4SingleList  
Class TVector2DoubleList  
Class TVector3DoubleList  
Class TVector4DoubleList  
Class TMatrix3SingleList  
Class TMatrix3DoubleList  
Class TMatrix4SingleList  
Class TMatrix4DoubleList  
Class TVector2IntegerList  
Class EVectorInvalidOp  
Class EPlanesParallel  
Class ELinesParallel  
Class ETransformedResultInvalid  

Functions and Procedures

function FloatsEqual(const f1, f2: Single): boolean; overload;
function FloatsEqual(const f1, f2: Double): boolean; overload;
function FloatsEqual(const f1, f2, EqEpsilon: Single): boolean; overload;
function FloatsEqual(const f1, f2, EqEpsilon: Double): boolean; overload;
function Zero(const f1: Single): boolean; overload;
function Zero(const f1: Double): boolean; overload;
function Zero(const f1, EqEpsilon: Single ): boolean; overload;
function Zero(const f1, EqEpsilon: Double ): boolean; overload;
function Vector2Cardinal(const x, y: Cardinal): TVector2Cardinal;
function Vector2Integer(const x, y: Integer): TVector2Integer;
function Vector2LongInt(const x, y: Longint): TVector2LongInt;
function Vector2SmallInt(const x, y: SmallInt): TVector2SmallInt;
function Vector2Single(const x, y: Single): TVector2Single; overload;
function Vector2Single(const V: TVector2Double): TVector2Single; overload;
function Vector2Double(const x, y: Double): TVector2Double;
function Vector3Single(const x, y: Single; const z: Single = 0.0): TVector3Single; overload;
function Vector3Single(const v3: TVector3Double): TVector3Single; overload;
function Vector3Single(const v3: TVector3Byte): TVector3Single; overload;
function Vector3Single(const v2: TVector2Single; const z: Single = 0.0): TVector3Single; overload;
function Vector3Longint(const p0, p1, p2: Longint): TVector3Longint;
function Vector3Double(const x, y: Double; const z: Double = 0.0): TVector3Double; overload;
function Vector3Double(const v: TVector3Single): TVector3Double; overload;
function Vector3Double(const v2: TVector2Double; const z: Double = 0.0): TVector3Double; overload;
function Vector4Single(const x, y: Single; const z: Single = 0; const w: Single = 1): TVector4Single; overload;
function Vector4Single(const v3: TVector3Single; const w: Single = 1): TVector4Single; overload;
function Vector4Single(const v2: TVector2Single; const z: Single = 0; const w: Single = 1): TVector4Single; overload;
function Vector4Single(const ub: TVector4Byte): TVector4Single; overload;
function Vector4Single(const V3: TVector3Byte; const W: Byte): TVector4Single; overload;
function Vector4Single(const v: TVector4Double): TVector4Single; overload;
function Vector4Double(const x, y, z ,w: Double): TVector4Double; overload;
function Vector4Double(const v: TVector4Single): TVector4Double; overload;
function Vector2Byte(x, y: Byte): TVector2Byte; overload;
function Vector3Byte(x, y, z: Byte): TVector3Byte; overload;
function Vector3Byte(const v: TVector3Single): TVector3Byte; overload;
function Vector3Byte(const v: TVector3Double): TVector3Byte; overload;
function Vector4Byte(const f4: TVector4Single): TVector4Byte; overload;
function Vector4Byte(const x, y, z: Byte; const w: Byte = 255): TVector4Byte; overload;
function Vector4Byte(const f3: TVector3Byte; w: Byte): TVector4Byte; overload;
function Vector4Integer(const X, Y, Z, W: Integer): TVector4Integer;
function Vector3SinglePoint(const v: TVector4Single): TVector3Single;
function Vector2SingleCut(const v: TVector3Single): TVector2Single;
function Vector3SingleCut(const v: TVector4Single): TVector3Single;
function Vector3ByteCut(const v: TVector4Byte): TVector3Byte;
function Normal3Single(const x, y: Single; const z: Single = 0.0): TVector3Single; overload;
function Vector2SingleFromStr(const S: string): TVector2Single;
function Vector3SingleFromStr(const S: string): TVector3Single;
function Vector3DoubleFromStr(const S: string): TVector3Double;
function Vector3ExtendedFromStr(const S: string): TVector3Extended;
function Vector4SingleFromStr(const S: string): TVector4Single;
function Matrix2Double(const M: TMatrix2Single): TMatrix2Double;
function Matrix2Single(const M: TMatrix2Double): TMatrix2Single;
function Matrix3Double(const M: TMatrix3Single): TMatrix3Double;
function Matrix3Single(const M: TMatrix3Double): TMatrix3Single;
function Matrix4Double(const M: TMatrix4Single): TMatrix4Double;
function Matrix4Single(const M: TMatrix4Double): TMatrix4Single;
operator := (const V: TVector2_Single): TVector2Single;
operator := (const V: TVector3_Single): TVector3Single;
operator := (const V: TVector4_Single): TVector4Single;
operator := (const V: TVector2Single): TVector2_Single;
operator := (const V: TVector3Single): TVector3_Single;
operator := (const V: TVector4Single): TVector4_Single;
function SwapEndian(const V: TVector2Single): TVector2Single; overload;
function SwapEndian(const V: TVector2Double): TVector2Double; overload;
function SwapEndian(const V: TVector3Single): TVector3Single; overload;
function SwapEndian(const V: TVector3Double): TVector3Double; overload;
function SwapEndian(const V: TVector4Single): TVector4Single; overload;
function SwapEndian(const V: TVector4Double): TVector4Double; overload;
function LEtoN(const V: TVector2Single): TVector2Single; overload;
function LEtoN(const V: TVector2Double): TVector2Double; overload;
function LEtoN(const V: TVector3Single): TVector3Single; overload;
function LEtoN(const V: TVector3Double): TVector3Double; overload;
function LEtoN(const V: TVector4Single): TVector4Single; overload;
function LEtoN(const V: TVector4Double): TVector4Double; overload;
function BEtoN(const V: TVector2Single): TVector2Single; overload;
function BEtoN(const V: TVector2Double): TVector2Double; overload;
function BEtoN(const V: TVector3Single): TVector3Single; overload;
function BEtoN(const V: TVector3Double): TVector3Double; overload;
function BEtoN(const V: TVector4Single): TVector4Single; overload;
function BEtoN(const V: TVector4Double): TVector4Double; overload;
function NtoLE(const V: TVector2Single): TVector2Single; overload;
function NtoLE(const V: TVector2Double): TVector2Double; overload;
function NtoLE(const V: TVector3Single): TVector3Single; overload;
function NtoLE(const V: TVector3Double): TVector3Double; overload;
function NtoLE(const V: TVector4Single): TVector4Single; overload;
function NtoLE(const V: TVector4Double): TVector4Double; overload;
function NtoBE(const V: TVector2Single): TVector2Single; overload;
function NtoBE(const V: TVector2Double): TVector2Double; overload;
function NtoBE(const V: TVector3Single): TVector3Single; overload;
function NtoBE(const V: TVector3Double): TVector3Double; overload;
function NtoBE(const V: TVector4Single): TVector4Single; overload;
function NtoBE(const V: TVector4Double): TVector4Double; overload;
procedure SwapValues(var V1, V2: TVector2Single); overload;
procedure SwapValues(var V1, V2: TVector2Double); overload;
procedure SwapValues(var V1, V2: TVector3Single); overload;
procedure SwapValues(var V1, V2: TVector3Double); overload;
procedure SwapValues(var V1, V2: TVector4Single); overload;
procedure SwapValues(var V1, V2: TVector4Double); overload;
function VectorAverage(const V: TVector3Single): Single; overload;
function VectorAverage(const V: TVector3Double): Double; overload;
function Approximate3DScale(const X, Y, Z: Single): Single;
function Approximate3DScale(const V: TVector3Single): Single;
function Lerp(const A: Single; const V1, V2: TVector2Byte): TVector2Byte; overload;
function Lerp(const A: Single; const V1, V2: TVector3Byte): TVector3Byte; overload;
function Lerp(const A: Single; const V1, V2: TVector4Byte): TVector4Byte; overload;
function Lerp(const A: Single; const V1, V2: TVector2Integer): TVector2Single; overload;
function Lerp(const A: Single; const V1, V2: TVector2Single): TVector2Single; overload;
function Lerp(const A: Single; const V1, V2: TVector3Single): TVector3Single; overload;
function Lerp(const A: Single; const V1, V2: TVector4Single): TVector4Single; overload;
function Lerp(const A: Double; const V1, V2: TVector2Double): TVector2Double; overload;
function Lerp(const A: Double; const V1, V2: TVector3Double): TVector3Double; overload;
function Lerp(const A: Double; const V1, V2: TVector4Double): TVector4Double; overload;
function Lerp(const A: Single; const M1, M2: TMatrix3Single): TMatrix3Single; overload;
function Lerp(const A: Single; const M1, M2: TMatrix4Single): TMatrix4Single; overload;
function Lerp(const A: Double; const M1, M2: TMatrix3Double): TMatrix3Double; overload;
function Lerp(const A: Double; const M1, M2: TMatrix4Double): TMatrix4Double; overload;
function Vector_Init_Lerp(const A: Single; const V1, V2: TVector3_Single): TVector3_Single; overload;
function Vector_Init_Lerp(const A: Single; const V1, V2: TVector4_Single): TVector4_Single; overload;
function Vector_Init_Lerp(const A: Double; const V1, V2: TVector3_Double): TVector3_Double; overload;
function Vector_Init_Lerp(const A: Double; const V1, V2: TVector4_Double): TVector4_Double; overload;
procedure NormalizeVar3Singlev(vv: PVector3Single);
procedure NormalizeVar3Bytev(vv: PVector3Byte);
procedure NormalizeVar(var v: TVector2Single); overload;
procedure NormalizeVar(var v: TVector2Double); overload;
procedure NormalizeVar(var v: TVector3Single); overload;
procedure NormalizeVar(var v: TVector3Double); overload;
function Normalized(const v: TVector2Single): TVector2Single; overload;
function Normalized(const v: TVector2Double): TVector2Double; overload;
function Normalized(const v: TVector3Single): TVector3Single; overload;
function Normalized(const v: TVector3Double): TVector3Double; overload;
function Vector_Get_Normalized(const V: TVector3_Single): TVector3_Single; overload;
function Vector_Get_Normalized(const V: TVector3_Double): TVector3_Double; overload;
procedure Vector_Normalize(var V: TVector3_Single); overload;
procedure Vector_Normalize(var V: TVector3_Double); overload;
procedure NormalizePlaneVar(var v: TVector4Single); overload;
procedure NormalizePlaneVar(var v: TVector4Double); overload;
function ZeroVector(const v: TVector2Single): boolean; overload;
function ZeroVector(const v: TVector2Double): boolean; overload;
function ZeroVector(const v: TVector3Single): boolean; overload;
function ZeroVector(const v: TVector3Double): boolean; overload;
function ZeroVector(const v: TVector4Single): boolean; overload;
function ZeroVector(const v: TVector4Double): boolean; overload;
function ZeroVector(const v: TVector2Single; const EqualityEpsilon: Single): boolean; overload;
function ZeroVector(const v: TVector2Double; const EqualityEpsilon: Double): boolean; overload;
function ZeroVector(const v: TVector3Single; const EqualityEpsilon: Single): boolean; overload;
function ZeroVector(const v: TVector3Double; const EqualityEpsilon: Double): boolean; overload;
function ZeroVector(const v: TVector4Single; const EqualityEpsilon: Single): boolean; overload;
function ZeroVector(const v: TVector4Double; const EqualityEpsilon: Double): boolean; overload;
function ZeroVector(const v: TVector4Integer): boolean; overload;
function ZeroVector(const v: TVector4Cardinal): boolean; overload;
function PerfectlyZeroVector(const v: TVector2Single): boolean; overload;
function PerfectlyZeroVector(const v: TVector2Double): boolean; overload;
function PerfectlyZeroVector(const v: TVector3Single): boolean; overload;
function PerfectlyZeroVector(const v: TVector3Double): boolean; overload;
function PerfectlyZeroVector(const v: TVector4Single): boolean; overload;
function PerfectlyZeroVector(const v: TVector4Double): boolean; overload;
function VectorSubtract(const V1, V2: TVector2Single): TVector2Single; overload;
function VectorSubtract(const V1, V2: TVector2Double): TVector2Double; overload;
function VectorSubtract(const V1, V2: TVector3Single): TVector3Single; overload;
function VectorSubtract(const V1, V2: TVector3Double): TVector3Double; overload;
function VectorSubtract(const V1, V2: TVector4Single): TVector4Single; overload;
function VectorSubtract(const V1, V2: TVector4Double): TVector4Double; overload;
procedure VectorSubtractVar(var v1: TVector2Single; const v2: TVector2Single); overload;
procedure VectorSubtractVar(var v1: TVector2Double; const v2: TVector2Double); overload;
procedure VectorSubtractVar(var v1: TVector3Single; const v2: TVector3Single); overload;
procedure VectorSubtractVar(var v1: TVector3Double; const v2: TVector3Double); overload;
procedure VectorSubtractVar(var v1: TVector4Single; const v2: TVector4Single); overload;
procedure VectorSubtractVar(var v1: TVector4Double; const v2: TVector4Double); overload;
function VectorAdd(const V1, V2: TVector2Single): TVector2Single; overload;
function VectorAdd(const V1, V2: TVector2Double): TVector2Double; overload;
function VectorAdd(const V1, V2: TVector3Single): TVector3Single; overload;
function VectorAdd(const V1, V2: TVector3Double): TVector3Double; overload;
function VectorAdd(const V1, V2: TVector4Single): TVector4Single; overload;
function VectorAdd(const V1, V2: TVector4Double): TVector4Double; overload;
procedure VectorAddVar(var v1: TVector2Single; const v2: TVector2Single); overload;
procedure VectorAddVar(var v1: TVector2Double; const v2: TVector2Double); overload;
procedure VectorAddVar(var v1: TVector3Single; const v2: TVector3Single); overload;
procedure VectorAddVar(var v1: TVector3Double; const v2: TVector3Double); overload;
procedure VectorAddVar(var v1: TVector4Single; const v2: TVector4Single); overload;
procedure VectorAddVar(var v1: TVector4Double; const v2: TVector4Double); overload;
function VectorScale(const v1: TVector2Single; const Scalar: Single): TVector2Single; overload;
function VectorScale(const v1: TVector2Double; const Scalar: Double): TVector2Double; overload;
function VectorScale(const v1: TVector3Single; const Scalar: Single): TVector3Single; overload;
function VectorScale(const v1: TVector3Double; const Scalar: Double): TVector3Double; overload;
function VectorScale(const v1: TVector4Single; const Scalar: Single): TVector4Single; overload;
function VectorScale(const v1: TVector4Double; const Scalar: Double): TVector4Double; overload;
procedure VectorScaleVar(var v1: TVector2Single; const Scalar: Single); overload;
procedure VectorScaleVar(var v1: TVector2Double; const Scalar: Double); overload;
procedure VectorScaleVar(var v1: TVector3Single; const Scalar: Single); overload;
procedure VectorScaleVar(var v1: TVector3Double; const Scalar: Double); overload;
procedure VectorScaleVar(var v1: TVector4Single; const Scalar: Single); overload;
procedure VectorScaleVar(var v1: TVector4Double; const Scalar: Double); overload;
function VectorNegate(const v: TVector2Single): TVector2Single; overload;
function VectorNegate(const v: TVector2Double): TVector2Double; overload;
function VectorNegate(const v: TVector3Single): TVector3Single; overload;
function VectorNegate(const v: TVector3Double): TVector3Double; overload;
function VectorNegate(const v: TVector4Single): TVector4Single; overload;
function VectorNegate(const v: TVector4Double): TVector4Double; overload;
procedure VectorNegateVar(var v: TVector2Single); overload;
procedure VectorNegateVar(var v: TVector2Double); overload;
procedure VectorNegateVar(var v: TVector3Single); overload;
procedure VectorNegateVar(var v: TVector3Double); overload;
procedure VectorNegateVar(var v: TVector4Single); overload;
procedure VectorNegateVar(var v: TVector4Double); overload;
function VectorAdjustToLength(const v: TVector2Single; VecLen: Single): TVector2Single; overload;
function VectorAdjustToLength(const v: TVector3Single; VecLen: Single): TVector3Single; overload;
function VectorAdjustToLength(const v: TVector3Double; VecLen: Double): TVector3Double; overload;
procedure VectorAdjustToLengthVar(var v: TVector2Single; VecLen: Single); overload;
procedure VectorAdjustToLengthVar(var v: TVector3Single; VecLen: Single); overload;
procedure VectorAdjustToLengthVar(var v: TVector3Double; VecLen: Double); overload;
function VectorLen(const v: TVector2Single): Single; overload;
function VectorLen(const v: TVector2Double): Double; overload;
function VectorLen(const v: TVector3Single): Single; overload;
function VectorLen(const v: TVector3Double): Double; overload;
function VectorLen(const v: TVector3Byte): Single; overload;
function VectorLen(const v: TVector4Single): Single; overload;
function VectorLen(const v: TVector4Double): Double; overload;
function VectorLenSqr(const v: TVector2Single): Single; overload;
function VectorLenSqr(const v: TVector2Double): Double; overload;
function VectorLenSqr(const v: TVector3Single): Single; overload;
function VectorLenSqr(const v: TVector3Double): Double; overload;
function VectorLenSqr(const v: TVector3Byte): Integer; overload;
function VectorLenSqr(const v: TVector4Single): Single; overload;
function VectorLenSqr(const v: TVector4Double): Double; overload;
function VectorProduct(const V1, V2: TVector3Double): TVector3Double; overload;
function VectorProduct(const V1, V2: TVector3Single): TVector3Single; overload;
function VectorDotProduct(const V1, V2: TVector2Single): Single; overload;
function VectorDotProduct(const V1, V2: TVector2Double): Double; overload;
function VectorDotProduct(const V1, V2: TVector3Single): Single; overload;
function VectorDotProduct(const V1, V2: TVector3Double): Double; overload;
function VectorDotProduct(const V1, V2: TVector4Single): Single; overload;
function VectorDotProduct(const V1, V2: TVector4Double): Double; overload;
function VectorDotProduct(const v1: TVector3Single; const v2: TVector4Single): Single; overload;
function VectorDotProduct(const v1: TVector3Double; const v2: TVector4Double): Double; overload;
function VectorMultiplyComponents(const V1, V2: TVector3Single): TVector3Single; overload;
function VectorMultiplyComponents(const V1, V2: TVector3Double): TVector3Double; overload;
procedure VectorMultiplyComponentsVar(var v1: TVector3Single; const v2: TVector3Single); overload;
procedure VectorMultiplyComponentsVar(var v1: TVector3Double; const v2: TVector3Double); overload;
function VectorPowerComponents(const v: TVector3Single; const Exp: Single): TVector3Single; overload;
function VectorPowerComponents(const v: TVector3Double; const Exp: Double): TVector3Double; overload;
procedure VectorPowerComponentsVar(var v: TVector3Single; const Exp: Single); overload;
procedure VectorPowerComponentsVar(var v: TVector3Double; const Exp: Double); overload;
function CosAngleBetweenVectors(const V1, V2: TVector3Single): Single; overload;
function CosAngleBetweenVectors(const V1, V2: TVector3Double): Double; overload;
function CosAngleBetweenNormals(const V1, V2: TVector3Single): Single; overload;
function CosAngleBetweenNormals(const V1, V2: TVector3Double): Double; overload;
function AngleRadBetweenVectors(const V1, V2: TVector3Single): Single; overload;
function AngleRadBetweenVectors(const V1, V2: TVector3Double): Double; overload;
function AngleRadBetweenNormals(const V1, V2: TVector3Single): Single; overload;
function AngleRadBetweenNormals(const V1, V2: TVector3Double): Double; overload;
function RotationAngleRadBetweenVectors(const V1, V2: TVector3Single): Single; overload;
function RotationAngleRadBetweenVectors(const V1, V2: TVector3Double): Double; overload;
function RotationAngleRadBetweenVectors(const V1, V2, Cross: TVector3Single): Single; overload;
function RotationAngleRadBetweenVectors(const V1, V2, Cross: TVector3Double): Double; overload;
function RotatePointAroundAxisDeg(Angle: Single; const Point: TVector3Single; const Axis: TVector3Single): TVector3Single; overload;
function RotatePointAroundAxisDeg(Angle: Double; const Point: TVector3Double; const Axis: TVector3Double): TVector3Double; overload;
function RotatePointAroundAxisRad(Angle: Single; const Point: TVector3Single; const Axis: TVector3Single): TVector3Single; overload;
function RotatePointAroundAxisRad(Angle: Double; const Point: TVector3Double; const Axis: TVector3Double): TVector3Double; overload;
function RotationNegate(const Rotation: TVector4Single): TVector4Single;
function RotatePoint2D(const Point: TVector2Single; const AngleRad: Single): TVector2Single;
function MaxVectorCoord(const v: TVector2Single): integer; overload;
function MaxVectorCoord(const v: TVector2Double): integer; overload;
function MaxVectorCoord(const v: TVector3Single): integer; overload;
function MaxVectorCoord(const v: TVector3Double): integer; overload;
function MaxVectorCoord(const v: TVector4Single): integer; overload;
function MaxVectorCoord(const v: TVector4Double): integer; overload;
function MaxAbsVectorCoord(const v: TVector2Single): integer; overload;
function MaxAbsVectorCoord(const v: TVector2Double): integer; overload;
function MaxAbsVectorCoord(const v: TVector3Single): integer; overload;
function MaxAbsVectorCoord(const v: TVector3Double): integer; overload;
function VectorAbs(const V: TVector2Single): TVector2Single;
function VectorAbs(const V: TVector2Double): TVector2Double;
function VectorAbs(const V: TVector3Single): TVector3Single;
function VectorAbs(const V: TVector3Double): TVector3Double;
function VectorAbs(const V: TVector4Single): TVector4Single;
function VectorAbs(const V: TVector4Double): TVector4Double;
function MinVectorCoord(const v: TVector3Single): integer; overload;
function MinVectorCoord(const v: TVector3Double): integer; overload;
procedure SortAbsVectorCoord(const v: TVector3Single; out Max, Middle, Min: Integer); overload;
procedure SortAbsVectorCoord(const v: TVector3Double; out Max, Middle, Min: Integer); overload;
function PlaneDirInDirection(const Plane: TVector4Single; const Direction: TVector3Single): TVector3Single; overload;
function PlaneDirInDirection(const PlaneDir, Direction: TVector3Single): TVector3Single; overload;
function PlaneDirInDirection(const Plane: TVector4Double; const Direction: TVector3Double): TVector3Double; overload;
function PlaneDirInDirection(const PlaneDir, Direction: TVector3Double): TVector3Double; overload;
function PlaneDirNotInDirection(const Plane: TVector4Single; const Direction: TVector3Single): TVector3Single; overload;
function PlaneDirNotInDirection(const PlaneDir, Direction: TVector3Single): TVector3Single; overload;
function PlaneDirNotInDirection(const Plane: TVector4Double; const Direction: TVector3Double): TVector3Double; overload;
function PlaneDirNotInDirection(const PlaneDir, Direction: TVector3Double): TVector3Double; overload;
procedure TwoPlanesIntersectionLine(const Plane0, Plane1: TVector4Single; out Line0, LineVector: TVector3Single); overload;
procedure TwoPlanesIntersectionLine(const Plane0, Plane1: TVector4Double; out Line0, LineVector: TVector3Double); overload;
function Lines2DIntersection(const Line0, Line1: TVector3Single): TVector2Single; overload;
function Lines2DIntersection(const Line0, Line1: TVector3Double): TVector2Double; overload;
function ThreePlanesIntersectionPoint( const Plane0, Plane1, Plane2: TVector4Single): TVector3Single; overload;
function ThreePlanesIntersectionPoint( const Plane0, Plane1, Plane2: TVector4Double): TVector3Double; overload;
function PlaneMove(const Plane: TVector4Single; const Move: TVector3Single): TVector4Single; overload;
function PlaneMove(const Plane: TVector4Double; const Move: TVector3Double): TVector4Double; overload;
procedure PlaneMoveVar(var Plane: TVector4Single; const Move: TVector3Single); overload;
procedure PlaneMoveVar(var Plane: TVector4Double; const Move: TVector3Double); overload;
function PlaneAntiMove(const Plane: TVector4Single; const Move: TVector3Single): TVector4Single; overload;
function PlaneAntiMove(const Plane: TVector4Double; const Move: TVector3Double): TVector4Double; overload;
function VectorsSamePlaneDirections(const V1, V2: TVector3Single; const Plane: TVector4Single): boolean; overload;
function VectorsSamePlaneDirections(const V1, V2: TVector3Double; const Plane: TVector4Double): boolean; overload;
function VectorsSamePlaneDirections(const V1, V2: TVector3Single; const PlaneDir: TVector3Single): boolean; overload;
function VectorsSamePlaneDirections(const V1, V2: TVector3Double; const PlaneDir: TVector3Double): boolean; overload;
function PointsSamePlaneSides(const p1, p2: TVector3Single; const Plane: TVector4Single): boolean; overload;
function PointsSamePlaneSides(const p1, p2: TVector3Double; const Plane: TVector4Double): boolean; overload;
function PointsDistance(const V1, V2: TVector2Single): Single; overload;
function PointsDistance(const V1, V2: TVector2Double): Double; overload;
function PointsDistance(const V1, V2: TVector3Single): Single; overload;
function PointsDistance(const V1, V2: TVector3Double): Double; overload;
function PointsDistanceSqr(const V1, V2: TVector3Single): Single; overload;
function PointsDistanceSqr(const V1, V2: TVector3Double): Double; overload;
function PointsDistanceSqr(const V1, V2: TVector2Single): Single; overload;
function PointsDistanceSqr(const V1, V2: TVector2Double): Double; overload;
function PointsDistance2DSqr(const V1, V2: TVector3Single; const IgnoreIndex: Integer): Single; overload;
function PointsDistance2DSqr(const V1, V2: TVector3Double; const IgnoreIndex: Integer): Double; overload;
function VectorsEqual(const V1, V2: TVector2Single): boolean; overload;
function VectorsEqual(const V1, V2: TVector2Double): boolean; overload;
function VectorsEqual(const V1, V2: TVector2Single; const EqualityEpsilon: Single): boolean; overload;
function VectorsEqual(const V1, V2: TVector2Double; const EqualityEpsilon: Double): boolean; overload;
function VectorsEqual(const V1, V2: TVector3Single): boolean; overload;
function VectorsEqual(const V1, V2: TVector3Double): boolean; overload;
function VectorsEqual(const V1, V2: TVector3Single; const EqualityEpsilon: Single): boolean; overload;
function VectorsEqual(const V1, V2: TVector3Double; const EqualityEpsilon: Double): boolean; overload;
function VectorsEqual(const V1, V2: TVector4Single): boolean; overload;
function VectorsEqual(const V1, V2: TVector4Double): boolean; overload;
function VectorsEqual(const V1, V2: TVector4Single; const EqualityEpsilon: Single): boolean; overload;
function VectorsEqual(const V1, V2: TVector4Double; const EqualityEpsilon: Double): boolean; overload;
function VectorsPerfectlyEqual(const V1, V2: TVector2Single): boolean; overload; inline;
function VectorsPerfectlyEqual(const V1, V2: TVector2Double): boolean; overload; inline;
function VectorsPerfectlyEqual(const V1, V2: TVector3Single): boolean; overload; inline;
function VectorsPerfectlyEqual(const V1, V2: TVector3Double): boolean; overload; inline;
function VectorsPerfectlyEqual(const V1, V2: TVector4Single): boolean; overload; inline;
function VectorsPerfectlyEqual(const V1, V2: TVector4Double): boolean; overload; inline;
function VectorsPerfectlyEqual(const V1, V2: TVector2Byte ): boolean; overload; inline;
function VectorsPerfectlyEqual(const V1, V2: TVector3Byte ): boolean; overload; inline;
function VectorsPerfectlyEqual(const V1, V2: TVector4Byte ): boolean; overload; inline;
function MatricesEqual(const M1, M2: TMatrix3Single; const EqualityEpsilon: Single): boolean; overload;
function MatricesEqual(const M1, M2: TMatrix3Double; const EqualityEpsilon: Double): boolean; overload;
function MatricesEqual(const M1, M2: TMatrix4Single; const EqualityEpsilon: Single): boolean; overload;
function MatricesEqual(const M1, M2: TMatrix4Double; const EqualityEpsilon: Double): boolean; overload;
function MatricesPerfectlyEqual(const M1, M2: TMatrix3Single): boolean; overload;
function MatricesPerfectlyEqual(const M1, M2: TMatrix3Double): boolean; overload;
function MatricesPerfectlyEqual(const M1, M2: TMatrix4Single): boolean; overload;
function MatricesPerfectlyEqual(const M1, M2: TMatrix4Double): boolean; overload;
function VectorsPerp(const V1, V2: TVector3Single): boolean; overload;
function VectorsPerp(const V1, V2: TVector3Double): boolean; overload;
function VectorsParallel(const V1, V2: TVector3Single): boolean; overload;
function VectorsParallel(const V1, V2: TVector3Double): boolean; overload;
procedure MakeVectorsAngleRadOnTheirPlane(var v1: TVector3Single; const v2: TVector3Single; const AngleRad: Single; const ResultWhenParallel: TVector3Single); overload;
procedure MakeVectorsAngleRadOnTheirPlane(var v1: TVector3Double; const v2: TVector3Double; const AngleRad: Double; const ResultWhenParallel: TVector3Double); overload;
procedure MakeVectorsOrthoOnTheirPlane(var v1: TVector3Single; const v2: TVector3Single); overload;
procedure MakeVectorsOrthoOnTheirPlane(var v1: TVector3Double; const v2: TVector3Double); overload;
function AnyOrthogonalVector(const v: TVector2Single): TVector2Single; overload;
function AnyOrthogonalVector(const v: TVector2Double): TVector2Double; overload;
function AnyOrthogonalVector(const v: TVector3Single): TVector3Single; overload;
function AnyOrthogonalVector(const v: TVector3Double): TVector3Double; overload;
function IsLineParallelToPlane(const lineVector: TVector3Single; const plane: TVector4Single): boolean; overload;
function IsLineParallelToPlane(const lineVector: TVector3Double; const plane: TVector4Double): boolean; overload;
function IsLineParallelToSimplePlane(const lineVector: TVector3Single; const PlaneConstCoord: integer): boolean; overload;
function IsLineParallelToSimplePlane(const lineVector: TVector3Double; const PlaneConstCoord: integer): boolean; overload;
function AreParallelVectorsSameDirection( const Vector1, Vector2: TVector3Single): boolean; overload;
function AreParallelVectorsSameDirection( const Vector1, Vector2: TVector3Double): boolean; overload;
function PointOnPlaneClosestToPoint(const plane: TVector4Single; const point: TVector3Single): TVector3Single; overload;
function PointOnPlaneClosestToPoint(const plane: TVector4Double; const point: TVector3Double): TVector3Double; overload;
function PointToPlaneDistanceSqr(const Point: TVector3Single; const Plane: TVector4Single): Single; overload;
function PointToPlaneDistanceSqr(const Point: TVector3Double; const Plane: TVector4Double): Double; overload;
function PointToNormalizedPlaneDistance(const Point: TVector3Single; const Plane: TVector4Single): Single; overload;
function PointToNormalizedPlaneDistance(const Point: TVector3Double; const Plane: TVector4Double): Double; overload;
function PointToPlaneDistance(const Point: TVector3Single; const Plane: TVector4Single): Single; overload;
function PointToPlaneDistance(const Point: TVector3Double; const Plane: TVector4Double): Double; overload;
function PointToSimplePlaneDistance(const point: TVector3Single; const PlaneConstCoord: integer; const PlaneConstValue: Single): Single; overload;
function PointToSimplePlaneDistance(const point: TVector3Double; const PlaneConstCoord: integer; const PlaneConstValue: Double): Double; overload;
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector3Single): TVector3Single; overload;
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector3Double): TVector3Double; overload;
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector2Single): TVector2Single; overload;
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector2Double): TVector2Double; overload;
function PointToLineDistanceSqr(const point, line0, lineVector: TVector3Single): Single; overload;
function PointToLineDistanceSqr(const point, line0, lineVector: TVector3Double): Double; overload;
function TryPlaneLineIntersection(out intersection: TVector3Single; const plane: TVector4Single; const line0, lineVector: TVector3Single): boolean; overload;
function TryPlaneLineIntersection(out intersection: TVector3Double; const plane: TVector4Double; const line0, lineVector: TVector3Double): boolean; overload;
function TryPlaneLineIntersection(out t: Single; const plane: TVector4Single; const line0, lineVector: TVector3Single): boolean; overload;
function TryPlaneLineIntersection(out t: Double; const plane: TVector4Double; const line0, lineVector: TVector3Double): boolean; overload;
function TrySimplePlaneRayIntersection(out Intersection: TVector3Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
function TrySimplePlaneRayIntersection(out Intersection: TVector3Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
function TrySimplePlaneRayIntersection(out Intersection: TVector3Single; out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
function TrySimplePlaneRayIntersection(out Intersection: TVector3Double; out T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
function TrySimplePlaneRayIntersection(out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
function TrySimplePlaneRayIntersection(out T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
function TryPlaneRayIntersection(out Intersection: TVector3Single; const Plane: TVector4Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
function TryPlaneRayIntersection(out Intersection: TVector3Double; const Plane: TVector4Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
function TryPlaneRayIntersection(out Intersection: TVector3Single; out T: Single; const Plane: TVector4Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
function TryPlaneRayIntersection(out Intersection: TVector3Double; out T: Double; const Plane: TVector4Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
function TrySimplePlaneSegmentDirIntersection(var Intersection: TVector3Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Segment0, SegmentVector: TVector3Single): boolean; overload;
function TrySimplePlaneSegmentDirIntersection(var Intersection: TVector3Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Segment0, SegmentVector: TVector3Double): boolean; overload;
function TrySimplePlaneSegmentDirIntersection(var Intersection: TVector3Single; var T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Segment0, SegmentVector: TVector3Single): boolean; overload;
function TrySimplePlaneSegmentDirIntersection(var Intersection: TVector3Double; var T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Segment0, SegmentVector: TVector3Double): boolean; overload;
function TrySimplePlaneSegmentDirIntersection(var T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Segment0, SegmentVector: TVector3Single): boolean; overload;
function TrySimplePlaneSegmentDirIntersection(var T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Segment0, SegmentVector: TVector3Double): boolean; overload;
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3Single): boolean; overload;
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Pos1, Pos2: TVector3Double): boolean; overload;
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3Single; out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3Single): boolean; overload;
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3Double; out T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Pos1, Pos2: TVector3Double): boolean; overload;
function TrySimplePlaneSegmentIntersection( out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3Single): boolean; overload;
function TrySimplePlaneSegmentIntersection( out T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Pos1, Pos2: TVector3Double): boolean; overload;
function TryPlaneSegmentDirIntersection(out Intersection: TVector3Single; const Plane: TVector4Single; const Segment0, SegmentVector: TVector3Single): boolean; overload;
function TryPlaneSegmentDirIntersection(out Intersection: TVector3Double; const Plane: TVector4Double; const Segment0, SegmentVector: TVector3Double): boolean; overload;
function TryPlaneSegmentDirIntersection(out Intersection: TVector3Single; out T: Single; const Plane: TVector4Single; const Segment0, SegmentVector: TVector3Single): boolean; overload;
function TryPlaneSegmentDirIntersection(out Intersection: TVector3Double; out T: Double; const Plane: TVector4Double; const Segment0, SegmentVector: TVector3Double): boolean; overload;
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector2Single): boolean; overload;
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector2Double): boolean; overload;
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector3Single): boolean; overload;
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector3Double): boolean; overload;
function LineOfTwoDifferentPoints2d(const p1, p2: TVector2Single): TVector3Single; overload;
function LineOfTwoDifferentPoints2d(const p1, p2: TVector2Double): TVector3Double; overload;
function PointToSegmentDistanceSqr(const point, pos1, pos2: TVector3Single): Single; overload;
function PointToSegmentDistanceSqr(const point, pos1, pos2: TVector3Double): Double; overload;
function PlaneTransform(const Plane: TVector4Single; const Matrix: TMatrix4Single): TVector4Single;
function PlaneTransform(const Plane: TVector4Double; const Matrix: TMatrix4Double): TVector4Double;
function IsTunnelSphereCollision(const Tunnel1, Tunnel2: TVector3Single; const TunnelRadius: Single; const SphereCenter: TVector3Single; const SphereRadius: Single): boolean; overload;
function IsTunnelSphereCollision(const Tunnel1, Tunnel2: TVector3Double; const TunnelRadius: Double; const SphereCenter: TVector3Double; const SphereRadius: Double): boolean; overload;
function IsSpheresCollision(const Sphere1Center: TVector3Single; const Sphere1Radius: Single; const Sphere2Center: TVector3Single; const Sphere2Radius: Single): boolean; overload;
function IsSpheresCollision(const Sphere1Center: TVector3Double; const Sphere1Radius: Double; const Sphere2Center: TVector3Double; const Sphere2Radius: Double): boolean; overload;
function IsSegmentSphereCollision(const pos1, pos2, SphereCenter: TVector3Single; const SphereRadius: Single): boolean; overload;
function IsSegmentSphereCollision(const pos1, pos2, SphereCenter: TVector3Double; const SphereRadius: Double): boolean; overload;
function TrySphereRayIntersection(out Intersection: TVector3Single; const SphereCenter: TVector3Single; const SphereRadius: Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
function TrySphereRayIntersection(out Intersection: TVector3Double; const SphereCenter: TVector3Double; const SphereRadius: Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
function TryCylinderRayIntersection(out Intersection: TVector3Single; const CylinderAxisOrigin, CylinderAxis: TVector3Single; const CylinderRadius: Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
function TryCylinderRayIntersection(out Intersection: TVector3Double; const CylinderAxisOrigin, CylinderAxis: TVector3Double; const CylinderRadius: Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
function FloatToNiceStr(f: Single): string; overload;
function FloatToNiceStr(f: Double): string; overload;
function VectorToNiceStr(const v: array of Byte): string; overload;
function VectorToNiceStr(const v: array of Single): string; overload;
function VectorToNiceStr(const v: array of Double): string; overload;
function VectorToNiceStr(const v: array of Integer): string; overload;
function MatrixToNiceStr(const v: TMatrix4Single; const LineIndent: string): string; overload;
function MatrixToNiceStr(const v: TMatrix4Double; const LineIndent: string): string; overload;
function FloatToRawStr(f: Single): string; overload;
function FloatToRawStr(f: Double): string; overload;
function VectorToRawStr(const v: array of Byte): string; overload;
function VectorToRawStr(const v: array of Integer): string; overload;
function VectorToRawStr(const v: array of Single): string; overload;
function VectorToRawStr(const v: array of Double): string; overload;
function MatrixToRawStr(const v: TMatrix4Single; const LineIndent: string): string; overload;
function MatrixToRawStr(const v: TMatrix4Double; const LineIndent: string): string; overload;
function MatrixAdd(const m1, m2: TMatrix3Single): TMatrix3Single; overload;
function MatrixAdd(const m1, m2: TMatrix4Single): TMatrix4Single; overload;
function MatrixAdd(const m1, m2: TMatrix3Double): TMatrix3Double; overload;
function MatrixAdd(const m1, m2: TMatrix4Double): TMatrix4Double; overload;
procedure MatrixAddVar(var m1: TMatrix3Single; const m2: TMatrix3Single); overload;
procedure MatrixAddVar(var m1: TMatrix4Single; const m2: TMatrix4Single); overload;
procedure MatrixAddVar(var m1: TMatrix3Double; const m2: TMatrix3Double); overload;
procedure MatrixAddVar(var m1: TMatrix4Double; const m2: TMatrix4Double); overload;
function MatrixSubtract(const m1, m2: TMatrix3Single): TMatrix3Single; overload;
function MatrixSubtract(const m1, m2: TMatrix4Single): TMatrix4Single; overload;
function MatrixSubtract(const m1, m2: TMatrix3Double): TMatrix3Double; overload;
function MatrixSubtract(const m1, m2: TMatrix4Double): TMatrix4Double; overload;
procedure MatrixSubtractVar(var m1: TMatrix3Single; const m2: TMatrix3Single); overload;
procedure MatrixSubtractVar(var m1: TMatrix4Single; const m2: TMatrix4Single); overload;
procedure MatrixSubtractVar(var m1: TMatrix3Double; const m2: TMatrix3Double); overload;
procedure MatrixSubtractVar(var m1: TMatrix4Double; const m2: TMatrix4Double); overload;
function MatrixNegate(const m1: TMatrix3Single): TMatrix3Single; overload;
function MatrixNegate(const m1: TMatrix4Single): TMatrix4Single; overload;
function MatrixNegate(const m1: TMatrix3Double): TMatrix3Double; overload;
function MatrixNegate(const m1: TMatrix4Double): TMatrix4Double; overload;
function MatrixMultScalar(const m: TMatrix3Single; const s: Single): TMatrix3Single; overload;
function MatrixMultScalar(const m: TMatrix4Single; const s: Single): TMatrix4Single; overload;
function MatrixMultScalar(const m: TMatrix3Double; const s: Double): TMatrix3Double; overload;
function MatrixMultScalar(const m: TMatrix4Double; const s: Double): TMatrix4Double; overload;
function MatrixMultPoint(const m: TMatrix4Single; const pt: TVector3Single): TVector3Single; overload;
function MatrixMultPoint(const m: TMatrix4Double; const pt: TVector3Double): TVector3Double; overload;
function MatrixMultPoint(const m: TMatrix4Single; const pt: TVector2Single): TVector2Single; overload;
function MatrixMultPoint(const m: TMatrix4Double; const pt: TVector2Double): TVector2Double; overload;
function MatrixMultDirection(const m: TMatrix4Single; const Dir: TVector3Single): TVector3Single; overload;
function MatrixMultDirection(const m: TMatrix4Double; const Dir: TVector3Double): TVector3Double; overload;
function MatrixMultDirection(const m: TMatrix4Single; const Dir: TVector2Single): TVector2Single; overload;
function MatrixMultDirection(const m: TMatrix4Double; const Dir: TVector2Double): TVector2Double; overload;
function MatrixMultVector(const m: TMatrix2Single; const v: TVector2Single): TVector2Single; overload;
function MatrixMultVector(const m: TMatrix3Single; const v: TVector3Single): TVector3Single; overload;
function MatrixMultVector(const m: TMatrix4Single; const v: TVector4Single): TVector4Single; overload;
function MatrixMultVector(const m: TMatrix2Double; const v: TVector2Double): TVector2Double; overload;
function MatrixMultVector(const m: TMatrix3Double; const v: TVector3Double): TVector3Double; overload;
function MatrixMultVector(const m: TMatrix4Double; const v: TVector4Double): TVector4Double; overload;
function MatrixMult(const m1, m2: TMatrix2Single): TMatrix2Single; overload;
function MatrixMult(const m1, m2: TMatrix3Single): TMatrix3Single; overload;
function MatrixMult(const m1, m2: TMatrix4Single): TMatrix4Single; overload;
function MatrixMult(const m1, m2: TMatrix2Double): TMatrix2Double; overload;
function MatrixMult(const m1, m2: TMatrix3Double): TMatrix3Double; overload;
function MatrixMult(const m1, m2: TMatrix4Double): TMatrix4Double; overload;
function MatrixRow(const m: TMatrix2Single; const Row: Integer): TVector2Single; overload;
function MatrixRow(const m: TMatrix3Single; const Row: Integer): TVector3Single; overload;
function MatrixRow(const m: TMatrix4Single; const Row: Integer): TVector4Single; overload;
function MatrixRow(const m: TMatrix2Double; const Row: Integer): TVector2Double; overload;
function MatrixRow(const m: TMatrix3Double; const Row: Integer): TVector3Double; overload;
function MatrixRow(const m: TMatrix4Double; const Row: Integer): TVector4Double; overload;
function MatrixDeterminant(const M: TMatrix2Single): Single; overload;
function MatrixDeterminant(const M: TMatrix2Double): Double; overload;
function MatrixDeterminant(const M: TMatrix3Single): Single; overload;
function MatrixDeterminant(const M: TMatrix3Double): Double; overload;
function MatrixDeterminant(const M: TMatrix4Single): Single; overload;
function MatrixDeterminant(const M: TMatrix4Double): Double; overload;
function MatrixInverse(const M: TMatrix2Single; const Determinant: Single): TMatrix2Single; overload;
function MatrixInverse(const M: TMatrix2Double; const Determinant: Double): TMatrix2Double; overload;
function MatrixInverse(const M: TMatrix3Single; const Determinant: Single): TMatrix3Single; overload;
function MatrixInverse(const M: TMatrix3Double; const Determinant: Double): TMatrix3Double; overload;
function MatrixInverse(const M: TMatrix4Single; const Determinant: Single): TMatrix4Single; overload;
function MatrixInverse(const M: TMatrix4Double; const Determinant: Double): TMatrix4Double; overload;
procedure MatrixTransposeVar(var M: TMatrix3Single); overload;
procedure MatrixTransposeVar(var M: TMatrix3Double); overload;
function MatrixTranspose(const M: TMatrix3Single): TMatrix3Single; overload;
function MatrixTranspose(const M: TMatrix3Double): TMatrix3Double; overload;
function MatrixTranspose(const M: TMatrix4Single): TMatrix4Single; overload;
function MatrixTranspose(const M: TMatrix4Double): TMatrix4Double; overload;
function TryMatrixInverse(const M: TMatrix2Single; out MInverse: TMatrix2Single): boolean; overload;
function TryMatrixInverse(const M: TMatrix2Double; out MInverse: TMatrix2Double): boolean; overload;
function TryMatrixInverse(const M: TMatrix3Single; out MInverse: TMatrix3Single): boolean; overload;
function TryMatrixInverse(const M: TMatrix3Double; out MInverse: TMatrix3Double): boolean; overload;
function TryMatrixInverse(const M: TMatrix4Single; out MInverse: TMatrix4Single): boolean; overload;
function TryMatrixInverse(const M: TMatrix4Double; out MInverse: TMatrix4Double): boolean; overload;
function ModelViewToNormalMatrix(const M: TMatrix4Single): TMatrix3Single;
function VectorMultTransposedSameVector(const v: TVector3Single): TMatrix4Single;
function TranslationMatrix(const X, Y, Z: Single): TMatrix4Single; overload;
function TranslationMatrix(const X, Y, Z: Double): TMatrix4Single; overload;
function TranslationMatrix(const Transl: TVector3Single): TMatrix4Single; overload;
function TranslationMatrix(const Transl: TVector3Double): TMatrix4Single; overload;
procedure TranslationMatrices(const X, Y, Z: Single; out Matrix, InvertedMatrix: TMatrix4Single); overload;
procedure TranslationMatrices(const X, Y, Z: Double; out Matrix, InvertedMatrix: TMatrix4Single); overload;
procedure TranslationMatrices(const Transl: TVector3Single; out Matrix, InvertedMatrix: TMatrix4Single); overload;
procedure TranslationMatrices(const Transl: TVector3Double; out Matrix, InvertedMatrix: TMatrix4Single); overload;
function ScalingMatrix(const ScaleFactor: TVector3Single): TMatrix4Single;
procedure ScalingMatrices(const ScaleFactor: TVector3Single; InvertedMatrixIdentityIfNotExists: boolean; out Matrix, InvertedMatrix: TMatrix4Single);
function RotationMatrixRad(const AngleRad: Single; const Axis: TVector3Single): TMatrix4Single; overload;
function RotationMatrixDeg(const AngleDeg: Single; const Axis: TVector3Single): TMatrix4Single; overload;
function RotationMatrixRad(const AngleRad: Single; const AxisX, AxisY, AxisZ: Single): TMatrix4Single; overload;
function RotationMatrixDeg(const AngleDeg: Single; const AxisX, AxisY, AxisZ: Single): TMatrix4Single; overload;
procedure RotationMatricesRad(const AngleRad: Single; const Axis: TVector3Single; out Matrix, InvertedMatrix: TMatrix4Single);
procedure RotationMatricesRad(const AxisAngle: TVector4Single; out Matrix, InvertedMatrix: TMatrix4Single);
procedure MultMatrixTranslation(var M: TMatrix4Single; const Transl: TVector3Single); overload;
procedure MultMatrixTranslation(var M: TMatrix4Double; const Transl: TVector3Double); overload;
procedure MultMatricesTranslation(var M, MInvert: TMatrix4Single; const Transl: TVector3Single); overload;
procedure MultMatricesTranslation(var M, MInvert: TMatrix4Double; const Transl: TVector3Double); overload;
function MatrixDet4x4(const mat: TMatrix4Single): Single;
function MatrixDet3x3(const a1, a2, a3, b1, b2, b3, c1, c2, c3: Single): Single;
function MatrixDet2x2(const a, b, c, d: Single): Single;
function TransformToCoordsMatrix(const NewX, NewY, NewZ: TVector3Single): TMatrix4Single; overload;
function TransformToCoordsMatrix(const NewX, NewY, NewZ: TVector3Double): TMatrix4Single; overload;
function TransformToCoordsMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3Single): TMatrix4Single; overload;
function TransformToCoordsMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3Double): TMatrix4Single; overload;
function TransformToCoordsNoScaleMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3Single): TMatrix4Single; overload;
function TransformToCoordsNoScaleMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3Double): TMatrix4Single; overload;
function TransformFromCoordsMatrix(const OldX, OldY, OldZ: TVector3Single): TMatrix4Single; overload;
function TransformFromCoordsMatrix(const OldX, OldY, OldZ: TVector3Double): TMatrix4Single; overload;
function TransformFromCoordsMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3Single): TMatrix4Single; overload;
function TransformFromCoordsMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3Double): TMatrix4Single; overload;
function TransformFromCoordsNoScaleMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3Single): TMatrix4Single; overload;
function TransformFromCoordsNoScaleMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3Double): TMatrix4Single; overload;
procedure TransformCoordsMatrices(const NewX, NewY, NewZ: TVector3Single; out ToCoords, FromCoords: TMatrix4Single); overload;
procedure TransformCoordsMatrices(const NewX, NewY, NewZ: TVector3Double; out ToCoords, FromCoords: TMatrix4Single); overload;
function TransformToCoords(const V, NewX, NewY, NewZ: TVector3Single): TVector3Single;
function TransformToCoords(const V, NewX, NewY, NewZ: TVector3Double): TVector3Double;
function LookAtMatrix(const Eye, Center, Up: TVector3Single): TMatrix4Single; overload;
function LookAtMatrix(const Eye, Center, Up: TVector3Double): TMatrix4Single; overload;
function LookDirMatrix(const Eye, Dir, Up: TVector3Single): TMatrix4Single; overload;
function LookDirMatrix(const Eye, Dir, Up: TVector3Double): TMatrix4Single; overload;
function LookDirMatrix(const Eye, Dir, Side, Up: TVector3Single): TMatrix4Single; overload;
function LookDirMatrix(const Eye, Dir, Side, Up: TVector3Double): TMatrix4Single; overload;
function FastLookDirMatrix(const Direction, Up: TVector3Single): TMatrix4Single;
function FastLookDirMatrix(const Direction, Up: TVector3Double): TMatrix4Single;
function InverseFastLookDirMatrix(const Direction, Up: TVector3Single): TMatrix4Single;
function InverseFastLookDirMatrix(const Direction, Up: TVector3Double): TMatrix4Single;
operator + (const x,y:Tvector2_single_data) : Tvector2_single_data;
operator + (const x,y:Tvector2_double_data) : Tvector2_double_data;
operator + (const x,y:Tvector2_extended_data) : Tvector2_extended_data;
operator + (const x,y:Tvector2Integer) : Tvector2Integer;
operator + (const x,y:Tvector3_single_data) : Tvector3_single_data;
operator + (const x,y:Tvector3_double_data) : Tvector3_double_data;
operator + (const x,y:Tvector3_extended_data) : Tvector3_extended_data;
operator + (const x,y:Tvector3Integer) : Tvector3Integer;
operator + (const x,y:Tvector4_single_data) : Tvector4_single_data;
operator + (const x,y:Tvector4_double_data) : Tvector4_double_data;
operator + (const x,y:Tvector4_extended_data) : Tvector4_extended_data;
operator + (const x,y:Tvector4Integer) : Tvector4Integer;
operator - (const x,y:Tvector2_single_data) : Tvector2_single_data;
operator - (const x,y:Tvector2_double_data) : Tvector2_double_data;
operator - (const x,y:Tvector2_extended_data) : Tvector2_extended_data;
operator - (const x,y:Tvector2Integer) : Tvector2Integer;
operator - (const x,y:Tvector3_single_data) : Tvector3_single_data;
operator - (const x,y:Tvector3_double_data) : Tvector3_double_data;
operator - (const x,y:Tvector3_extended_data) : Tvector3_extended_data;
operator - (const x,y:Tvector3Integer) : Tvector3Integer;
operator - (const x,y:Tvector4_single_data) : Tvector4_single_data;
operator - (const x,y:Tvector4_double_data) : Tvector4_double_data;
operator - (const x,y:Tvector4_extended_data) : Tvector4_extended_data;
operator - (const x,y:Tvector4Integer) : Tvector4Integer;
operator - (const x:Tvector2_single_data) : Tvector2_single_data;
operator - (const x:Tvector2_double_data) : Tvector2_double_data;
operator - (const x:Tvector2_extended_data) : Tvector2_extended_data;
operator - (const x:Tvector2Integer) : Tvector2Integer;
operator - (const x:Tvector3_single_data) : Tvector3_single_data;
operator - (const x:Tvector3_double_data) : Tvector3_double_data;
operator - (const x:Tvector3_extended_data) : Tvector3_extended_data;
operator - (const x:Tvector3Integer) : Tvector3Integer;
operator - (const x:Tvector4_single_data) : Tvector4_single_data;
operator - (const x:Tvector4_double_data) : Tvector4_double_data;
operator - (const x:Tvector4_extended_data) : Tvector4_extended_data;
operator - (const x:Tvector4Integer) : Tvector4Integer;
operator * (const x,y:Tvector2_single_data) : Tvector2_single_data;
operator * (const x,y:Tvector2_double_data) : Tvector2_double_data;
operator * (const x,y:Tvector2_extended_data) : Tvector2_extended_data;
operator * (const x,y:Tvector2Integer) : Tvector2Integer;
operator * (const x,y:Tvector3_single_data) : Tvector3_single_data;
operator * (const x,y:Tvector3_double_data) : Tvector3_double_data;
operator * (const x,y:Tvector3_extended_data) : Tvector3_extended_data;
operator * (const x,y:Tvector3Integer) : Tvector3Integer;
operator * (const x,y:Tvector4_single_data) : Tvector4_single_data;
operator * (const x,y:Tvector4_double_data) : Tvector4_double_data;
operator * (const x,y:Tvector4_extended_data) : Tvector4_extended_data;
operator * (const x,y:Tvector4Integer) : Tvector4Integer;
operator ** (const x,y:Tvector2_single_data) : single;
operator ** (const x,y:Tvector2_double_data) : double;
operator ** (const x,y:Tvector2_extended_data) : extended;
operator ** (const x,y:Tvector2Integer) : Integer;
operator ** (const x,y:Tvector3_single_data) : single;
operator ** (const x,y:Tvector3_double_data) : double;
operator ** (const x,y:Tvector3_extended_data) : extended;
operator ** (const x,y:Tvector3Integer) : Integer;
operator ** (const x,y:Tvector4_single_data) : single;
operator ** (const x,y:Tvector4_double_data) : double;
operator ** (const x,y:Tvector4_extended_data) : extended;
operator ** (const x,y:Tvector4Integer) : Integer;
operator >< (const x,y:Tvector3_single_data) : Tvector3_single_data;
operator >< (const x,y:Tvector3_double_data) : Tvector3_double_data;
operator >< (const x,y:Tvector3_extended_data) : Tvector3_extended_data;
operator >< (const x,y:Tvector3Integer) : Tvector3Integer;
operator * (const x:Tvector2_single_data;y:single) : Tvector2_single_data;
operator * (const x:Tvector2_double_data;y:double) : Tvector2_double_data;
operator * (const x:Tvector2_extended_data;y:extended) : Tvector2_extended_data;
operator * (const x:Tvector3_single_data;y:single) : Tvector3_single_data;
operator * (const x:Tvector3_double_data;y:double) : Tvector3_double_data;
operator * (const x:Tvector3_extended_data;y:extended) : Tvector3_extended_data;
operator * (const x:Tvector4_single_data;y:single) : Tvector4_single_data;
operator * (const x:Tvector4_double_data;y:double) : Tvector4_double_data;
operator * (const x:Tvector4_extended_data;y:extended) : Tvector4_extended_data;
operator / (const x:Tvector2_single_data;y:single) : Tvector2_single_data;
operator / (const x:Tvector2_double_data;y:double) : Tvector2_double_data;
operator / (const x:Tvector2_extended_data;y:extended) : Tvector2_extended_data;
operator / (const x:Tvector3_single_data;y:single) : Tvector3_single_data;
operator / (const x:Tvector3_double_data;y:double) : Tvector3_double_data;
operator / (const x:Tvector3_extended_data;y:extended) : Tvector3_extended_data;
operator / (const x:Tvector4_single_data;y:single) : Tvector4_single_data;
operator / (const x:Tvector4_double_data;y:double) : Tvector4_double_data;
operator / (const x:Tvector4_extended_data;y:extended) : Tvector4_extended_data;
operator + (const m1,m2:Tmatrix2_single_data) : Tmatrix2_single_data;
operator + (const m1,m2:Tmatrix2_double_data) : Tmatrix2_double_data;
operator + (const m1,m2:Tmatrix3_single_data) : Tmatrix3_single_data;
operator + (const m1,m2:Tmatrix3_double_data) : Tmatrix3_double_data;
operator + (const m1,m2:Tmatrix4_single_data) : Tmatrix4_single_data;
operator + (const m1,m2:Tmatrix4_double_data) : Tmatrix4_double_data;
operator - (const m1,m2:Tmatrix2_single_data) : Tmatrix2_single_data;
operator - (const m1,m2:Tmatrix2_double_data) : Tmatrix2_double_data;
operator - (const m1,m2:Tmatrix3_single_data) : Tmatrix3_single_data;
operator - (const m1,m2:Tmatrix3_double_data) : Tmatrix3_double_data;
operator - (const m1,m2:Tmatrix4_single_data) : Tmatrix4_single_data;
operator - (const m1,m2:Tmatrix4_double_data) : Tmatrix4_double_data;
operator - (const m1:Tmatrix2_single_data) : Tmatrix2_single_data;
operator - (const m1:Tmatrix2_double_data) : Tmatrix2_double_data;
operator - (const m1:Tmatrix3_single_data) : Tmatrix3_single_data;
operator - (const m1:Tmatrix3_double_data) : Tmatrix3_double_data;
operator - (const m1:Tmatrix4_single_data) : Tmatrix4_single_data;
operator - (const m1:Tmatrix4_double_data) : Tmatrix4_double_data;
operator * (const m1,m2:Tmatrix2_single_data) : Tmatrix2_single_data;
operator * (const m1,m2:Tmatrix2_double_data) : Tmatrix2_double_data;
operator * (const m1,m2:Tmatrix3_single_data) : Tmatrix3_single_data;
operator * (const m1,m2:Tmatrix3_double_data) : Tmatrix3_double_data;
operator * (const m1,m2:Tmatrix4_single_data) : Tmatrix4_single_data;
operator * (const m1,m2:Tmatrix4_double_data) : Tmatrix4_double_data;
operator * (const m:Tmatrix2_single_data;const v:Tvector2_single_data) : Tvector2_single_data;
operator * (const m:Tmatrix2_double_data;const v:Tvector2_double_data) : Tvector2_double_data;
operator * (const m:Tmatrix3_single_data;const v:Tvector3_single_data) : Tvector3_single_data;
operator * (const m:Tmatrix3_double_data;const v:Tvector3_double_data) : Tvector3_double_data;
operator * (const m:Tmatrix4_single_data;const v:Tvector4_single_data) : Tvector4_single_data;
operator * (const m:Tmatrix4_double_data;const v:Tvector4_double_data) : Tvector4_double_data;
operator * (const m:Tmatrix2_single_data;const x:single) : Tmatrix2_single_data;
operator * (const m:Tmatrix2_double_data;const x:double) : Tmatrix2_double_data;
operator * (const m:Tmatrix3_single_data;const x:single) : Tmatrix3_single_data;
operator * (const m:Tmatrix3_double_data;const x:double) : Tmatrix3_double_data;
operator * (const m:Tmatrix4_single_data;const x:single) : Tmatrix4_single_data;
operator * (const m:Tmatrix4_double_data;const x:double) : Tmatrix4_double_data;
operator / (const m:Tmatrix2_single_data;const x:single) : Tmatrix2_single_data;
operator / (const m:Tmatrix2_double_data;const x:double) : Tmatrix2_double_data;
operator / (const m:Tmatrix3_single_data;const x:single) : Tmatrix3_single_data;
operator / (const m:Tmatrix3_double_data;const x:double) : Tmatrix3_double_data;
operator / (const m:Tmatrix4_single_data;const x:single) : Tmatrix4_single_data;
operator / (const m:Tmatrix4_double_data;const x:double) : Tmatrix4_double_data;

Types

Pvector2_single = ˆTvector2_single ;
Pvector2_double = ˆTvector2_double ;
Pvector2_extended = ˆTvector2_extended;
Pvector3_single = ˆTvector3_single ;
Pvector3_double = ˆTvector3_double ;
Pvector3_extended = ˆTvector3_extended;
Pvector4_single = ˆTvector4_single ;
Pvector4_double = ˆTvector4_double ;
Pvector4_extended = ˆTvector4_extended;
Pmatrix2_single = ˆTmatrix2_single ;
Pmatrix2_double = ˆTmatrix2_double ;
Pmatrix2_extended = ˆTmatrix2_extended;
Pmatrix3_single = ˆTmatrix3_single ;
Pmatrix3_double = ˆTmatrix3_double ;
Pmatrix3_extended = ˆTmatrix3_extended;
Pmatrix4_single = ˆTmatrix4_single ;
Pmatrix4_double = ˆTmatrix4_double ;
Pmatrix4_extended = ˆTmatrix4_extended;
TVector2Single = Tvector2_single_data;
PVector2Single = ˆTVector2Single;
TVector2Double = Tvector2_double_data;
PVector2Double = ˆTVector2Double;
TVector2Extended = Tvector2_extended_data;
PVector2Extended = ˆTVector2Extended;
TVector2Byte = packed array [0..1] of Byte;
PVector2Byte = ˆTVector2Byte;
TVector2Word = packed array [0..1] of Word;
PVector2Word = ˆTVector2Word;
TVector2SmallInt = packed array [0..1] of SmallInt;
PVector2SmallInt = ˆTVector2SmallInt;
TVector2Longint = packed array [0..1] of Longint;
PVector2Longint = ˆTVector2Longint;
TVector2Pointer = packed array [0..1] of Pointer;
PVector2Pointer = ˆTVector2Pointer;
TVector2Cardinal = packed array [0..1] of Cardinal;
PVector2Cardinal = ˆTVector2Cardinal;
TVector2Integer = packed array [0..1] of Integer;
PVector2Integer = ˆTVector2Integer;
TVector3Single = Tvector3_single_data;
PVector3Single = ˆTVector3Single;
TVector3Double = Tvector3_double_data;
PVector3Double = ˆTVector3Double;
TVector3Extended = Tvector3_extended_data;
PVector3Extended = ˆTVector3Extended;
TVector3Byte = packed array [0..2] of Byte;
PVector3Byte = ˆTVector3Byte;
TVector3Word = packed array [0..2] of Word;
PVector3Word = ˆTVector3Word;
TVector3Longint = packed array [0..2] of Longint;
PVector3Longint = ˆTVector3Longint;
TVector3Pointer = packed array [0..2] of Pointer;
PVector3Pointer = ˆTVector3Pointer;
TVector3Integer = packed array [0..2] of Integer;
PVector3Integer = ˆTVector3Integer;
TVector3Cardinal = packed array [0..2] of Cardinal;
PVector3Cardinal = ˆTVector3Cardinal;
TVector4Single = Tvector4_single_data;
PVector4Single = ˆTVector4Single;
TVector4Double = Tvector4_double_data;
PVector4Double = ˆTVector4Double;
TVector4Extended = Tvector4_extended_data;
PVector4Extended = ˆTVector4Extended;
TVector4Byte = packed array [0..3] of Byte;
PVector4Byte = ˆTVector4Byte;
TVector4Word = packed array [0..3] of Word;
PVector4Word = ˆTVector4Word;
TVector4Longint = packed array [0..3] of Longint;
PVector4Longint = ˆTVector4Longint;
TVector4Pointer = packed array [0..3] of Pointer;
PVector4Pointer = ˆTVector4Pointer;
TVector4Cardinal = packed array [0..3] of Cardinal;
PVector4Cardinal = ˆTVector4Cardinal;
TVector4Integer = packed array [0..3] of Integer;
PVector4Integer = ˆTVector4Integer;
TMatrix2Single = Tmatrix2_single_data;
PMatrix2Single = ˆTMatrix2Single;
TMatrix2Double = Tmatrix2_double_data;
PMatrix2Double = ˆTMatrix2Double;
TMatrix2Longint = packed array[0..1]of TVector2Longint;
PMatrix2Longint = ˆTMatrix2Longint;
TMatrix3Single = Tmatrix3_single_data;
PMatrix3Single = ˆTMatrix3Single;
TMatrix3Double = Tmatrix3_double_data;
PMatrix3Double = ˆTMatrix3Double;
TMatrix3Longint = packed array[0..2]of TVector3Longint;
PMatrix3Longint = ˆTMatrix3Longint;
TMatrix4Single = Tmatrix4_single_data;
PMatrix4Single = ˆTMatrix4Single;
TMatrix4Double = Tmatrix4_double_data;
PMatrix4Double = ˆTMatrix4Double;
TMatrix4Longint = packed array[0..3]of TVector4Longint;
PMatrix4Longint = ˆTMatrix4Longint;
TArray_Vector2Byte = packed array [0..MaxInt div SizeOf(TVector2Byte)-1] of TVector2Byte;
PArray_Vector2Byte = ˆTArray_Vector2Byte;
TArray_Vector3Byte = packed array [0..MaxInt div SizeOf(TVector3Byte)-1] of TVector3Byte;
PArray_Vector3Byte = ˆTArray_Vector3Byte;
TArray_Vector4Byte = packed array [0..MaxInt div SizeOf(TVector4Byte)-1] of TVector4Byte;
PArray_Vector4Byte = ˆTArray_Vector4Byte;
TArray_Vector2Cardinal = packed array [0..MaxInt div SizeOf(TVector2Cardinal) - 1] of TVector2Cardinal;
PArray_Vector2Cardinal = ˆTArray_Vector2Cardinal;
TArray_Vector2Extended = packed array [0..MaxInt div SizeOf(TVector2Extended) - 1] of TVector2Extended;
PArray_Vector2Extended = ˆTArray_Vector2Extended;
TArray_Vector2Single = packed array [0..MaxInt div SizeOf(TVector2Single) - 1] of TVector2Single;
PArray_Vector2Single = ˆTArray_Vector2Single;
TArray_Vector3Single = packed array [0..MaxInt div SizeOf(TVector3Single) - 1] of TVector3Single;
PArray_Vector3Single = ˆTArray_Vector3Single;
TArray_Vector4Single = packed array [0..MaxInt div SizeOf(TVector4Single) - 1] of TVector4Single;
PArray_Vector4Single = ˆTArray_Vector4Single;
TVector3CardinalList = specialize TGenericStructList<TVector3Cardinal>;
TVector2SmallIntList = specialize TGenericStructList<TVector2SmallInt>;
TGetVertexFromIndexFunc = function (Index: integer): TVector3Single of object;

Constants

ZeroVector2Integer: TVector2Integer = (0, 0);
ZeroVector2Single: TVector2Single = (0, 0);
ZeroVector2Double: TVector2Double = (0, 0);
ZeroVector3Single: TVector3Single = (0, 0, 0);
ZeroVector3Double: TVector3Double = (0, 0, 0);
ZeroVector4Single: TVector4Single = (0, 0, 0, 0);
ZeroVector4Double: TVector4Double = (0, 0, 0, 0);
ZeroMatrix2Single: TMatrix2Single = ((0, 0), (0, 0));
ZeroMatrix2Double: TMatrix2Double = ((0, 0), (0, 0));
ZeroMatrix2Longint: TMatrix2Longint = ((0, 0), (0, 0));
ZeroMatrix3Single: TMatrix3Single = ((0, 0, 0), (0, 0, 0), (0, 0, 0));
ZeroMatrix3Double: TMatrix3Double = ((0, 0, 0), (0, 0, 0), (0, 0, 0));
ZeroMatrix3Longint: TMatrix3Longint = ((0, 0, 0), (0, 0, 0), (0, 0, 0));
ZeroMatrix4Single: TMatrix4Single = ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0));
ZeroMatrix4Double: TMatrix4Double = ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0));
ZeroMatrix4Longint: TMatrix4Longint = ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0));
IdentityMatrix2Single: TMatrix2Single = ((1, 0), (0, 1));
IdentityMatrix2Double: TMatrix2Double = ((1, 0), (0, 1));
IdentityMatrix2Longint: TMatrix2Longint = ((1, 0), (0, 1));
IdentityMatrix3Single: TMatrix3Single = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
IdentityMatrix3Double: TMatrix3Double = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
IdentityMatrix3Longint: TMatrix3Longint = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
IdentityMatrix4Single: TMatrix4Single = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
IdentityMatrix4Double: TMatrix4Double = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
IdentityMatrix4Longint: TMatrix4Longint = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
UnitVector3Single: array[0..2]of TVector3Single = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
UnitVector3Double: array[0..2]of TVector3Double = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
UnitVector4Single: array[0..3]of TVector4Single = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
UnitVector4Double: array[0..3]of TVector4Double = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));

Variables

SingleEqualityEpsilon: Single = 1e-7;
DoubleEqualityEpsilon: Double = 1e-12;
ExtendedEqualityEpsilon: Extended = 1e-16;
FloatNiceFormat: string = 'f';

Description

Functions and Procedures

function FloatsEqual(const f1, f2: Single): boolean; overload;

Compare two float values, with some epsilon. When two float values differ by less than given epsilon, they are considered equal.

function FloatsEqual(const f1, f2: Double): boolean; overload;
 
function FloatsEqual(const f1, f2, EqEpsilon: Single): boolean; overload;
 
function FloatsEqual(const f1, f2, EqEpsilon: Double): boolean; overload;
 
function Zero(const f1: Single): boolean; overload;

Compare float value with zero, with some epsilon. This is somewhat optimized version of doing FloatsEqual(F1, 0).

This is named Zero, not IsZero — to not collide with IsZero function in Math unit (that has the same purpose, but uses different epsilons by default).

function Zero(const f1: Double): boolean; overload;
 
function Zero(const f1, EqEpsilon: Single ): boolean; overload;
 
function Zero(const f1, EqEpsilon: Double ): boolean; overload;
 
function Vector2Cardinal(const x, y: Cardinal): TVector2Cardinal;
 
function Vector2Integer(const x, y: Integer): TVector2Integer;
 
function Vector2LongInt(const x, y: Longint): TVector2LongInt;
 
function Vector2SmallInt(const x, y: SmallInt): TVector2SmallInt;
 
function Vector2Single(const x, y: Single): TVector2Single; overload;
 
function Vector2Single(const V: TVector2Double): TVector2Single; overload;
 
function Vector2Double(const x, y: Double): TVector2Double;
 
function Vector3Single(const x, y: Single; const z: Single = 0.0): TVector3Single; overload;
 
function Vector3Single(const v3: TVector3Double): TVector3Single; overload;
 
function Vector3Single(const v3: TVector3Byte): TVector3Single; overload;
 
function Vector3Single(const v2: TVector2Single; const z: Single = 0.0): TVector3Single; overload;
 
function Vector3Longint(const p0, p1, p2: Longint): TVector3Longint;
 
function Vector3Double(const x, y: Double; const z: Double = 0.0): TVector3Double; overload;
 
function Vector3Double(const v: TVector3Single): TVector3Double; overload;
 
function Vector3Double(const v2: TVector2Double; const z: Double = 0.0): TVector3Double; overload;
 
function Vector4Single(const x, y: Single; const z: Single = 0; const w: Single = 1): TVector4Single; overload;
 
function Vector4Single(const v3: TVector3Single; const w: Single = 1): TVector4Single; overload;
 
function Vector4Single(const v2: TVector2Single; const z: Single = 0; const w: Single = 1): TVector4Single; overload;
 
function Vector4Single(const ub: TVector4Byte): TVector4Single; overload;
 
function Vector4Single(const V3: TVector3Byte; const W: Byte): TVector4Single; overload;
 
function Vector4Single(const v: TVector4Double): TVector4Single; overload;
 
function Vector4Double(const x, y, z ,w: Double): TVector4Double; overload;
 
function Vector4Double(const v: TVector4Single): TVector4Double; overload;
 
function Vector2Byte(x, y: Byte): TVector2Byte; overload;
 
function Vector3Byte(x, y, z: Byte): TVector3Byte; overload;
 
function Vector3Byte(const v: TVector3Single): TVector3Byte; overload;

Convert float vectors into byte vectors. Each float component is converted such that float 0.0 (or less) results in 0 byte, 1.0 (or more) results in byte 255 (note: not 256). Values between 0.0 and 1.0 are appropriately (linearly) converted into the byte range.

function Vector3Byte(const v: TVector3Double): TVector3Byte; overload;
 
function Vector4Byte(const f4: TVector4Single): TVector4Byte; overload;
 
function Vector4Byte(const x, y, z: Byte; const w: Byte = 255): TVector4Byte; overload;
 
function Vector4Byte(const f3: TVector3Byte; w: Byte): TVector4Byte; overload;
 
function Vector4Integer(const X, Y, Z, W: Integer): TVector4Integer;
 
function Vector3SinglePoint(const v: TVector4Single): TVector3Single;

Convert a point in homogeneous coordinates into normal 3D point. In other words, convert 4D (x, y, z, w) into (x/w, y/w, z/w). Make sure the 4th vector component <> 0.

function Vector2SingleCut(const v: TVector3Single): TVector2Single;

Convert 3D vector into 2D by simply discarding (ignoring) the last component.

function Vector3SingleCut(const v: TVector4Single): TVector3Single;

Convert 4D vector into 3D by simply discarding (ignoring) the 4th vector component.

function Vector3ByteCut(const v: TVector4Byte): TVector3Byte;
 
function Normal3Single(const x, y: Single; const z: Single = 0.0): TVector3Single; overload;

Construct and normalize 3D vector value.

function Vector2SingleFromStr(const S: string): TVector2Single;

Convert string to vector. Each component is simply parsed by StrToFloat, and components must be separated by whitespace (see WhiteSpaces constant).

Exceptions raised
EConvertError
In case of problems during conversion (invalid float or unexpected string end or expected but missed string end).
function Vector3SingleFromStr(const S: string): TVector3Single;
 
function Vector3DoubleFromStr(const S: string): TVector3Double;
 
function Vector3ExtendedFromStr(const S: string): TVector3Extended;
 
function Vector4SingleFromStr(const S: string): TVector4Single;
 
function Matrix2Double(const M: TMatrix2Single): TMatrix2Double;

Convert between single and double precision matrices.

function Matrix2Single(const M: TMatrix2Double): TMatrix2Single;
 
function Matrix3Double(const M: TMatrix3Single): TMatrix3Double;
 
function Matrix3Single(const M: TMatrix3Double): TMatrix3Single;
 
function Matrix4Double(const M: TMatrix4Single): TMatrix4Double;
 
function Matrix4Single(const M: TMatrix4Double): TMatrix4Single;
 
operator := (const V: TVector2_Single): TVector2Single;

Overload := operator to allow conversion between Matrix unit objects and this unit's arrays easy.

operator := (const V: TVector3_Single): TVector3Single;
 
operator := (const V: TVector4_Single): TVector4Single;
 
operator := (const V: TVector2Single): TVector2_Single;
 
operator := (const V: TVector3Single): TVector3_Single;
 
operator := (const V: TVector4Single): TVector4_Single;
 
function SwapEndian(const V: TVector2Single): TVector2Single; overload;

Endianess utility functions for vectors ———————————–

function SwapEndian(const V: TVector2Double): TVector2Double; overload;
 
function SwapEndian(const V: TVector3Single): TVector3Single; overload;
 
function SwapEndian(const V: TVector3Double): TVector3Double; overload;
 
function SwapEndian(const V: TVector4Single): TVector4Single; overload;
 
function SwapEndian(const V: TVector4Double): TVector4Double; overload;
 
function LEtoN(const V: TVector2Single): TVector2Single; overload;
 
function LEtoN(const V: TVector2Double): TVector2Double; overload;
 
function LEtoN(const V: TVector3Single): TVector3Single; overload;
 
function LEtoN(const V: TVector3Double): TVector3Double; overload;
 
function LEtoN(const V: TVector4Single): TVector4Single; overload;
 
function LEtoN(const V: TVector4Double): TVector4Double; overload;
 
function BEtoN(const V: TVector2Single): TVector2Single; overload;
 
function BEtoN(const V: TVector2Double): TVector2Double; overload;
 
function BEtoN(const V: TVector3Single): TVector3Single; overload;
 
function BEtoN(const V: TVector3Double): TVector3Double; overload;
 
function BEtoN(const V: TVector4Single): TVector4Single; overload;
 
function BEtoN(const V: TVector4Double): TVector4Double; overload;
 
function NtoLE(const V: TVector2Single): TVector2Single; overload;
 
function NtoLE(const V: TVector2Double): TVector2Double; overload;
 
function NtoLE(const V: TVector3Single): TVector3Single; overload;
 
function NtoLE(const V: TVector3Double): TVector3Double; overload;
 
function NtoLE(const V: TVector4Single): TVector4Single; overload;
 
function NtoLE(const V: TVector4Double): TVector4Double; overload;
 
function NtoBE(const V: TVector2Single): TVector2Single; overload;
 
function NtoBE(const V: TVector2Double): TVector2Double; overload;
 
function NtoBE(const V: TVector3Single): TVector3Single; overload;
 
function NtoBE(const V: TVector3Double): TVector3Double; overload;
 
function NtoBE(const V: TVector4Single): TVector4Single; overload;
 
function NtoBE(const V: TVector4Double): TVector4Double; overload;
 
procedure SwapValues(var V1, V2: TVector2Single); overload;
 
procedure SwapValues(var V1, V2: TVector2Double); overload;
 
procedure SwapValues(var V1, V2: TVector3Single); overload;
 
procedure SwapValues(var V1, V2: TVector3Double); overload;
 
procedure SwapValues(var V1, V2: TVector4Single); overload;
 
procedure SwapValues(var V1, V2: TVector4Double); overload;
 
function VectorAverage(const V: TVector3Single): Single; overload;
 
function VectorAverage(const V: TVector3Double): Double; overload;
 
function Approximate3DScale(const X, Y, Z: Single): Single;

When you really, really must approximate a 3D scale by a single float. If your algorithm cannot handle non-uniform 3D scale, you have to approximate 3D scale by a single float.

This is similar to an average of X, Y, Z, but it additionally secures in case some of X, Y, Z are negative and some are positive (like scale (-1, 1), common in 2D to flip horizontally).

function Approximate3DScale(const V: TVector3Single): Single;
 
function Lerp(const A: Single; const V1, V2: TVector2Byte): TVector2Byte; overload;

Linear interpolation between two vector values. Returns (1-A) * V1 + A * V2 (well, calculated a little differently for speed). So A = 0 gives V1, A = 1 gives V2, and values between and around are interpolated.

function Lerp(const A: Single; const V1, V2: TVector3Byte): TVector3Byte; overload;
 
function Lerp(const A: Single; const V1, V2: TVector4Byte): TVector4Byte; overload;
 
function Lerp(const A: Single; const V1, V2: TVector2Integer): TVector2Single; overload;
 
function Lerp(const A: Single; const V1, V2: TVector2Single): TVector2Single; overload;
 
function Lerp(const A: Single; const V1, V2: TVector3Single): TVector3Single; overload;
 
function Lerp(const A: Single; const V1, V2: TVector4Single): TVector4Single; overload;
 
function Lerp(const A: Double; const V1, V2: TVector2Double): TVector2Double; overload;
 
function Lerp(const A: Double; const V1, V2: TVector3Double): TVector3Double; overload;
 
function Lerp(const A: Double; const V1, V2: TVector4Double): TVector4Double; overload;
 
function Lerp(const A: Single; const M1, M2: TMatrix3Single): TMatrix3Single; overload;
 
function Lerp(const A: Single; const M1, M2: TMatrix4Single): TMatrix4Single; overload;
 
function Lerp(const A: Double; const M1, M2: TMatrix3Double): TMatrix3Double; overload;
 
function Lerp(const A: Double; const M1, M2: TMatrix4Double): TMatrix4Double; overload;
 
function Vector_Init_Lerp(const A: Single; const V1, V2: TVector3_Single): TVector3_Single; overload;
 
function Vector_Init_Lerp(const A: Single; const V1, V2: TVector4_Single): TVector4_Single; overload;
 
function Vector_Init_Lerp(const A: Double; const V1, V2: TVector3_Double): TVector3_Double; overload;
 
function Vector_Init_Lerp(const A: Double; const V1, V2: TVector4_Double): TVector4_Double; overload;
 
procedure NormalizeVar3Singlev(vv: PVector3Single);

Normalize the first 3 vector components. For zero vectors, does nothing.

procedure NormalizeVar3Bytev(vv: PVector3Byte);
 
procedure NormalizeVar(var v: TVector2Single); overload;
 
procedure NormalizeVar(var v: TVector2Double); overload;
 
procedure NormalizeVar(var v: TVector3Single); overload;
 
procedure NormalizeVar(var v: TVector3Double); overload;
 
function Normalized(const v: TVector2Single): TVector2Single; overload;
 
function Normalized(const v: TVector2Double): TVector2Double; overload;
 
function Normalized(const v: TVector3Single): TVector3Single; overload;
 
function Normalized(const v: TVector3Double): TVector3Double; overload;
 
function Vector_Get_Normalized(const V: TVector3_Single): TVector3_Single; overload;
 
function Vector_Get_Normalized(const V: TVector3_Double): TVector3_Double; overload;
 
procedure Vector_Normalize(var V: TVector3_Single); overload;
 
procedure Vector_Normalize(var V: TVector3_Double); overload;
 
procedure NormalizePlaneVar(var v: TVector4Single); overload;

This normalizes Plane by scaling all four coordinates of Plane so that length of plane vector (taken from 1st three coordinates) is one.

Also, contrary to normal NormalizeVar on 3-component vectors, this will fail with some awful error (like floating point overflow) in case length of plane vector is zero. That's because we know that plane vector must be always non-zero.

procedure NormalizePlaneVar(var v: TVector4Double); overload;
 
function ZeroVector(const v: TVector2Single): boolean; overload;
 
function ZeroVector(const v: TVector2Double): boolean; overload;
 
function ZeroVector(const v: TVector3Single): boolean; overload;
 
function ZeroVector(const v: TVector3Double): boolean; overload;
 
function ZeroVector(const v: TVector4Single): boolean; overload;
 
function ZeroVector(const v: TVector4Double): boolean; overload;
 
function ZeroVector(const v: TVector2Single; const EqualityEpsilon: Single): boolean; overload;
 
function ZeroVector(const v: TVector2Double; const EqualityEpsilon: Double): boolean; overload;
 
function ZeroVector(const v: TVector3Single; const EqualityEpsilon: Single): boolean; overload;
 
function ZeroVector(const v: TVector3Double; const EqualityEpsilon: Double): boolean; overload;
 
function ZeroVector(const v: TVector4Single; const EqualityEpsilon: Single): boolean; overload;
 
function ZeroVector(const v: TVector4Double; const EqualityEpsilon: Double): boolean; overload;
 
function ZeroVector(const v: TVector4Integer): boolean; overload;
 
function ZeroVector(const v: TVector4Cardinal): boolean; overload;
 
function PerfectlyZeroVector(const v: TVector2Single): boolean; overload;
 
function PerfectlyZeroVector(const v: TVector2Double): boolean; overload;
 
function PerfectlyZeroVector(const v: TVector3Single): boolean; overload;
 
function PerfectlyZeroVector(const v: TVector3Double): boolean; overload;
 
function PerfectlyZeroVector(const v: TVector4Single): boolean; overload;
 
function PerfectlyZeroVector(const v: TVector4Double): boolean; overload;
 
function VectorSubtract(const V1, V2: TVector2Single): TVector2Single; overload;

Subtract two vectors.

Versions *Var place result back into the 1st vector, like "-=" operator. Are very very slightly faster.

function VectorSubtract(const V1, V2: TVector2Double): TVector2Double; overload;
 
function VectorSubtract(const V1, V2: TVector3Single): TVector3Single; overload;
 
function VectorSubtract(const V1, V2: TVector3Double): TVector3Double; overload;
 
function VectorSubtract(const V1, V2: TVector4Single): TVector4Single; overload;
 
function VectorSubtract(const V1, V2: TVector4Double): TVector4Double; overload;
 
procedure VectorSubtractVar(var v1: TVector2Single; const v2: TVector2Single); overload;
 
procedure VectorSubtractVar(var v1: TVector2Double; const v2: TVector2Double); overload;
 
procedure VectorSubtractVar(var v1: TVector3Single; const v2: TVector3Single); overload;
 
procedure VectorSubtractVar(var v1: TVector3Double; const v2: TVector3Double); overload;
 
procedure VectorSubtractVar(var v1: TVector4Single; const v2: TVector4Single); overload;
 
procedure VectorSubtractVar(var v1: TVector4Double; const v2: TVector4Double); overload;
 
function VectorAdd(const V1, V2: TVector2Single): TVector2Single; overload;

Add two vectors.

Versions *Var place result back into the 1st vector, like "+=" operator. Are very very slightly faster.

function VectorAdd(const V1, V2: TVector2Double): TVector2Double; overload;
 
function VectorAdd(const V1, V2: TVector3Single): TVector3Single; overload;
 
function VectorAdd(const V1, V2: TVector3Double): TVector3Double; overload;
 
function VectorAdd(const V1, V2: TVector4Single): TVector4Single; overload;
 
function VectorAdd(const V1, V2: TVector4Double): TVector4Double; overload;
 
procedure VectorAddVar(var v1: TVector2Single; const v2: TVector2Single); overload;
 
procedure VectorAddVar(var v1: TVector2Double; const v2: TVector2Double); overload;
 
procedure VectorAddVar(var v1: TVector3Single; const v2: TVector3Single); overload;
 
procedure VectorAddVar(var v1: TVector3Double; const v2: TVector3Double); overload;
 
procedure VectorAddVar(var v1: TVector4Single; const v2: TVector4Single); overload;
 
procedure VectorAddVar(var v1: TVector4Double; const v2: TVector4Double); overload;
 
function VectorScale(const v1: TVector2Single; const Scalar: Single): TVector2Single; overload;

Scale vector (aka multiply by scalar).

Versions *Var scale place result back into the 1st vector, like "*=" operator. Are very very slightly faster.

function VectorScale(const v1: TVector2Double; const Scalar: Double): TVector2Double; overload;
 
function VectorScale(const v1: TVector3Single; const Scalar: Single): TVector3Single; overload;
 
function VectorScale(const v1: TVector3Double; const Scalar: Double): TVector3Double; overload;
 
function VectorScale(const v1: TVector4Single; const Scalar: Single): TVector4Single; overload;
 
function VectorScale(const v1: TVector4Double; const Scalar: Double): TVector4Double; overload;
 
procedure VectorScaleVar(var v1: TVector2Single; const Scalar: Single); overload;
 
procedure VectorScaleVar(var v1: TVector2Double; const Scalar: Double); overload;
 
procedure VectorScaleVar(var v1: TVector3Single; const Scalar: Single); overload;
 
procedure VectorScaleVar(var v1: TVector3Double; const Scalar: Double); overload;
 
procedure VectorScaleVar(var v1: TVector4Single; const Scalar: Single); overload;
 
procedure VectorScaleVar(var v1: TVector4Double; const Scalar: Double); overload;
 
function VectorNegate(const v: TVector2Single): TVector2Single; overload;

Negate vector (return -V).

Versions *Var scale place result back into the 1st vector. Are very very slightly faster.

function VectorNegate(const v: TVector2Double): TVector2Double; overload;
 
function VectorNegate(const v: TVector3Single): TVector3Single; overload;
 
function VectorNegate(const v: TVector3Double): TVector3Double; overload;
 
function VectorNegate(const v: TVector4Single): TVector4Single; overload;
 
function VectorNegate(const v: TVector4Double): TVector4Double; overload;
 
procedure VectorNegateVar(var v: TVector2Single); overload;
 
procedure VectorNegateVar(var v: TVector2Double); overload;
 
procedure VectorNegateVar(var v: TVector3Single); overload;
 
procedure VectorNegateVar(var v: TVector3Double); overload;
 
procedure VectorNegateVar(var v: TVector4Single); overload;
 
procedure VectorNegateVar(var v: TVector4Double); overload;
 
function VectorAdjustToLength(const v: TVector2Single; VecLen: Single): TVector2Single; overload;

Scale vector such that it has given length (VecLen). Given VecLen may be negative, then we'll additionally negate the vector.

function VectorAdjustToLength(const v: TVector3Single; VecLen: Single): TVector3Single; overload;
 
function VectorAdjustToLength(const v: TVector3Double; VecLen: Double): TVector3Double; overload;
 
procedure VectorAdjustToLengthVar(var v: TVector2Single; VecLen: Single); overload;
 
procedure VectorAdjustToLengthVar(var v: TVector3Single; VecLen: Single); overload;
 
procedure VectorAdjustToLengthVar(var v: TVector3Double; VecLen: Double); overload;
 
function VectorLen(const v: TVector2Single): Single; overload;

Vector length.

function VectorLen(const v: TVector2Double): Double; overload;
 
function VectorLen(const v: TVector3Single): Single; overload;
 
function VectorLen(const v: TVector3Double): Double; overload;
 
function VectorLen(const v: TVector3Byte): Single; overload;
 
function VectorLen(const v: TVector4Single): Single; overload;
 
function VectorLen(const v: TVector4Double): Double; overload;
 
function VectorLenSqr(const v: TVector2Single): Single; overload;

Vector length squared.

This is slightly faster than calculating actual vector length, as it avoids doing expensive Sqrt. In many cases, you can operate on such squared vector length, and thus you gain some speed. For example, to check if vector is longer than 10, check VectorLenSqr(V) > 100 instead of VectorLen(V) > 10.

Also note that when you have a vector with discrete values (like TVector3Byte), VectorLenSqr returns a precide integer value, while VectorLen must return floating-point value.

function VectorLenSqr(const v: TVector2Double): Double; overload;
 
function VectorLenSqr(const v: TVector3Single): Single; overload;
 
function VectorLenSqr(const v: TVector3Double): Double; overload;
 
function VectorLenSqr(const v: TVector3Byte): Integer; overload;
 
function VectorLenSqr(const v: TVector4Single): Single; overload;
 
function VectorLenSqr(const v: TVector4Double): Double; overload;
 
function VectorProduct(const V1, V2: TVector3Double): TVector3Double; overload;

Vector cross product.

This is a vector orthogonal to both given vectors. Generally there are two such vectors, this function returns the one following right-hand rule. More precisely, V1, V2 and VectorProduct(V1, V2) are in the same relation as basic X, Y, Z axes. Reverse the order of arguments to get negated result.

If you use this to calculate a normal vector of a triangle (P0, P1, P2): note that VectorProduct(P1 - P0, P1 - P2) points out from CCW triangle side in right-handed coordinate system.

When V1 and V2 are parallel (that is, when V1 = V2 multiplied by some scalar), and this includes the case when one of them is zero, then result is a zero vector.

See http://en.wikipedia.org/wiki/Cross_product

function VectorProduct(const V1, V2: TVector3Single): TVector3Single; overload;
 
function VectorDotProduct(const V1, V2: TVector2Single): Single; overload;

Dot product (aka scalar product) of two vectors.

Overloaded versions that take as one argument 3-component vector and as the second argument 4-component vector: they simply behave like the missing 4th component would be equal 1.0. This is useful when V1 is a 3D point and V2 is something like plane equation.

function VectorDotProduct(const V1, V2: TVector2Double): Double; overload;
 
function VectorDotProduct(const V1, V2: TVector3Single): Single; overload;
 
function VectorDotProduct(const V1, V2: TVector3Double): Double; overload;
 
function VectorDotProduct(const V1, V2: TVector4Single): Single; overload;
 
function VectorDotProduct(const V1, V2: TVector4Double): Double; overload;
 
function VectorDotProduct(const v1: TVector3Single; const v2: TVector4Single): Single; overload;
 
function VectorDotProduct(const v1: TVector3Double; const v2: TVector4Double): Double; overload;
 
function VectorMultiplyComponents(const V1, V2: TVector3Single): TVector3Single; overload;

Multiply two vectors component-wise. That is, Result[I] := V1[I] * V2[I] for each I.

function VectorMultiplyComponents(const V1, V2: TVector3Double): TVector3Double; overload;
 
procedure VectorMultiplyComponentsVar(var v1: TVector3Single; const v2: TVector3Single); overload;
 
procedure VectorMultiplyComponentsVar(var v1: TVector3Double; const v2: TVector3Double); overload;
 
function VectorPowerComponents(const v: TVector3Single; const Exp: Single): TVector3Single; overload;

Change each vector component into Power(component, Exp).

Exceptions raised
EInvalidArgument
When some component is < 0 and Exp <> 0. Version VectorPowerComponentsVar leaves the V in undefined state in case of such exception.
function VectorPowerComponents(const v: TVector3Double; const Exp: Double): TVector3Double; overload;
 
procedure VectorPowerComponentsVar(var v: TVector3Single; const Exp: Single); overload;
 
procedure VectorPowerComponentsVar(var v: TVector3Double; const Exp: Double); overload;
 
function CosAngleBetweenVectors(const V1, V2: TVector3Single): Single; overload;

Cosinus of angle between two vectors.

CosAngleBetweenNormals is a little faster, but must receive normalized (length 1) vectors. This avoids expensive Sqrt inside CosAngleBetweenVectors.

Exceptions raised
EVectorInvalidOp
If V1 or V2 is zero.
function CosAngleBetweenVectors(const V1, V2: TVector3Double): Double; overload;
 
function CosAngleBetweenNormals(const V1, V2: TVector3Single): Single; overload;
 
function CosAngleBetweenNormals(const V1, V2: TVector3Double): Double; overload;
 
function AngleRadBetweenVectors(const V1, V2: TVector3Single): Single; overload;

Angle between two vectors, in radians. Returns always positive angle, between 0 and Pi.

AngleRadBetweenNormals is a little faster, but must receive normalized (length 1) vectors. This avoids expensive Sqrt. See also CosAngleBetweenVectors and CosAngleBetweenNormals to avoid expensive ArcCos.

Exceptions raised
EVectorInvalidOp
If V1 or V2 is zero.
function AngleRadBetweenVectors(const V1, V2: TVector3Double): Double; overload;
 
function AngleRadBetweenNormals(const V1, V2: TVector3Single): Single; overload;
 
function AngleRadBetweenNormals(const V1, V2: TVector3Double): Double; overload;
 
function RotationAngleRadBetweenVectors(const V1, V2: TVector3Single): Single; overload;

Signed angle between two vectors, in radians. As opposed to AngleRadBetweenNormals, this returns a signed angle, between -Pi and Pi. This is guaranteed to be such angle that rotating V1 around vector cross product (V1 x V2) will produce V2. As you see, the order or arguments is important (just like it's important for vector cross).

Overloaded versions with Cross argument assume the rotation is done around given Cross vector, which must be a cross product or it's negation (in other words, it must be orthogonal to both vectors).

Exceptions raised
EVectorInvalidOp
If V1 or V2 is zero.
function RotationAngleRadBetweenVectors(const V1, V2: TVector3Double): Double; overload;
 
function RotationAngleRadBetweenVectors(const V1, V2, Cross: TVector3Single): Single; overload;
 
function RotationAngleRadBetweenVectors(const V1, V2, Cross: TVector3Double): Double; overload;
 
function RotatePointAroundAxisDeg(Angle: Single; const Point: TVector3Single; const Axis: TVector3Single): TVector3Single; overload;

Rotate point Point around the Axis by given Angle. Axis cannot be zero.

Note that this is equivalent to constructing a rotation matrix and then using it, like

M := RotationMatrixDeg(Angle, Axis);
Result := MatrixMultPoint(M, Point);

Except this will be a little faster. So rotations are done in the same direction as RotationMatrixDeg, and as OpenGL.

function RotatePointAroundAxisDeg(Angle: Double; const Point: TVector3Double; const Axis: TVector3Double): TVector3Double; overload;
 
function RotatePointAroundAxisRad(Angle: Single; const Point: TVector3Single; const Axis: TVector3Single): TVector3Single; overload;
 
function RotatePointAroundAxisRad(Angle: Double; const Point: TVector3Double; const Axis: TVector3Double): TVector3Double; overload;
 
function RotationNegate(const Rotation: TVector4Single): TVector4Single;

Negate a rotation expressed as axis-angle (3 components for axis, 1 for angle). This simply negates the 4th vector component.

function RotatePoint2D(const Point: TVector2Single; const AngleRad: Single): TVector2Single;

Rotate point in 2D, in a counter-clockwise fashion. AngleRad is in radians.

function MaxVectorCoord(const v: TVector2Single): integer; overload;

Which coordinate (0, 1, 2, and eventually 3 for 4D versions) is the largest. When the vector components are equal, the first one "wins", for example if V[0] = V[1] (and are larger than other vector component) we return 0. MaxAbsVectorCoord compares the absolute value of components.

function MaxVectorCoord(const v: TVector2Double): integer; overload;
 
function MaxVectorCoord(const v: TVector3Single): integer; overload;
 
function MaxVectorCoord(const v: TVector3Double): integer; overload;
 
function MaxVectorCoord(const v: TVector4Single): integer; overload;
 
function MaxVectorCoord(const v: TVector4Double): integer; overload;
 
function MaxAbsVectorCoord(const v: TVector2Single): integer; overload;
 
function MaxAbsVectorCoord(const v: TVector2Double): integer; overload;
 
function MaxAbsVectorCoord(const v: TVector3Single): integer; overload;
 
function MaxAbsVectorCoord(const v: TVector3Double): integer; overload;
 
function VectorAbs(const V: TVector2Single): TVector2Single;
 
function VectorAbs(const V: TVector2Double): TVector2Double;
 
function VectorAbs(const V: TVector3Single): TVector3Single;
 
function VectorAbs(const V: TVector3Double): TVector3Double;
 
function VectorAbs(const V: TVector4Single): TVector4Single;
 
function VectorAbs(const V: TVector4Double): TVector4Double;
 
function MinVectorCoord(const v: TVector3Single): integer; overload;
 
function MinVectorCoord(const v: TVector3Double): integer; overload;
 
procedure SortAbsVectorCoord(const v: TVector3Single; out Max, Middle, Min: Integer); overload;
 
procedure SortAbsVectorCoord(const v: TVector3Double; out Max, Middle, Min: Integer); overload;
 
function PlaneDirInDirection(const Plane: TVector4Single; const Direction: TVector3Single): TVector3Single; overload;

Vector orthogonal to plane and pointing in the given direction.

Given a plane equation (or just the first 3 components of this equation), we have vector orthogonal to the plane (just the first 3 components of plane equation). This returns either this vector, or it's negation. It chooses the one that points in the same 3D half-space as given Direction.

When given Direction is paralell to Plane, returns original plane direction, not it's negation.

This really simply returns the first 3 components of plane equation. possibly negated. So e.g. if the plane direction was normalized, result is normalized too.

PlaneDirNotInDirection chooses the direction opposite to given Direction parameter. So it's like PlaneDirInDirection(Plane, -Direction).

function PlaneDirInDirection(const PlaneDir, Direction: TVector3Single): TVector3Single; overload;
 
function PlaneDirInDirection(const Plane: TVector4Double; const Direction: TVector3Double): TVector3Double; overload;
 
function PlaneDirInDirection(const PlaneDir, Direction: TVector3Double): TVector3Double; overload;
 
function PlaneDirNotInDirection(const Plane: TVector4Single; const Direction: TVector3Single): TVector3Single; overload;
 
function PlaneDirNotInDirection(const PlaneDir, Direction: TVector3Single): TVector3Single; overload;
 
function PlaneDirNotInDirection(const Plane: TVector4Double; const Direction: TVector3Double): TVector3Double; overload;
 
function PlaneDirNotInDirection(const PlaneDir, Direction: TVector3Double): TVector3Double; overload;
 
procedure TwoPlanesIntersectionLine(const Plane0, Plane1: TVector4Single; out Line0, LineVector: TVector3Single); overload;

Intersection of two 3D planes.

Exceptions raised
EPlanesParallel
If planes are parallel.
procedure TwoPlanesIntersectionLine(const Plane0, Plane1: TVector4Double; out Line0, LineVector: TVector3Double); overload;
 
function Lines2DIntersection(const Line0, Line1: TVector3Single): TVector2Single; overload;

Intersection of two 2D lines. 2D lines are expressed here as a vector of three values (A,B,C), such that Ax+By+C=0 is true for points on the line.

Exceptions raised
ELinesParallel
if lines parallel
function Lines2DIntersection(const Line0, Line1: TVector3Double): TVector2Double; overload;
 
function ThreePlanesIntersectionPoint( const Plane0, Plane1, Plane2: TVector4Single): TVector3Single; overload;

Intersection of three 3D planes, results in a single 3D point. If the intersection is not a single 3D point, result is undefined, so don't try to use this.

function ThreePlanesIntersectionPoint( const Plane0, Plane1, Plane2: TVector4Double): TVector3Double; overload;
 
function PlaneMove(const Plane: TVector4Single; const Move: TVector3Single): TVector4Single; overload;

Move a plane by a specifed vector. The first three plane numbers (plane normal vector) don't change (so, in particular, if you used the plane to define the half-space, the half-space gets moved as it should).

PlaneAntiMove work like PlaneMove, but they translate by negated Move So it's like PlaneAntiMove(Plane, V) := PlaneMove(Plane, -V), but (very slightly) faster.

This works Ok with invalid planes (1st three components = 0), that is after the move the plane remains invalid (1st three components remain = 0).

function PlaneMove(const Plane: TVector4Double; const Move: TVector3Double): TVector4Double; overload;
 
procedure PlaneMoveVar(var Plane: TVector4Single; const Move: TVector3Single); overload;
 
procedure PlaneMoveVar(var Plane: TVector4Double; const Move: TVector3Double); overload;
 
function PlaneAntiMove(const Plane: TVector4Single; const Move: TVector3Single): TVector4Single; overload;
 
function PlaneAntiMove(const Plane: TVector4Double; const Move: TVector3Double): TVector4Double; overload;
 
function VectorsSamePlaneDirections(const V1, V2: TVector3Single; const Plane: TVector4Single): boolean; overload;

Check if both directions indicate the same side of given 3D plane. If one direction is parallel to the plane, also returns True. You can specify only the first 3 components of plane equation (PlaneDir), since the 4th component would be ignored anyway.

function VectorsSamePlaneDirections(const V1, V2: TVector3Double; const Plane: TVector4Double): boolean; overload;
 
function VectorsSamePlaneDirections(const V1, V2: TVector3Single; const PlaneDir: TVector3Single): boolean; overload;
 
function VectorsSamePlaneDirections(const V1, V2: TVector3Double; const PlaneDir: TVector3Double): boolean; overload;
 
function PointsSamePlaneSides(const p1, p2: TVector3Single; const Plane: TVector4Single): boolean; overload;

Check if both points are on the same side of given 3D plane. If one of the points is exactly on the plane, also returns True.

function PointsSamePlaneSides(const p1, p2: TVector3Double; const Plane: TVector4Double): boolean; overload;
 
function PointsDistance(const V1, V2: TVector2Single): Single; overload;
 
function PointsDistance(const V1, V2: TVector2Double): Double; overload;
 
function PointsDistance(const V1, V2: TVector3Single): Single; overload;
 
function PointsDistance(const V1, V2: TVector3Double): Double; overload;
 
function PointsDistanceSqr(const V1, V2: TVector3Single): Single; overload;
 
function PointsDistanceSqr(const V1, V2: TVector3Double): Double; overload;
 
function PointsDistanceSqr(const V1, V2: TVector2Single): Single; overload;
 
function PointsDistanceSqr(const V1, V2: TVector2Double): Double; overload;
 
function PointsDistance2DSqr(const V1, V2: TVector3Single; const IgnoreIndex: Integer): Single; overload;

Distance between points projected on the 2D plane. Projection is done by rejecting IgnoreIndex coordinate (must be 0, 1 or 2).

function PointsDistance2DSqr(const V1, V2: TVector3Double; const IgnoreIndex: Integer): Double; overload;
 
function VectorsEqual(const V1, V2: TVector2Single): boolean; overload;

Compare two vectors, with epsilon to tolerate slightly different floats. Uses singleEqualityEpsilon, DoubleEqualityEpsilon just like FloatsEqual.

Note that the case when EqualityEpsilon (or SingleEqualityEpsilon or DoubleEqualityEpsilon) is exactly 0 is optimized here, just like VectorsPerfectlyEqual.

See also
VectorsPerfectlyEqual
function VectorsEqual(const V1, V2: TVector2Double): boolean; overload;
 
function VectorsEqual(const V1, V2: TVector2Single; const EqualityEpsilon: Single): boolean; overload;
 
function VectorsEqual(const V1, V2: TVector2Double; const EqualityEpsilon: Double): boolean; overload;
 
function VectorsEqual(const V1, V2: TVector3Single): boolean; overload;
 
function VectorsEqual(const V1, V2: TVector3Double): boolean; overload;
 
function VectorsEqual(const V1, V2: TVector3Single; const EqualityEpsilon: Single): boolean; overload;
 
function VectorsEqual(const V1, V2: TVector3Double; const EqualityEpsilon: Double): boolean; overload;
 
function VectorsEqual(const V1, V2: TVector4Single): boolean; overload;
 
function VectorsEqual(const V1, V2: TVector4Double): boolean; overload;
 
function VectorsEqual(const V1, V2: TVector4Single; const EqualityEpsilon: Single): boolean; overload;
 
function VectorsEqual(const V1, V2: TVector4Double; const EqualityEpsilon: Double): boolean; overload;
 
function VectorsPerfectlyEqual(const V1, V2: TVector2Single): boolean; overload; inline;

Compare two vectors using perfect comparison, that is using the "=" operator to compare floats.

See also
VectorsEqual
function VectorsPerfectlyEqual(const V1, V2: TVector2Double): boolean; overload; inline;
 
function VectorsPerfectlyEqual(const V1, V2: TVector3Single): boolean; overload; inline;
 
function VectorsPerfectlyEqual(const V1, V2: TVector3Double): boolean; overload; inline;
 
function VectorsPerfectlyEqual(const V1, V2: TVector4Single): boolean; overload; inline;
 
function VectorsPerfectlyEqual(const V1, V2: TVector4Double): boolean; overload; inline;
 
function VectorsPerfectlyEqual(const V1, V2: TVector2Byte ): boolean; overload; inline;
 
function VectorsPerfectlyEqual(const V1, V2: TVector3Byte ): boolean; overload; inline;
 
function VectorsPerfectlyEqual(const V1, V2: TVector4Byte ): boolean; overload; inline;
 
function MatricesEqual(const M1, M2: TMatrix3Single; const EqualityEpsilon: Single): boolean; overload;
 
function MatricesEqual(const M1, M2: TMatrix3Double; const EqualityEpsilon: Double): boolean; overload;
 
function MatricesEqual(const M1, M2: TMatrix4Single; const EqualityEpsilon: Single): boolean; overload;
 
function MatricesEqual(const M1, M2: TMatrix4Double; const EqualityEpsilon: Double): boolean; overload;
 
function MatricesPerfectlyEqual(const M1, M2: TMatrix3Single): boolean; overload;
 
function MatricesPerfectlyEqual(const M1, M2: TMatrix3Double): boolean; overload;
 
function MatricesPerfectlyEqual(const M1, M2: TMatrix4Single): boolean; overload;
 
function MatricesPerfectlyEqual(const M1, M2: TMatrix4Double): boolean; overload;
 
function VectorsPerp(const V1, V2: TVector3Single): boolean; overload;
 
function VectorsPerp(const V1, V2: TVector3Double): boolean; overload;
 
function VectorsParallel(const V1, V2: TVector3Single): boolean; overload;

Are the two vectors parallel (one is a scaled version of another). In particular, if one of the vectors is zero, then this is True.

function VectorsParallel(const V1, V2: TVector3Double): boolean; overload;
 
procedure MakeVectorsAngleRadOnTheirPlane(var v1: TVector3Single; const v2: TVector3Single; const AngleRad: Single; const ResultWhenParallel: TVector3Single); overload;

Adjust the V1 vector to force given angle between V1 and V2. Vector V1 will be adjusted, such that it has the same length and the 3D plane defined by V1, V2 and (0, 0, 0) is the same.

When vectors are parallel (this includes the case when one of them is zero), we set V1 to ResultWhenParallel.

We make it such that V1 rotated around axis VectorProduct(V1, V2) by given angle will result in V2. Note that this means that MakeVectorsAngleRadOnTheirPlane(V1, V2, Angle, ...) results in the same (not reversed) relation between vectors as MakeVectorsAngleRadOnTheirPlane(V2, V1, Angle, ...). That's because you change the arguments order, but also VectorProduct sign changes.

procedure MakeVectorsAngleRadOnTheirPlane(var v1: TVector3Double; const v2: TVector3Double; const AngleRad: Double; const ResultWhenParallel: TVector3Double); overload;
 
procedure MakeVectorsOrthoOnTheirPlane(var v1: TVector3Single; const v2: TVector3Single); overload;

Adjust the V1 vector to force V1 and V2 to be orthogonal. When vectors are parallel, we set V1 to be AnyOrthogonalVector(V2).

procedure MakeVectorsOrthoOnTheirPlane(var v1: TVector3Double; const v2: TVector3Double); overload;
 
function AnyOrthogonalVector(const v: TVector2Single): TVector2Single; overload;

Return, deterministically, some vector orthogonal to V. When V is non-zero, then the result is non-zero.

function AnyOrthogonalVector(const v: TVector2Double): TVector2Double; overload;
 
function AnyOrthogonalVector(const v: TVector3Single): TVector3Single; overload;
 
function AnyOrthogonalVector(const v: TVector3Double): TVector3Double; overload;
 
function IsLineParallelToPlane(const lineVector: TVector3Single; const plane: TVector4Single): boolean; overload;
 
function IsLineParallelToPlane(const lineVector: TVector3Double; const plane: TVector4Double): boolean; overload;
 
function IsLineParallelToSimplePlane(const lineVector: TVector3Single; const PlaneConstCoord: integer): boolean; overload;
 
function IsLineParallelToSimplePlane(const lineVector: TVector3Double; const PlaneConstCoord: integer): boolean; overload;
 
function AreParallelVectorsSameDirection( const Vector1, Vector2: TVector3Single): boolean; overload;

Assuming that Vector1 and Vector2 are parallel, check do they point in the same direction.

This assumes that both vectors are non-zero. If one of the vectors is zero, the result is undefined — false or true. (but the function will surely not raise some floating point error etc.)

function AreParallelVectorsSameDirection( const Vector1, Vector2: TVector3Double): boolean; overload;
 
function PointOnPlaneClosestToPoint(const plane: TVector4Single; const point: TVector3Single): TVector3Single; overload;

Orthogonally project a point on a plane, that is find a closest point to Point lying on a Plane.

function PointOnPlaneClosestToPoint(const plane: TVector4Double; const point: TVector3Double): TVector3Double; overload;
 
function PointToPlaneDistanceSqr(const Point: TVector3Single; const Plane: TVector4Single): Single; overload;
 
function PointToPlaneDistanceSqr(const Point: TVector3Double; const Plane: TVector4Double): Double; overload;
 
function PointToNormalizedPlaneDistance(const Point: TVector3Single; const Plane: TVector4Single): Single; overload;

Distance from a point to a plane (with already normalized direction).

Note: distance of the plane from origin point (0,0,0) may be simply obtained by Abs(Plane[3]) when Plane is Normalized.

function PointToNormalizedPlaneDistance(const Point: TVector3Double; const Plane: TVector4Double): Double; overload;
 
function PointToPlaneDistance(const Point: TVector3Single; const Plane: TVector4Single): Single; overload;

Distance from a point to a plane.

Note that calculating this costs you one Sqrt (contrary to PointToPlaneDistanceSqr or PointToNormalizedPlaneDistance).

function PointToPlaneDistance(const Point: TVector3Double; const Plane: TVector4Double): Double; overload;
 
function PointToSimplePlaneDistance(const point: TVector3Single; const PlaneConstCoord: integer; const PlaneConstValue: Single): Single; overload;
 
function PointToSimplePlaneDistance(const point: TVector3Double; const PlaneConstCoord: integer; const PlaneConstValue: Double): Double; overload;
 
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector3Single): TVector3Single; overload;
 
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector3Double): TVector3Double; overload;
 
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector2Single): TVector2Single; overload;
 
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector2Double): TVector2Double; overload;
 
function PointToLineDistanceSqr(const point, line0, lineVector: TVector3Single): Single; overload;
 
function PointToLineDistanceSqr(const point, line0, lineVector: TVector3Double): Double; overload;
 
function TryPlaneLineIntersection(out intersection: TVector3Single; const plane: TVector4Single; const line0, lineVector: TVector3Single): boolean; overload;

Plane and line intersection.

Returns False and doesn't modify Intersection or T when the line is parallel to the plane (this includes the case when the line lies on a plane, so theoretically the whole line is an intersection).

Otherwise, returns True, and calculates 3D intersection point, or calculates T such that 3D intersection = Line0 + LineVector * T.

function TryPlaneLineIntersection(out intersection: TVector3Double; const plane: TVector4Double; const line0, lineVector: TVector3Double): boolean; overload;
 
function TryPlaneLineIntersection(out t: Single; const plane: TVector4Single; const line0, lineVector: TVector3Single): boolean; overload;
 
function TryPlaneLineIntersection(out t: Double; const plane: TVector4Double; const line0, lineVector: TVector3Double): boolean; overload;
 
function TrySimplePlaneRayIntersection(out Intersection: TVector3Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;

Plane and ray intersection.

Returns False and doesn't modify Intersection or T when the ray is parallel to the plane (this includes the case when the ray lies on a plane. Also returns False when the ray would have to point in the opposite direction to hit the plane.

Otherwise, returns True, and calculates 3D intersection point, or calculates T such that 3D intersection = RayOrigin + RayDirection * T.

function TrySimplePlaneRayIntersection(out Intersection: TVector3Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
 
function TrySimplePlaneRayIntersection(out Intersection: TVector3Single; out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
 
function TrySimplePlaneRayIntersection(out Intersection: TVector3Double; out T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
 
function TrySimplePlaneRayIntersection(out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
 
function TrySimplePlaneRayIntersection(out T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
 
function TryPlaneRayIntersection(out Intersection: TVector3Single; const Plane: TVector4Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
 
function TryPlaneRayIntersection(out Intersection: TVector3Double; const Plane: TVector4Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
 
function TryPlaneRayIntersection(out Intersection: TVector3Single; out T: Single; const Plane: TVector4Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
 
function TryPlaneRayIntersection(out Intersection: TVector3Double; out T: Double; const Plane: TVector4Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
 
function TrySimplePlaneSegmentDirIntersection(var Intersection: TVector3Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Segment0, SegmentVector: TVector3Single): boolean; overload;

Plane and line segment intersection.

Returns False and doesn't modify Intersection or T when the segment is parallel to the plane (this includes the case when the segment lies on a plane. Also returns False when the segment would have to be longer to hit the plane.

Otherwise, returns True, and calculates 3D intersection point, or calculates T such that 3D intersection = RayOrigin + RayDirection * T.

function TrySimplePlaneSegmentDirIntersection(var Intersection: TVector3Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Segment0, SegmentVector: TVector3Double): boolean; overload;
 
function TrySimplePlaneSegmentDirIntersection(var Intersection: TVector3Single; var T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Segment0, SegmentVector: TVector3Single): boolean; overload;
 
function TrySimplePlaneSegmentDirIntersection(var Intersection: TVector3Double; var T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Segment0, SegmentVector: TVector3Double): boolean; overload;
 
function TrySimplePlaneSegmentDirIntersection(var T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Segment0, SegmentVector: TVector3Single): boolean; overload;
 
function TrySimplePlaneSegmentDirIntersection(var T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Segment0, SegmentVector: TVector3Double): boolean; overload;
 
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3Single): boolean; overload;
 
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Pos1, Pos2: TVector3Double): boolean; overload;
 
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3Single; out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3Single): boolean; overload;
 
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3Double; out T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Pos1, Pos2: TVector3Double): boolean; overload;
 
function TrySimplePlaneSegmentIntersection( out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3Single): boolean; overload;
 
function TrySimplePlaneSegmentIntersection( out T: Double; const PlaneConstCoord: integer; const PlaneConstValue: Double; const Pos1, Pos2: TVector3Double): boolean; overload;
 
function TryPlaneSegmentDirIntersection(out Intersection: TVector3Single; const Plane: TVector4Single; const Segment0, SegmentVector: TVector3Single): boolean; overload;
 
function TryPlaneSegmentDirIntersection(out Intersection: TVector3Double; const Plane: TVector4Double; const Segment0, SegmentVector: TVector3Double): boolean; overload;
 
function TryPlaneSegmentDirIntersection(out Intersection: TVector3Single; out T: Single; const Plane: TVector4Single; const Segment0, SegmentVector: TVector3Single): boolean; overload;
 
function TryPlaneSegmentDirIntersection(out Intersection: TVector3Double; out T: Double; const Plane: TVector4Double; const Segment0, SegmentVector: TVector3Double): boolean; overload;
 
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector2Single): boolean; overload;
 
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector2Double): boolean; overload;
 
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector3Single): boolean; overload;
 
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector3Double): boolean; overload;
 
function LineOfTwoDifferentPoints2d(const p1, p2: TVector2Single): TVector3Single; overload;

Line passing through two different points. When the points are equal, undefined.

function LineOfTwoDifferentPoints2d(const p1, p2: TVector2Double): TVector3Double; overload;
 
function PointToSegmentDistanceSqr(const point, pos1, pos2: TVector3Single): Single; overload;
 
function PointToSegmentDistanceSqr(const point, pos1, pos2: TVector3Double): Double; overload;
 
function PlaneTransform(const Plane: TVector4Single; const Matrix: TMatrix4Single): TVector4Single;

Transform plane by a matrix.

Exceptions raised
ETransformedResultInvalid
Raised when matrix will transform some point to a direction, or direction to point, in homogeneous coordinates.
function PlaneTransform(const Plane: TVector4Double; const Matrix: TMatrix4Double): TVector4Double;
 
function IsTunnelSphereCollision(const Tunnel1, Tunnel2: TVector3Single; const TunnelRadius: Single; const SphereCenter: TVector3Single; const SphereRadius: Single): boolean; overload;
 
function IsTunnelSphereCollision(const Tunnel1, Tunnel2: TVector3Double; const TunnelRadius: Double; const SphereCenter: TVector3Double; const SphereRadius: Double): boolean; overload;
 
function IsSpheresCollision(const Sphere1Center: TVector3Single; const Sphere1Radius: Single; const Sphere2Center: TVector3Single; const Sphere2Radius: Single): boolean; overload;
 
function IsSpheresCollision(const Sphere1Center: TVector3Double; const Sphere1Radius: Double; const Sphere2Center: TVector3Double; const Sphere2Radius: Double): boolean; overload;
 
function IsSegmentSphereCollision(const pos1, pos2, SphereCenter: TVector3Single; const SphereRadius: Single): boolean; overload;
 
function IsSegmentSphereCollision(const pos1, pos2, SphereCenter: TVector3Double; const SphereRadius: Double): boolean; overload;
 
function TrySphereRayIntersection(out Intersection: TVector3Single; const SphereCenter: TVector3Single; const SphereRadius: Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;
 
function TrySphereRayIntersection(out Intersection: TVector3Double; const SphereCenter: TVector3Double; const SphereRadius: Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
 
function TryCylinderRayIntersection(out Intersection: TVector3Single; const CylinderAxisOrigin, CylinderAxis: TVector3Single; const CylinderRadius: Single; const RayOrigin, RayDirection: TVector3Single): boolean; overload;

Intersection between an (infinitely tall) cylinder and a ray.

function TryCylinderRayIntersection(out Intersection: TVector3Double; const CylinderAxisOrigin, CylinderAxis: TVector3Double; const CylinderRadius: Double; const RayOrigin, RayDirection: TVector3Double): boolean; overload;
 
function FloatToNiceStr(f: Single): string; overload;
 
function FloatToNiceStr(f: Double): string; overload;
 
function VectorToNiceStr(const v: array of Byte): string; overload;
 
function VectorToNiceStr(const v: array of Single): string; overload;
 
function VectorToNiceStr(const v: array of Double): string; overload;
 
function VectorToNiceStr(const v: array of Integer): string; overload;
 
function MatrixToNiceStr(const v: TMatrix4Single; const LineIndent: string): string; overload;
 
function MatrixToNiceStr(const v: TMatrix4Double; const LineIndent: string): string; overload;
 
function FloatToRawStr(f: Single): string; overload;
 
function FloatToRawStr(f: Double): string; overload;
 
function VectorToRawStr(const v: array of Byte): string; overload;
 
function VectorToRawStr(const v: array of Integer): string; overload;
 
function VectorToRawStr(const v: array of Single): string; overload;
 
function VectorToRawStr(const v: array of Double): string; overload;
 
function MatrixToRawStr(const v: TMatrix4Single; const LineIndent: string): string; overload;
 
function MatrixToRawStr(const v: TMatrix4Double; const LineIndent: string): string; overload;
 
function MatrixAdd(const m1, m2: TMatrix3Single): TMatrix3Single; overload;
 
function MatrixAdd(const m1, m2: TMatrix4Single): TMatrix4Single; overload;
 
function MatrixAdd(const m1, m2: TMatrix3Double): TMatrix3Double; overload;
 
function MatrixAdd(const m1, m2: TMatrix4Double): TMatrix4Double; overload;
 
procedure MatrixAddVar(var m1: TMatrix3Single; const m2: TMatrix3Single); overload;
 
procedure MatrixAddVar(var m1: TMatrix4Single; const m2: TMatrix4Single); overload;
 
procedure MatrixAddVar(var m1: TMatrix3Double; const m2: TMatrix3Double); overload;
 
procedure MatrixAddVar(var m1: TMatrix4Double; const m2: TMatrix4Double); overload;
 
function MatrixSubtract(const m1, m2: TMatrix3Single): TMatrix3Single; overload;
 
function MatrixSubtract(const m1, m2: TMatrix4Single): TMatrix4Single; overload;
 
function MatrixSubtract(const m1, m2: TMatrix3Double): TMatrix3Double; overload;
 
function MatrixSubtract(const m1, m2: TMatrix4Double): TMatrix4Double; overload;
 
procedure MatrixSubtractVar(var m1: TMatrix3Single; const m2: TMatrix3Single); overload;
 
procedure MatrixSubtractVar(var m1: TMatrix4Single; const m2: TMatrix4Single); overload;
 
procedure MatrixSubtractVar(var m1: TMatrix3Double; const m2: TMatrix3Double); overload;
 
procedure MatrixSubtractVar(var m1: TMatrix4Double; const m2: TMatrix4Double); overload;
 
function MatrixNegate(const m1: TMatrix3Single): TMatrix3Single; overload;
 
function MatrixNegate(const m1: TMatrix4Single): TMatrix4Single; overload;
 
function MatrixNegate(const m1: TMatrix3Double): TMatrix3Double; overload;
 
function MatrixNegate(const m1: TMatrix4Double): TMatrix4Double; overload;
 
function MatrixMultScalar(const m: TMatrix3Single; const s: Single): TMatrix3Single; overload;
 
function MatrixMultScalar(const m: TMatrix4Single; const s: Single): TMatrix4Single; overload;
 
function MatrixMultScalar(const m: TMatrix3Double; const s: Double): TMatrix3Double; overload;
 
function MatrixMultScalar(const m: TMatrix4Double; const s: Double): TMatrix4Double; overload;
 
function MatrixMultPoint(const m: TMatrix4Single; const pt: TVector3Single): TVector3Single; overload;

Transform a 3D or 2D point with 4x4 matrix.

This works by temporarily converting point to 4-component vector (4th component is 1). After multiplying matrix * vector we divide by 4th component. So this works Ok for all matrices, even with last row different than identity (0, 0, 0, 1). E.g. this works for projection matrices too.

Exceptions raised
ETransformedResultInvalid
This is raised when matrix will transform point to a direction (vector with 4th component equal zero). In this case we just cannot interpret the result as a point.
function MatrixMultPoint(const m: TMatrix4Double; const pt: TVector3Double): TVector3Double; overload;
 
function MatrixMultPoint(const m: TMatrix4Single; const pt: TVector2Single): TVector2Single; overload;
 
function MatrixMultPoint(const m: TMatrix4Double; const pt: TVector2Double): TVector2Double; overload;
 
function MatrixMultDirection(const m: TMatrix4Single; const Dir: TVector3Single): TVector3Single; overload;

Transform a 3D or 2D direction with 4x4 matrix.

This works by temporarily converting direction to 4-component vector (4th component is 0). After multiplying matrix * vector we check is the 4th component still 0 (eventually raising ETransformedResultInvalid).

Exceptions raised
ETransformedResultInvalid
This is raised when matrix will transform direction to a point (vector with 4th component nonzero). In this case we just cannot interpret the result as a direction.
function MatrixMultDirection(const m: TMatrix4Double; const Dir: TVector3Double): TVector3Double; overload;
 
function MatrixMultDirection(const m: TMatrix4Single; const Dir: TVector2Single): TVector2Single; overload;
 
function MatrixMultDirection(const m: TMatrix4Double; const Dir: TVector2Double): TVector2Double; overload;
 
function MatrixMultVector(const m: TMatrix2Single; const v: TVector2Single): TVector2Single; overload;
 
function MatrixMultVector(const m: TMatrix3Single; const v: TVector3Single): TVector3Single; overload;
 
function MatrixMultVector(const m: TMatrix4Single; const v: TVector4Single): TVector4Single; overload;
 
function MatrixMultVector(const m: TMatrix2Double; const v: TVector2Double): TVector2Double; overload;
 
function MatrixMultVector(const m: TMatrix3Double; const v: TVector3Double): TVector3Double; overload;
 
function MatrixMultVector(const m: TMatrix4Double; const v: TVector4Double): TVector4Double; overload;
 
function MatrixMult(const m1, m2: TMatrix2Single): TMatrix2Single; overload;
 
function MatrixMult(const m1, m2: TMatrix3Single): TMatrix3Single; overload;
 
function MatrixMult(const m1, m2: TMatrix4Single): TMatrix4Single; overload;
 
function MatrixMult(const m1, m2: TMatrix2Double): TMatrix2Double; overload;
 
function MatrixMult(const m1, m2: TMatrix3Double): TMatrix3Double; overload;
 
function MatrixMult(const m1, m2: TMatrix4Double): TMatrix4Double; overload;
 
function MatrixRow(const m: TMatrix2Single; const Row: Integer): TVector2Single; overload;
 
function MatrixRow(const m: TMatrix3Single; const Row: Integer): TVector3Single; overload;
 
function MatrixRow(const m: TMatrix4Single; const Row: Integer): TVector4Single; overload;
 
function MatrixRow(const m: TMatrix2Double; const Row: Integer): TVector2Double; overload;
 
function MatrixRow(const m: TMatrix3Double; const Row: Integer): TVector3Double; overload;
 
function MatrixRow(const m: TMatrix4Double; const Row: Integer): TVector4Double; overload;
 
function MatrixDeterminant(const M: TMatrix2Single): Single; overload;
 
function MatrixDeterminant(const M: TMatrix2Double): Double; overload;
 
function MatrixDeterminant(const M: TMatrix3Single): Single; overload;
 
function MatrixDeterminant(const M: TMatrix3Double): Double; overload;
 
function MatrixDeterminant(const M: TMatrix4Single): Single; overload;
 
function MatrixDeterminant(const M: TMatrix4Double): Double; overload;
 
function MatrixInverse(const M: TMatrix2Single; const Determinant: Single): TMatrix2Single; overload;

Inverse the matrix.

They do division by Determinant internally, so will raise exception from this float division if the matrix is not reversible.

function MatrixInverse(const M: TMatrix2Double; const Determinant: Double): TMatrix2Double; overload;
 
function MatrixInverse(const M: TMatrix3Single; const Determinant: Single): TMatrix3Single; overload;
 
function MatrixInverse(const M: TMatrix3Double; const Determinant: Double): TMatrix3Double; overload;
 
function MatrixInverse(const M: TMatrix4Single; const Determinant: Single): TMatrix4Single; overload;
 
function MatrixInverse(const M: TMatrix4Double; const Determinant: Double): TMatrix4Double; overload;
 
procedure MatrixTransposeVar(var M: TMatrix3Single); overload;

Transpose the matrix.

procedure MatrixTransposeVar(var M: TMatrix3Double); overload;
 
function MatrixTranspose(const M: TMatrix3Single): TMatrix3Single; overload;
 
function MatrixTranspose(const M: TMatrix3Double): TMatrix3Double; overload;
 
function MatrixTranspose(const M: TMatrix4Single): TMatrix4Single; overload;
 
function MatrixTranspose(const M: TMatrix4Double): TMatrix4Double; overload;
 
function TryMatrixInverse(const M: TMatrix2Single; out MInverse: TMatrix2Single): boolean; overload;

Inverse the matrix, trying harder (but possibly slower).

Basically, they internally calculate determinant and then calculate inverse using this determinant. Return False if the determinant is zero.

The main feature is that Single precision versions actually internally calculate everything (determinant and inverse) in Double precision. This gives better accuracy, and safety from matrices with very very small (but not zero) determinants.

This is quite important for many matrices. For example, a 4x4 matrix with scaling = 1/200 (which can be easily found in practice, see e.g. castle/data/levels/gate/gate_processed.wrl) already has determinant = 1/8 000 000, which will not pass Zero test (with SingleEqualityEpsilon). But it's possible to calculate it (even on Single precision, although safer in Double precision).

function TryMatrixInverse(const M: TMatrix2Double; out MInverse: TMatrix2Double): boolean; overload;
 
function TryMatrixInverse(const M: TMatrix3Single; out MInverse: TMatrix3Single): boolean; overload;
 
function TryMatrixInverse(const M: TMatrix3Double; out MInverse: TMatrix3Double): boolean; overload;
 
function TryMatrixInverse(const M: TMatrix4Single; out MInverse: TMatrix4Single): boolean; overload;
 
function TryMatrixInverse(const M: TMatrix4Double; out MInverse: TMatrix4Double): boolean; overload;
 
function ModelViewToNormalMatrix(const M: TMatrix4Single): TMatrix3Single;

Convert ModelView matrix to a Normal matrix, just like 3D graphic libraries do. See e.g. http://www.lighthouse3d.com/tutorials/glsl-tutorial/the-normal-matrix/ for explanation why this is necessary, and how it's done.

function VectorMultTransposedSameVector(const v: TVector3Single): TMatrix4Single;

Multiply vector by a transposition of the same vector. For 3d vectors, this results in a 3x3 matrix. To put this inside a 4x4 matrix, we fill the last row and column just like for an identity matrix.

This is useful for calculating rotation matrix.

function TranslationMatrix(const X, Y, Z: Single): TMatrix4Single; overload;

Functions to create common 4x4 matrices used in 3D graphics.

These functions generate the same matrices that are made by corresponding OpenGL (gl or glu) functions. So rotations will be generated in the same fashion, etc. For exact specification of what matrices they create see OpenGL specification for routines glTranslate, glScale, glRotate.

Functions named Matrices below generate both normal and inverted matrices. For example, function RotationMatrices returns two matrices that you could calculate separately by

        Matrix: = RotationMatrix( Angle, Axis);
InvertedMatrix: = RotationMatrix(-Angle, Axis);

This is useful sometimes, and generating them both at the same time allows for some speedup (for example, calling RotationMatrix twice will calculate sincos of Angle twice).

Note that inverse of scaling matrix will not exist if the ScaleFactor has one of the components zero ! Depending on InvertedMatrixIdentityIfNotExists, this will (if False) raise division by zero exception or (if True) cause the matrix to be set to identity.

Note that rotation matrix (both normal and inverse) is always defined, for Axis = zero both normal and inverse matrices are set to identity.

function TranslationMatrix(const X, Y, Z: Double): TMatrix4Single; overload;
 
function TranslationMatrix(const Transl: TVector3Single): TMatrix4Single; overload;
 
function TranslationMatrix(const Transl: TVector3Double): TMatrix4Single; overload;
 
procedure TranslationMatrices(const X, Y, Z: Single; out Matrix, InvertedMatrix: TMatrix4Single); overload;
 
procedure TranslationMatrices(const X, Y, Z: Double; out Matrix, InvertedMatrix: TMatrix4Single); overload;
 
procedure TranslationMatrices(const Transl: TVector3Single; out Matrix, InvertedMatrix: TMatrix4Single); overload;
 
procedure TranslationMatrices(const Transl: TVector3Double; out Matrix, InvertedMatrix: TMatrix4Single); overload;
 
function ScalingMatrix(const ScaleFactor: TVector3Single): TMatrix4Single;
 
procedure ScalingMatrices(const ScaleFactor: TVector3Single; InvertedMatrixIdentityIfNotExists: boolean; out Matrix, InvertedMatrix: TMatrix4Single);
 
function RotationMatrixRad(const AngleRad: Single; const Axis: TVector3Single): TMatrix4Single; overload;
 
function RotationMatrixDeg(const AngleDeg: Single; const Axis: TVector3Single): TMatrix4Single; overload;
 
function RotationMatrixRad(const AngleRad: Single; const AxisX, AxisY, AxisZ: Single): TMatrix4Single; overload;
 
function RotationMatrixDeg(const AngleDeg: Single; const AxisX, AxisY, AxisZ: Single): TMatrix4Single; overload;
 
procedure RotationMatricesRad(const AngleRad: Single; const Axis: TVector3Single; out Matrix, InvertedMatrix: TMatrix4Single);
 
procedure RotationMatricesRad(const AxisAngle: TVector4Single; out Matrix, InvertedMatrix: TMatrix4Single);
 
procedure MultMatrixTranslation(var M: TMatrix4Single; const Transl: TVector3Single); overload;

Multiply matrix M by translation matrix.

This is equivalent to M := MatrixMult(M, TranslationMatrix(Transl)), but it works much faster since TranslationMatrix is a very simple matrix and multiplication by it may be much optimized.

An additional speedup comes from the fact that the result is placed back in M (so on places where M doesn't change (and there's a lot of them for multiplication with translation matrix) there's no useless copying).

MultMatricesTranslation is analogous to calculating both TranslationMatrix(Transl) and it's inverse, and then

M := MatrixMult(M, translation);
MInvert := MatrixMult(inverted translation, MInvert);

The idea is that if M represented some translation, and MInvert it's inverse, then after MultMatricesTranslation this will still hold.

procedure MultMatrixTranslation(var M: TMatrix4Double; const Transl: TVector3Double); overload;
 
procedure MultMatricesTranslation(var M, MInvert: TMatrix4Single; const Transl: TVector3Single); overload;
 
procedure MultMatricesTranslation(var M, MInvert: TMatrix4Double; const Transl: TVector3Double); overload;
 
function MatrixDet4x4(const mat: TMatrix4Single): Single;
 
function MatrixDet3x3(const a1, a2, a3, b1, b2, b3, c1, c2, c3: Single): Single;
 
function MatrixDet2x2(const a, b, c, d: Single): Single;
 
function TransformToCoordsMatrix(const NewX, NewY, NewZ: TVector3Single): TMatrix4Single; overload;

Transform coordinates to / from a coordinate system. Stuff multiplied by this matrix is supplied in other coordinate system.

The "new" coordinate system (you specify it explicitly for TransformToCoordsMatrix) is the coordinate system in which your 3D stuff is defined. That is, when you supply the points (that will later be multiplied by TransformToCoordsMatrix) you think in the "new" coordinate system. The "old" coordinate system (you specify it explicitly for TransformFromCoordsMatrix) is the coordinate system of stuff after it's multiplied by this matrix.

This may get confusing, so to be more precise:

  • TransformToCoordsMatrix says how the new coords system looks from the point of view of the old coords system. A stuff lying at (0, 0, 0) in new coord system will be seen at NewOrigin after the transformation (in the old coordinate system). Similarly, direction (0, 1, 0) will be seen as NewY after the transformation.

  • TransformFromCoordsMatrix is the inverse: how the old system is seen from the new one. If before the transformation you are at OldOrigin, then after the transformation you are at (0, 0, 0). This is natural way to implement LookAtMatrix, LookDirMatrix.

The lengths of directions (New or Old X, Y, Z vectors) are meaningful. These vectors correspond to unit vectors (1, 0, 0), (0, 1, 0) and (0, 0, 1) in the other coordinate system. Supplying here non-normalized vectors will result in scaling.

You can use the "NoScale" versions to have the vectors automatically normalized, thus you waste a little time (on normalizing) but you avoid the scaling.

Overloaded versions without OldOrigin / NewOrigin parameters work like the old/new origin is zero. IOW, the origin of the coordinate system doesn't change in this case.

function TransformToCoordsMatrix(const NewX, NewY, NewZ: TVector3Double): TMatrix4Single; overload;
 
function TransformToCoordsMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3Single): TMatrix4Single; overload;
 
function TransformToCoordsMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3Double): TMatrix4Single; overload;
 
function TransformToCoordsNoScaleMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3Single): TMatrix4Single; overload;
 
function TransformToCoordsNoScaleMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3Double): TMatrix4Single; overload;
 
function TransformFromCoordsMatrix(const OldX, OldY, OldZ: TVector3Single): TMatrix4Single; overload;
 
function TransformFromCoordsMatrix(const OldX, OldY, OldZ: TVector3Double): TMatrix4Single; overload;
 
function TransformFromCoordsMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3Single): TMatrix4Single; overload;
 
function TransformFromCoordsMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3Double): TMatrix4Single; overload;
 
function TransformFromCoordsNoScaleMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3Single): TMatrix4Single; overload;
 
function TransformFromCoordsNoScaleMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3Double): TMatrix4Single; overload;
 
procedure TransformCoordsMatrices(const NewX, NewY, NewZ: TVector3Single; out ToCoords, FromCoords: TMatrix4Single); overload;

Calculate matrix to convert to given coordinate system (like TransformToCoordsMatrix) and it's inverse (like TransformFromCoordsMatrix).

procedure TransformCoordsMatrices(const NewX, NewY, NewZ: TVector3Double; out ToCoords, FromCoords: TMatrix4Single); overload;
 
function TransformToCoords(const V, NewX, NewY, NewZ: TVector3Single): TVector3Single;

Transform vector into new coordinate space.

Equivalent to MatrixMultPoint(TransformToCoordsMatrix(ZeroVector3Single, NewX, NewY, NewZ)). So the origin of new coordinate system is at the same place. You should pass NewX, NewY, NewZ vectors normalized if you want to preserve vector length.

function TransformToCoords(const V, NewX, NewY, NewZ: TVector3Double): TVector3Double;
 
function LookAtMatrix(const Eye, Center, Up: TVector3Single): TMatrix4Single; overload;

Camera matrix to look at the specified point (or along the specified direction). Work according to right-handed coordinate system.

When applied to the scene, they transform it, such that a camera standing at (0, 0, 0) (with dir (0, 0, -1) and up vector (0, 1, 0)), was seeing the same view as if it was standing at Eye (with given Dir and Up vectors).

For LookAtMatrix, looking direction is implicitly given as Center - Eye. Just like gluLookAt.

  • For the overloaded LookDirMatrix version with Side parameter, we assume that Dir, Side and Up are already normalized and orthogonal to each other.

  • For the overloaded version without the Side parameter, Dir and Up do not have to normalized. We'll normalize them if needed, so their lengths do not affect the result (just as the distance between Center and Eye points for LookAtMatrix).

    Also, Dir and Up do not have to be perfectly orthogonal (we will eventually adjust Up internally to make it orthogonal to Up).

    You still must make sure that Dir and Up are not parallel.

function LookAtMatrix(const Eye, Center, Up: TVector3Double): TMatrix4Single; overload;
 
function LookDirMatrix(const Eye, Dir, Up: TVector3Single): TMatrix4Single; overload;
 
function LookDirMatrix(const Eye, Dir, Up: TVector3Double): TMatrix4Single; overload;
 
function LookDirMatrix(const Eye, Dir, Side, Up: TVector3Single): TMatrix4Single; overload;
 
function LookDirMatrix(const Eye, Dir, Side, Up: TVector3Double): TMatrix4Single; overload;
 
function FastLookDirMatrix(const Direction, Up: TVector3Single): TMatrix4Single;

Calculate LookDirMatrix (or it's inverse), fast.

Has some assumptions that make it run fast:

  • It assumes camera position is zero.

  • It assumes that Dir and Up are already normalized and orthogonal.

function FastLookDirMatrix(const Direction, Up: TVector3Double): TMatrix4Single;
 
function InverseFastLookDirMatrix(const Direction, Up: TVector3Single): TMatrix4Single;
 
function InverseFastLookDirMatrix(const Direction, Up: TVector3Double): TMatrix4Single;
 
operator + (const x,y:Tvector2_single_data) : Tvector2_single_data;

Vector to vector operations.

operator + (const x,y:Tvector2_double_data) : Tvector2_double_data;
 
operator + (const x,y:Tvector2_extended_data) : Tvector2_extended_data;
 
operator + (const x,y:Tvector2Integer) : Tvector2Integer;
 
operator + (const x,y:Tvector3_single_data) : Tvector3_single_data;
 
operator + (const x,y:Tvector3_double_data) : Tvector3_double_data;
 
operator + (const x,y:Tvector3_extended_data) : Tvector3_extended_data;
 
operator + (const x,y:Tvector3Integer) : Tvector3Integer;
 
operator + (const x,y:Tvector4_single_data) : Tvector4_single_data;
 
operator + (const x,y:Tvector4_double_data) : Tvector4_double_data;
 
operator + (const x,y:Tvector4_extended_data) : Tvector4_extended_data;
 
operator + (const x,y:Tvector4Integer) : Tvector4Integer;
 
operator - (const x,y:Tvector2_single_data) : Tvector2_single_data;
 
operator - (const x,y:Tvector2_double_data) : Tvector2_double_data;
 
operator - (const x,y:Tvector2_extended_data) : Tvector2_extended_data;
 
operator - (const x,y:Tvector2Integer) : Tvector2Integer;
 
operator - (const x,y:Tvector3_single_data) : Tvector3_single_data;
 
operator - (const x,y:Tvector3_double_data) : Tvector3_double_data;
 
operator - (const x,y:Tvector3_extended_data) : Tvector3_extended_data;
 
operator - (const x,y:Tvector3Integer) : Tvector3Integer;
 
operator - (const x,y:Tvector4_single_data) : Tvector4_single_data;
 
operator - (const x,y:Tvector4_double_data) : Tvector4_double_data;
 
operator - (const x,y:Tvector4_extended_data) : Tvector4_extended_data;
 
operator - (const x,y:Tvector4Integer) : Tvector4Integer;
 
operator - (const x:Tvector2_single_data) : Tvector2_single_data;
 
operator - (const x:Tvector2_double_data) : Tvector2_double_data;
 
operator - (const x:Tvector2_extended_data) : Tvector2_extended_data;
 
operator - (const x:Tvector2Integer) : Tvector2Integer;
 
operator - (const x:Tvector3_single_data) : Tvector3_single_data;
 
operator - (const x:Tvector3_double_data) : Tvector3_double_data;
 
operator - (const x:Tvector3_extended_data) : Tvector3_extended_data;
 
operator - (const x:Tvector3Integer) : Tvector3Integer;
 
operator - (const x:Tvector4_single_data) : Tvector4_single_data;
 
operator - (const x:Tvector4_double_data) : Tvector4_double_data;
 
operator - (const x:Tvector4_extended_data) : Tvector4_extended_data;
 
operator - (const x:Tvector4Integer) : Tvector4Integer;
 
operator * (const x,y:Tvector2_single_data) : Tvector2_single_data;
 
operator * (const x,y:Tvector2_double_data) : Tvector2_double_data;
 
operator * (const x,y:Tvector2_extended_data) : Tvector2_extended_data;
 
operator * (const x,y:Tvector2Integer) : Tvector2Integer;
 
operator * (const x,y:Tvector3_single_data) : Tvector3_single_data;
 
operator * (const x,y:Tvector3_double_data) : Tvector3_double_data;
 
operator * (const x,y:Tvector3_extended_data) : Tvector3_extended_data;
 
operator * (const x,y:Tvector3Integer) : Tvector3Integer;
 
operator * (const x,y:Tvector4_single_data) : Tvector4_single_data;
 
operator * (const x,y:Tvector4_double_data) : Tvector4_double_data;
 
operator * (const x,y:Tvector4_extended_data) : Tvector4_extended_data;
 
operator * (const x,y:Tvector4Integer) : Tvector4Integer;
 
operator ** (const x,y:Tvector2_single_data) : single;
 
operator ** (const x,y:Tvector2_double_data) : double;
 
operator ** (const x,y:Tvector2_extended_data) : extended;
 
operator ** (const x,y:Tvector2Integer) : Integer;
 
operator ** (const x,y:Tvector3_single_data) : single;
 
operator ** (const x,y:Tvector3_double_data) : double;
 
operator ** (const x,y:Tvector3_extended_data) : extended;
 
operator ** (const x,y:Tvector3Integer) : Integer;
 
operator ** (const x,y:Tvector4_single_data) : single;
 
operator ** (const x,y:Tvector4_double_data) : double;
 
operator ** (const x,y:Tvector4_extended_data) : extended;
 
operator ** (const x,y:Tvector4Integer) : Integer;
 
operator >< (const x,y:Tvector3_single_data) : Tvector3_single_data;
 
operator >< (const x,y:Tvector3_double_data) : Tvector3_double_data;
 
operator >< (const x,y:Tvector3_extended_data) : Tvector3_extended_data;
 
operator >< (const x,y:Tvector3Integer) : Tvector3Integer;
 
operator * (const x:Tvector2_single_data;y:single) : Tvector2_single_data;
 
operator * (const x:Tvector2_double_data;y:double) : Tvector2_double_data;
 
operator * (const x:Tvector2_extended_data;y:extended) : Tvector2_extended_data;
 
operator * (const x:Tvector3_single_data;y:single) : Tvector3_single_data;
 
operator * (const x:Tvector3_double_data;y:double) : Tvector3_double_data;
 
operator * (const x:Tvector3_extended_data;y:extended) : Tvector3_extended_data;
 
operator * (const x:Tvector4_single_data;y:single) : Tvector4_single_data;
 
operator * (const x:Tvector4_double_data;y:double) : Tvector4_double_data;
 
operator * (const x:Tvector4_extended_data;y:extended) : Tvector4_extended_data;
 
operator / (const x:Tvector2_single_data;y:single) : Tvector2_single_data;
 
operator / (const x:Tvector2_double_data;y:double) : Tvector2_double_data;
 
operator / (const x:Tvector2_extended_data;y:extended) : Tvector2_extended_data;
 
operator / (const x:Tvector3_single_data;y:single) : Tvector3_single_data;
 
operator / (const x:Tvector3_double_data;y:double) : Tvector3_double_data;
 
operator / (const x:Tvector3_extended_data;y:extended) : Tvector3_extended_data;
 
operator / (const x:Tvector4_single_data;y:single) : Tvector4_single_data;
 
operator / (const x:Tvector4_double_data;y:double) : Tvector4_double_data;
 
operator / (const x:Tvector4_extended_data;y:extended) : Tvector4_extended_data;
 
operator + (const m1,m2:Tmatrix2_single_data) : Tmatrix2_single_data;
 
operator + (const m1,m2:Tmatrix2_double_data) : Tmatrix2_double_data;
 
operator + (const m1,m2:Tmatrix3_single_data) : Tmatrix3_single_data;
 
operator + (const m1,m2:Tmatrix3_double_data) : Tmatrix3_double_data;
 
operator + (const m1,m2:Tmatrix4_single_data) : Tmatrix4_single_data;
 
operator + (const m1,m2:Tmatrix4_double_data) : Tmatrix4_double_data;
 
operator - (const m1,m2:Tmatrix2_single_data) : Tmatrix2_single_data;
 
operator - (const m1,m2:Tmatrix2_double_data) : Tmatrix2_double_data;
 
operator - (const m1,m2:Tmatrix3_single_data) : Tmatrix3_single_data;
 
operator - (const m1,m2:Tmatrix3_double_data) : Tmatrix3_double_data;
 
operator - (const m1,m2:Tmatrix4_single_data) : Tmatrix4_single_data;
 
operator - (const m1,m2:Tmatrix4_double_data) : Tmatrix4_double_data;
 
operator - (const m1:Tmatrix2_single_data) : Tmatrix2_single_data;
 
operator - (const m1:Tmatrix2_double_data) : Tmatrix2_double_data;
 
operator - (const m1:Tmatrix3_single_data) : Tmatrix3_single_data;
 
operator - (const m1:Tmatrix3_double_data) : Tmatrix3_double_data;
 
operator - (const m1:Tmatrix4_single_data) : Tmatrix4_single_data;
 
operator - (const m1:Tmatrix4_double_data) : Tmatrix4_double_data;
 
operator * (const m1,m2:Tmatrix2_single_data) : Tmatrix2_single_data;
 
operator * (const m1,m2:Tmatrix2_double_data) : Tmatrix2_double_data;
 
operator * (const m1,m2:Tmatrix3_single_data) : Tmatrix3_single_data;
 
operator * (const m1,m2:Tmatrix3_double_data) : Tmatrix3_double_data;
 
operator * (const m1,m2:Tmatrix4_single_data) : Tmatrix4_single_data;
 
operator * (const m1,m2:Tmatrix4_double_data) : Tmatrix4_double_data;
 
operator * (const m:Tmatrix2_single_data;const v:Tvector2_single_data) : Tvector2_single_data;

Matrix/vector operations

operator * (const m:Tmatrix2_double_data;const v:Tvector2_double_data) : Tvector2_double_data;
 
operator * (const m:Tmatrix3_single_data;const v:Tvector3_single_data) : Tvector3_single_data;
 
operator * (const m:Tmatrix3_double_data;const v:Tvector3_double_data) : Tvector3_double_data;
 
operator * (const m:Tmatrix4_single_data;const v:Tvector4_single_data) : Tvector4_single_data;
 
operator * (const m:Tmatrix4_double_data;const v:Tvector4_double_data) : Tvector4_double_data;
 
operator * (const m:Tmatrix2_single_data;const x:single) : Tmatrix2_single_data;

Matrix/scalar operations

operator * (const m:Tmatrix2_double_data;const x:double) : Tmatrix2_double_data;
 
operator * (const m:Tmatrix3_single_data;const x:single) : Tmatrix3_single_data;
 
operator * (const m:Tmatrix3_double_data;const x:double) : Tmatrix3_double_data;
 
operator * (const m:Tmatrix4_single_data;const x:single) : Tmatrix4_single_data;
 
operator * (const m:Tmatrix4_double_data;const x:double) : Tmatrix4_double_data;
 
operator / (const m:Tmatrix2_single_data;const x:single) : Tmatrix2_single_data;
 
operator / (const m:Tmatrix2_double_data;const x:double) : Tmatrix2_double_data;
 
operator / (const m:Tmatrix3_single_data;const x:single) : Tmatrix3_single_data;
 
operator / (const m:Tmatrix3_double_data;const x:double) : Tmatrix3_double_data;
 
operator / (const m:Tmatrix4_single_data;const x:single) : Tmatrix4_single_data;
 
operator / (const m:Tmatrix4_double_data;const x:double) : Tmatrix4_double_data;
 

Types

Pvector2_single = ˆTvector2_single ;
 
Pvector2_double = ˆTvector2_double ;
 
Pvector2_extended = ˆTvector2_extended;
 
Pvector3_single = ˆTvector3_single ;
 
Pvector3_double = ˆTvector3_double ;
 
Pvector3_extended = ˆTvector3_extended;
 
Pvector4_single = ˆTvector4_single ;
 
Pvector4_double = ˆTvector4_double ;
 
Pvector4_extended = ˆTvector4_extended;
 
Pmatrix2_single = ˆTmatrix2_single ;
 
Pmatrix2_double = ˆTmatrix2_double ;
 
Pmatrix2_extended = ˆTmatrix2_extended;
 
Pmatrix3_single = ˆTmatrix3_single ;
 
Pmatrix3_double = ˆTmatrix3_double ;
 
Pmatrix3_extended = ˆTmatrix3_extended;
 
Pmatrix4_single = ˆTmatrix4_single ;
 
Pmatrix4_double = ˆTmatrix4_double ;
 
Pmatrix4_extended = ˆTmatrix4_extended;
 
TVector2Single = Tvector2_single_data;
 
PVector2Single = ˆTVector2Single;
 
TVector2Double = Tvector2_double_data;
 
PVector2Double = ˆTVector2Double;
 
TVector2Extended = Tvector2_extended_data;
 
PVector2Extended = ˆTVector2Extended;
 
TVector2Byte = packed array [0..1] of Byte;
 
PVector2Byte = ˆTVector2Byte;
 
TVector2Word = packed array [0..1] of Word;
 
PVector2Word = ˆTVector2Word;
 
TVector2SmallInt = packed array [0..1] of SmallInt;
 
PVector2SmallInt = ˆTVector2SmallInt;
 
TVector2Longint = packed array [0..1] of Longint;
 
PVector2Longint = ˆTVector2Longint;
 
TVector2Pointer = packed array [0..1] of Pointer;
 
PVector2Pointer = ˆTVector2Pointer;
 
TVector2Cardinal = packed array [0..1] of Cardinal;
 
PVector2Cardinal = ˆTVector2Cardinal;
 
TVector2Integer = packed array [0..1] of Integer;
 
PVector2Integer = ˆTVector2Integer;
 
TVector3Single = Tvector3_single_data;
 
PVector3Single = ˆTVector3Single;
 
TVector3Double = Tvector3_double_data;
 
PVector3Double = ˆTVector3Double;
 
TVector3Extended = Tvector3_extended_data;
 
PVector3Extended = ˆTVector3Extended;
 
TVector3Byte = packed array [0..2] of Byte;
 
PVector3Byte = ˆTVector3Byte;
 
TVector3Word = packed array [0..2] of Word;
 
PVector3Word = ˆTVector3Word;
 
TVector3Longint = packed array [0..2] of Longint;
 
PVector3Longint = ˆTVector3Longint;
 
TVector3Pointer = packed array [0..2] of Pointer;
 
PVector3Pointer = ˆTVector3Pointer;
 
TVector3Integer = packed array [0..2] of Integer;
 
PVector3Integer = ˆTVector3Integer;
 
TVector3Cardinal = packed array [0..2] of Cardinal;
 
PVector3Cardinal = ˆTVector3Cardinal;
 
TVector4Single = Tvector4_single_data;
 
PVector4Single = ˆTVector4Single;
 
TVector4Double = Tvector4_double_data;
 
PVector4Double = ˆTVector4Double;
 
TVector4Extended = Tvector4_extended_data;
 
PVector4Extended = ˆTVector4Extended;
 
TVector4Byte = packed array [0..3] of Byte;
 
PVector4Byte = ˆTVector4Byte;
 
TVector4Word = packed array [0..3] of Word;
 
PVector4Word = ˆTVector4Word;
 
TVector4Longint = packed array [0..3] of Longint;
 
PVector4Longint = ˆTVector4Longint;
 
TVector4Pointer = packed array [0..3] of Pointer;
 
PVector4Pointer = ˆTVector4Pointer;
 
TVector4Cardinal = packed array [0..3] of Cardinal;
 
PVector4Cardinal = ˆTVector4Cardinal;
 
TVector4Integer = packed array [0..3] of Integer;
 
PVector4Integer = ˆTVector4Integer;
 
TMatrix2Single = Tmatrix2_single_data;

Matrices types.

The indexing rules of these types are the same as indexing rules for matrix types of OpenGL. I.e. the 1st index specifies the column (where the leftmost column is numbered zero), 2nd index specifies the row (where the uppermost row is numbered zero).

Note that this is different than how FPC Matrix unit treats matrices ! If you want to pass matrices between Matrix unit and this unit, you must transpose them !

As you can see, matrices below are not declared explicitly as 2-dimensional arrays (like array [0..3, 0..3] of Single), but they are 1-dimensional arrays of vectors. This is sometimes useful and comfortable.

PMatrix2Single = ˆTMatrix2Single;
 
TMatrix2Double = Tmatrix2_double_data;
 
PMatrix2Double = ˆTMatrix2Double;
 
TMatrix2Longint = packed array[0..1]of TVector2Longint;
 
PMatrix2Longint = ˆTMatrix2Longint;
 
TMatrix3Single = Tmatrix3_single_data;
 
PMatrix3Single = ˆTMatrix3Single;
 
TMatrix3Double = Tmatrix3_double_data;
 
PMatrix3Double = ˆTMatrix3Double;
 
TMatrix3Longint = packed array[0..2]of TVector3Longint;
 
PMatrix3Longint = ˆTMatrix3Longint;
 
TMatrix4Single = Tmatrix4_single_data;
 
PMatrix4Single = ˆTMatrix4Single;
 
TMatrix4Double = Tmatrix4_double_data;
 
PMatrix4Double = ˆTMatrix4Double;
 
TMatrix4Longint = packed array[0..3]of TVector4Longint;
 
PMatrix4Longint = ˆTMatrix4Longint;
 
TArray_Vector2Byte = packed array [0..MaxInt div SizeOf(TVector2Byte)-1] of TVector2Byte;
 
PArray_Vector2Byte = ˆTArray_Vector2Byte;
 
TArray_Vector3Byte = packed array [0..MaxInt div SizeOf(TVector3Byte)-1] of TVector3Byte;
 
PArray_Vector3Byte = ˆTArray_Vector3Byte;
 
TArray_Vector4Byte = packed array [0..MaxInt div SizeOf(TVector4Byte)-1] of TVector4Byte;
 
PArray_Vector4Byte = ˆTArray_Vector4Byte;
 
TArray_Vector2Cardinal = packed array [0..MaxInt div SizeOf(TVector2Cardinal) - 1] of TVector2Cardinal;
 
PArray_Vector2Cardinal = ˆTArray_Vector2Cardinal;
 
TArray_Vector2Extended = packed array [0..MaxInt div SizeOf(TVector2Extended) - 1] of TVector2Extended;
 
PArray_Vector2Extended = ˆTArray_Vector2Extended;
 
TArray_Vector2Single = packed array [0..MaxInt div SizeOf(TVector2Single) - 1] of TVector2Single;
 
PArray_Vector2Single = ˆTArray_Vector2Single;
 
TArray_Vector3Single = packed array [0..MaxInt div SizeOf(TVector3Single) - 1] of TVector3Single;
 
PArray_Vector3Single = ˆTArray_Vector3Single;
 
TArray_Vector4Single = packed array [0..MaxInt div SizeOf(TVector4Single) - 1] of TVector4Single;
 
PArray_Vector4Single = ˆTArray_Vector4Single;
 
TVector3CardinalList = specialize TGenericStructList<TVector3Cardinal>;
 
TVector2SmallIntList = specialize TGenericStructList<TVector2SmallInt>;
 
TGetVertexFromIndexFunc = function (Index: integer): TVector3Single of object;
 

Constants

ZeroVector2Integer: TVector2Integer = (0, 0);
 
ZeroVector2Single: TVector2Single = (0, 0);
 
ZeroVector2Double: TVector2Double = (0, 0);
 
ZeroVector3Single: TVector3Single = (0, 0, 0);
 
ZeroVector3Double: TVector3Double = (0, 0, 0);
 
ZeroVector4Single: TVector4Single = (0, 0, 0, 0);
 
ZeroVector4Double: TVector4Double = (0, 0, 0, 0);
 
ZeroMatrix2Single: TMatrix2Single = ((0, 0), (0, 0));
 
ZeroMatrix2Double: TMatrix2Double = ((0, 0), (0, 0));
 
ZeroMatrix2Longint: TMatrix2Longint = ((0, 0), (0, 0));
 
ZeroMatrix3Single: TMatrix3Single = ((0, 0, 0), (0, 0, 0), (0, 0, 0));
 
ZeroMatrix3Double: TMatrix3Double = ((0, 0, 0), (0, 0, 0), (0, 0, 0));
 
ZeroMatrix3Longint: TMatrix3Longint = ((0, 0, 0), (0, 0, 0), (0, 0, 0));
 
ZeroMatrix4Single: TMatrix4Single = ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0));
 
ZeroMatrix4Double: TMatrix4Double = ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0));
 
ZeroMatrix4Longint: TMatrix4Longint = ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0));
 
IdentityMatrix2Single: TMatrix2Single = ((1, 0), (0, 1));
 
IdentityMatrix2Double: TMatrix2Double = ((1, 0), (0, 1));
 
IdentityMatrix2Longint: TMatrix2Longint = ((1, 0), (0, 1));
 
IdentityMatrix3Single: TMatrix3Single = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
 
IdentityMatrix3Double: TMatrix3Double = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
 
IdentityMatrix3Longint: TMatrix3Longint = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
 
IdentityMatrix4Single: TMatrix4Single = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
 
IdentityMatrix4Double: TMatrix4Double = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
 
IdentityMatrix4Longint: TMatrix4Longint = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
 
UnitVector3Single: array[0..2]of TVector3Single = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
 
UnitVector3Double: array[0..2]of TVector3Double = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
 
UnitVector4Single: array[0..3]of TVector4Single = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
 
UnitVector4Double: array[0..3]of TVector4Double = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
 

Variables

SingleEqualityEpsilon: Single = 1e-7;

Values that differ less than given *EqualityEpsilon are assumed as equal by FloatsEqual (and so by all other routines in this unit).

Note that initial *EqualityEpsilon values are quite large, if you compare them with the epsilons used by CastleUtils.SameValue or Math.SameValue. Well, unfortunately they have to be so large, to always detect collisions.

You can change the variables below (but always keep them >= 0).

Exact 0 always means that exact comparison will be used.

DoubleEqualityEpsilon: Double = 1e-12;
 
ExtendedEqualityEpsilon: Extended = 1e-16;
 
FloatNiceFormat: string = 'f';
 

Generated by PasDoc 0.14.0.