Unit CastleVectors

Description

Vector and matrix types and basic geometric operations.

Various routines in this unit perform operations on geometric objects, like spheres and line segments. Here's an outline how do we represent various geometric objects:

  • Plane in 3D space is a vector of 4 values. 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. It is called 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.

  • An axis-aligned 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.

  • 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.

Requirements of the geometric objects:

In descriptions of the geometric objects above, you can see some requirements, e.g. "the triangle must not be degenerated (equivalent to a line segment)", "RayDirection must not be a zero vector", etc. 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 exceptions (like an arithmetic exception) or nonsensible results. So try to make sure that the values you pass satisfy the requirements.

However, wrong input values should never lead to exceptions that would be a security risk, like access violations or range check errors. As these exceptions could be uncatched in some situations, and then allow accessing a memory that otherwise should not be accessed, so we protect from this. Sometimes you simply cannot guarantee for 100% that input values are correct, because the floating-point operations are inherently not precise.

About floating-point precision:

  • As floating-point operations are never precise, when comparing floating-point values we always use some epsilon to "tolerate" some small differences.

    This epsilon is either done through the standard Math.SameValue and Math.IsZero or by using our own SingleEpsilon and DoubleEpsilon constants (they are equal to standard Math unit epsilon values). The floating-point vector and matrix comparison methods, like TVector3.Equals and TVector3.IsZero, compare with such epsilon.

    If you really want to compare things precisely, use methods like TVector3.PerfectlyEquals or TVector3.IsPerfectlyZero.

  • 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.

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Record TVector2Byte Vector of 2 Byte values.
Record TVector3Byte Vector of 3 Byte values.
Record TVector4Byte Vector of 4 Byte values.
Record TVector2Integer Vector of 2 Integer values.
Record TVector3Integer Vector of 3 Integer values.
Record TVector4Integer Vector of 4 Integer values.
Record TVector2Cardinal Vector of 2 Cardinal values.
Record TVector3Cardinal Vector of 3 Cardinal values.
Record TVector4Cardinal Vector of 4 Cardinal values.
Record TVector2SmallInt Vector of 2 SmallInt values.
Class TVector2List List of TVector2.
Class TVector3List List of TVector3.
Class TVector4List List of TVector4.
Class TMatrix3List List of TMatrix3.
Class TMatrix4List List of TMatrix4.
Class TVector2DoubleList List of TVector2Double.
Class TVector3DoubleList List of TVector3Double.
Class TVector4DoubleList List of TVector4Double.
Class TMatrix3DoubleList List of TMatrix3Double.
Class TMatrix4DoubleList List of TMatrix4Double.
Record TVector4Pointer Vector of 4 Pointers.
Class EPlanesParallel  
Class ELinesParallel  

Functions and Procedures

function Vector2(const X, Y: Single): TVector2; overload; inline;
function Vector2(const V: TVector2Double): TVector2; overload; inline;
function Vector2Double(const X, Y: Double): TVector2Double; inline;
function Vector3(const X, Y, Z: Single): TVector3; overload; inline;
function Vector3(const V: TVector2; const Z: Single): TVector3; overload; inline;
function Vector3(const V: TVector3Double): TVector3; overload; inline;
function Vector3Double(const X, Y, Z: Double): TVector3Double; overload; inline;
function Vector3Double(const V: TVector3): TVector3Double; overload; inline;
function Vector4(const X, Y, Z, W: Single): TVector4; overload; inline;
function Vector4(const V: TVector3; const W: Single): TVector4; overload; inline;
function Vector4(const V: TVector2; const Z, W: Single): TVector4; overload; inline;
function Vector4(const V: TVector4Double): TVector4; overload; inline;
function Vector4Double(const X, Y, Z, W: Double): TVector4Double; overload; inline;
function Vector4Double(const V: TVector4): TVector4Double; overload; inline;
function Matrix3(const V: TMatrix3Double): TMatrix3;
function Matrix4(const V: TMatrix4Double): TMatrix4;
function Matrix3Double(const V: TMatrix3): TMatrix3Double;
function Matrix4Double(const V: TMatrix4): TMatrix4Double;
function Vector2FromStr(const S: string): TVector2;
function Vector3FromStr(const S: string): TVector3;
function Vector4FromStr(const S: string): TVector4;
function Lerp(const A: Single; const V1, V2: TVector2): TVector2; overload; inline;
function Lerp(const A: Single; const V1, V2: TVector3): TVector3; overload; inline;
function Lerp(const A: Single; const V1, V2: TVector4): TVector4; overload; inline;
function Lerp(const A: Single; const M1, M2: TMatrix2): TMatrix2; overload; inline;
function Lerp(const A: Single; const M1, M2: TMatrix3): TMatrix3; overload; inline;
function Lerp(const A: Single; const M1, M2: TMatrix4): TMatrix4; overload; inline;
function Lerp(const A: Double; const V1, V2: TVector2Double): TVector2Double; overload; inline;
function Lerp(const A: Double; const V1, V2: TVector3Double): TVector3Double; overload; inline;
function Lerp(const A: Double; const V1, V2: TVector4Double): TVector4Double; overload; inline;
function Lerp(const A: Double; const M1, M2: TMatrix2Double): TMatrix2Double; overload; inline;
function Lerp(const A: Double; const M1, M2: TMatrix3Double): TMatrix3Double; overload; inline;
function Lerp(const A: Double; const M1, M2: TMatrix4Double): TMatrix4Double; overload; inline;
function TryInverseHarder(const M: TMatrix4; out MInverse: TMatrix4): boolean;
function CosAngleBetweenVectors(const V1, V2: TVector3): Single; overload;
function CosAngleBetweenNormals(const V1, V2: TVector3): Single; overload;
function AngleRadBetweenVectors(const V1, V2: TVector3): Single; overload;
function AngleRadBetweenNormals(const V1, V2: TVector3): Single; overload;
function RotationAngleRadBetweenVectors(const V1, V2: TVector3): Single; overload;
function RotationAngleRadBetweenVectors(const V1, V2, Cross: TVector3): Single; overload;
function RotatePointAroundAxisRad(const Angle: Single; const Point: TVector3; const Axis: TVector3): TVector3; overload;
function RotatePointAroundAxisDeg(const Angle: Single; const Point: TVector3; const Axis: TVector3): TVector3; overload;
function RotatePointAroundAxis(const AxisAngle: TVector4; const Point: TVector3): TVector3;
function MaxVectorCoord(const v: TVector2): integer; overload;
function MaxVectorCoord(const v: TVector3): integer; overload;
function MaxVectorCoord(const v: TVector4): integer; overload;
function MaxAbsVectorCoord(const v: TVector2): integer; overload;
function MaxAbsVectorCoord(const v: TVector3): integer; overload;
function MinVectorCoord(const v: TVector3): integer; overload;
procedure SortAbsVectorCoord(const v: TVector3; out Max, Middle, Min: Integer); overload;
function PlaneDirInDirection(const Plane: TVector4; const Direction: TVector3): TVector3; overload;
function PlaneDirInDirection(const PlaneDir, Direction: TVector3): TVector3; overload;
function PlaneDirNotInDirection(const Plane: TVector4; const Direction: TVector3): TVector3; overload;
function PlaneDirNotInDirection(const PlaneDir, Direction: TVector3): TVector3; overload;
function SwapEndian(const V: TVector2): TVector2; overload;
function SwapEndian(const V: TVector3): TVector3; overload;
function SwapEndian(const V: TVector4): TVector4; overload;
function LEtoN(const V: TVector2): TVector2; overload;
function LEtoN(const V: TVector3): TVector3; overload;
function LEtoN(const V: TVector4): TVector4; overload;
function BEtoN(const V: TVector2): TVector2; overload;
function BEtoN(const V: TVector3): TVector3; overload;
function BEtoN(const V: TVector4): TVector4; overload;
function NtoLE(const V: TVector2): TVector2; overload;
function NtoLE(const V: TVector3): TVector3; overload;
function NtoLE(const V: TVector4): TVector4; overload;
function NtoBE(const V: TVector2): TVector2; overload;
function NtoBE(const V: TVector3): TVector3; overload;
function NtoBE(const V: TVector4): TVector4; overload;
procedure SwapValues(var V1, V2: TVector2); overload;
procedure SwapValues(var V1, V2: TVector3); overload;
procedure SwapValues(var V1, V2: TVector4); overload;
procedure NormalizePlaneVar(var v: TVector4); overload;
procedure TwoPlanesIntersectionLine(const Plane0, Plane1: TVector4; out Line0, LineVector: TVector3); overload;
function Lines2DIntersection(const Line0, Line1: TVector3): TVector2; overload;
function ThreePlanesIntersectionPoint( const Plane0, Plane1, Plane2: TVector4): TVector3; overload;
function PlaneMove(const Plane: TVector4; const Move: TVector3): TVector4; overload;
procedure PlaneMoveVar(var Plane: TVector4; const Move: TVector3); overload;
function PlaneAntiMove(const Plane: TVector4; const Move: TVector3): TVector4; overload;
function VectorsSamePlaneDirections(const V1, V2: TVector3; const Plane: TVector4): boolean; overload;
function VectorsSamePlaneDirections(const V1, V2: TVector3; const PlaneDir: TVector3): boolean; overload;
function PointsSamePlaneSides(const p1, p2: TVector3; const Plane: TVector4): boolean; overload;
function PointsDistance(const V1, V2: TVector2): Single; overload;
function PointsDistance(const V1, V2: TVector3): Single; overload;
function PointsDistanceSqr(const V1, V2: TVector2): Single; overload;
function PointsDistanceSqr(const V1, V2: TVector3): Single; overload;
function PointsDistance2DSqr(const V1, V2: TVector3; const IgnoreIndex: Integer): Single; overload;
function VectorsPerp(const V1, V2: TVector3): boolean; overload;
function VectorsParallel(const V1, V2: TVector3): boolean; overload;
procedure MakeVectorsAngleRadOnTheirPlane(var v1: TVector3; const v2: TVector3; const AngleRad: Single; const ResultWhenParallel: TVector3); overload;
procedure MakeVectorsOrthoOnTheirPlane(var v1: TVector3; const v2: TVector3); overload;
function AnyOrthogonalVector(const v: TVector2): TVector2; overload;
function AnyOrthogonalVector(const v: TVector3): TVector3; overload;
function IsLineParallelToPlane(const lineVector: TVector3; const plane: TVector4): boolean; overload;
function IsLineParallelToSimplePlane(const lineVector: TVector3; const PlaneConstCoord: integer): boolean; overload;
function AreParallelVectorsSameDirection( const Vector1, Vector2: TVector3): boolean; overload;
function PointOnPlaneClosestToPoint(const plane: TVector4; const point: TVector3): TVector3; overload;
function PointToPlaneDistanceSqr(const Point: TVector3; const Plane: TVector4): Single; overload;
function PointToNormalizedPlaneDistance(const Point: TVector3; const Plane: TVector4): Single; overload;
function PointToPlaneDistance(const Point: TVector3; const Plane: TVector4): Single; overload;
function PointToSimplePlaneDistance(const point: TVector3; const PlaneConstCoord: integer; const PlaneConstValue: Single): Single; overload;
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector2): TVector2; overload;
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector3): TVector3; overload;
function PointToLineDistanceSqr(const point, line0, lineVector: TVector3): Single; overload;
function TryPlaneLineIntersection(out intersection: TVector3; const plane: TVector4; const line0, lineVector: TVector3): boolean; overload;
function TryPlaneLineIntersection(out t: Single; const plane: TVector4; const line0, lineVector: TVector3): boolean; overload;
function TrySimplePlaneRayIntersection(out Intersection: TVector3; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3): boolean; overload;
function TrySimplePlaneRayIntersection(out Intersection: TVector3; out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3): boolean; overload;
function TrySimplePlaneRayIntersection(out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3): boolean; overload;
function TryPlaneRayIntersection(out Intersection: TVector3; const Plane: TVector4; const RayOrigin, RayDirection: TVector3): boolean; overload;
function TryPlaneRayIntersection(out Intersection: TVector3; out T: Single; const Plane: TVector4; const RayOrigin, RayDirection: TVector3): boolean; overload;
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3): boolean; overload;
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3; out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3): boolean; overload;
function TrySimplePlaneSegmentIntersection( out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3): boolean; overload;
function TryPlaneSegmentDirIntersection(out Intersection: TVector3; const Plane: TVector4; const Segment0, SegmentVector: TVector3): boolean; overload;
function TryPlaneSegmentDirIntersection(out Intersection: TVector3; out T: Single; const Plane: TVector4; const Segment0, SegmentVector: TVector3): boolean; overload;
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector2): boolean; overload;
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector3): boolean; overload;
function LineOfTwoDifferentPoints2d(const p1, p2: TVector2): TVector3; overload;
function PointToSegmentDistanceSqr(const point, pos1, pos2: TVector3): Single; overload;
function PlaneTransform(const Plane: TVector4; const Matrix: TMatrix4): TVector4;
function IsTunnelSphereCollision(const Tunnel1, Tunnel2: TVector3; const TunnelRadius: Single; const SphereCenter: TVector3; const SphereRadius: Single): boolean; overload;
function IsSpheresCollision(const Sphere1Center: TVector3; const Sphere1Radius: Single; const Sphere2Center: TVector3; const Sphere2Radius: Single): boolean; overload;
function IsSegmentSphereCollision(const pos1, pos2, SphereCenter: TVector3; const SphereRadius: Single): boolean; overload;
function TrySphereRayIntersection(out Intersection: TVector3; const SphereCenter: TVector3; const SphereRadius: Single; const RayOrigin, RayDirection: TVector3): boolean; overload;
function TryCylinderRayIntersection(out Intersection: TVector3; const CylinderAxisOrigin, CylinderAxis: TVector3; const CylinderRadius: Single; const RayOrigin, RayDirection: TVector3): boolean; overload;
function TranslationMatrix(const X, Y, Z: Single): TMatrix4; overload;
function TranslationMatrix(const Transl: TVector3): TMatrix4; overload;
procedure TranslationMatrices(const X, Y, Z: Single; out Matrix, InvertedMatrix: TMatrix4); overload;
procedure TranslationMatrices(const Transl: TVector3; out Matrix, InvertedMatrix: TMatrix4); overload;
procedure MultMatrixTranslation(var M: TMatrix4; const Transl: TVector3); overload;
procedure MultMatricesTranslation(var M, MInvert: TMatrix4; const Transl: TVector3); overload;
function TransformToCoordsMatrix(const NewX, NewY, NewZ: TVector3): TMatrix4; overload;
function TransformToCoordsMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3): TMatrix4; overload;
function TransformToCoordsNoScaleMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3): TMatrix4; overload;
function TransformFromCoordsMatrix(const OldX, OldY, OldZ: TVector3): TMatrix4; overload;
function TransformFromCoordsMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3): TMatrix4; overload;
function TransformFromCoordsNoScaleMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3): TMatrix4; overload;
procedure TransformCoordsMatrices(const NewX, NewY, NewZ: TVector3; out ToCoords, FromCoords: TMatrix4); overload;
function TransformToCoords(const V, NewX, NewY, NewZ: TVector3): TVector3;
function LookAtMatrix(const Eye, Center, Up: TVector3): TMatrix4; overload;
function LookDirMatrix(const Eye, Dir, Up: TVector3): TMatrix4; overload;
function LookDirMatrix(const Eye, Dir, Side, Up: TVector3): TMatrix4; overload;
function FastLookDirMatrix(const Direction, Up: TVector3): TMatrix4;
function InverseFastLookDirMatrix(const Direction, Up: TVector3): TMatrix4;
function ModelViewToNormalMatrix(const M: TMatrix4): TMatrix3;
function VectorMultTransposedSameVector(const v: TVector3): TMatrix4;
function ScalingMatrix(const ScaleFactor: TVector3): TMatrix4;
procedure ScalingMatrices(const ScaleFactor: TVector3; InvertedMatrixIdentityIfNotExists: boolean; out Matrix, InvertedMatrix: TMatrix4);
function RotationMatrixRad(const AngleRad: Single; const Axis: TVector3): TMatrix4; overload;
function RotationMatrixDeg(const AngleDeg: Single; const Axis: TVector3): TMatrix4; overload;
function RotationMatrixRad(const AngleRad: Single; const AxisX, AxisY, AxisZ: Single): TMatrix4; overload;
function RotationMatrixDeg(const AngleDeg: Single; const AxisX, AxisY, AxisZ: Single): TMatrix4; overload;
procedure RotationMatricesRad(const AngleRad: Single; const Axis: TVector3; out Matrix, InvertedMatrix: TMatrix4); overload;
procedure RotationMatricesRad(const AxisAngle: TVector4; out Matrix, InvertedMatrix: TMatrix4); overload;
function RotationNegate(const Rotation: TVector4): TVector4;
function RotatePoint2D(const Point: TVector2; const AngleRad: Single): TVector2;
function Approximate3DScale(const X, Y, Z: Single): Single; overload;
function Approximate3DScale(const V: TVector3): Single; overload;
function Approximate2DScale(const X, Y: Single): Single; overload;
function Approximate2DScale(const V: TVector2): Single; overload;
function ThreePlanesIntersectionPointDouble( const Plane0, Plane1, Plane2: TVector4Double): TVector3Double; overload;
function Vector2Byte(const X, Y: Byte): TVector2Byte; overload; inline;
function Vector3Byte(const X, Y, Z: Byte): TVector3Byte; overload; inline;
function Vector4Byte(const X, Y, Z, W: Byte): TVector4Byte; overload; inline;
function Vector2Byte(const V: TVector2): TVector2Byte; overload;
function Vector3Byte(const V: TVector3): TVector3Byte; overload;
function Vector4Byte(const V: TVector4): TVector4Byte; overload;
function Vector2(const V: TVector2Byte): TVector2; overload;
function Vector3(const V: TVector3Byte): TVector3; overload;
function Vector4(const V: TVector4Byte): TVector4; overload;
function Lerp(const A: Single; const V1, V2: TVector2Byte): TVector2Byte; overload; inline;
function Lerp(const A: Single; const V1, V2: TVector3Byte): TVector3Byte; overload; inline;
function Lerp(const A: Single; const V1, V2: TVector4Byte): TVector4Byte; overload; inline;
function Vector2Integer(const X, Y: Integer): TVector2Integer; inline;
function Vector3Integer(const X, Y, Z: Integer): TVector3Integer; inline;
function Vector4Integer(const X, Y, Z, W: Integer): TVector4Integer; inline;
function Vector2Cardinal(const X, Y: Cardinal): TVector2Cardinal; inline;
function Vector3Cardinal(const X, Y, Z: Cardinal): TVector3Cardinal; inline;
function Vector4Cardinal(const X, Y, Z, W: Cardinal): TVector4Cardinal; inline;
function Vector2SmallInt(const X, Y: SmallInt): TVector2SmallInt; inline;
function Vector2Single(const X, Y: Single): TVector2; overload; deprecated 'use Vector2';
function Vector2Single(const V: TVector2Double): TVector2; overload; deprecated 'use Vector2';
function Vector3Single(const X, Y, Z: Single): TVector3; overload; deprecated 'use Vector3';
function Vector3Single(const V: TVector2; const Z: Single): TVector3; overload; deprecated 'use Vector3';
function Vector3Single(const V: TVector3Double): TVector3; overload; deprecated 'use Vector3';
function Vector4Single(const X, Y, Z, W: Single): TVector4; overload; deprecated 'use Vector4';
function Vector4Single(const V: TVector3; const W: Single): TVector4; overload; deprecated 'use Vector4';
function Vector4Single(const V: TVector4Double): TVector4; overload; deprecated 'use Vector4';
function FloatsEqual(const A, B: Single): boolean; overload; deprecated 'use Math.SameValue';
function FloatsEqual(const A, B: Single; const Epsilon: Single): boolean; overload; deprecated 'use Math.SameValue';
function FloatToNiceStr(const A: Single): string; overload; deprecated 'use Format(''%f'', [Value])';
function FloatToRawStr(const A: Single): string; overload; deprecated 'use Format(''%g'', [Value])';
function Zero(const A: Single): boolean; overload; deprecated 'use Math.IsZero';
function VectorAdd(const V1, V2: TVector2): TVector2; overload; deprecated 'use V1 + V2';
function VectorAdd(const V1, V2: TVector3): TVector3; overload; deprecated 'use V1 + V2';
function VectorAdd(const V1, V2: TVector4): TVector4; overload; deprecated 'use V1 + V2';
function VectorSubtract(const V1, V2: TVector2): TVector2; overload; deprecated 'use V1 - V2';
function VectorSubtract(const V1, V2: TVector3): TVector3; overload; deprecated 'use V1 - V2';
function VectorSubtract(const V1, V2: TVector4): TVector4; overload; deprecated 'use V1 - V2';
function VectorMultiplyComponents(const V1, V2: TVector2): TVector2; overload; deprecated 'use V1 * V2';
function VectorMultiplyComponents(const V1, V2: TVector3): TVector3; overload; deprecated 'use V1 * V2';
function VectorMultiplyComponents(const V1, V2: TVector4): TVector4; overload; deprecated 'use V1 * V2';
function VectorProduct(const V1, V2: TVector3): TVector3; overload; deprecated 'use TVector3.CrossProduct';
function Normalized(const V: TVector2): TVector2; overload; deprecated 'use V.Normalize method';
function Normalized(const V: TVector3): TVector3; overload; deprecated 'use V.Normalize method';
procedure NormalizeVar(var V: TVector2); overload; deprecated 'use V.NormalizeMe method';
procedure NormalizeVar(var V: TVector3); overload; deprecated 'use V.NormalizeMe method';
function MatrixMult(const M1, M2: TMatrix4): TMatrix4; overload; deprecated 'use * operator to multiply matrices';
function MatrixMultPoint(const M: TMatrix4; const P: TVector2): TVector2; overload; deprecated 'use M.MultPoint method';
function MatrixMultPoint(const M: TMatrix4; const P: TVector3): TVector3; overload; deprecated 'use M.MultPoint method';
function MatrixMultDirection(const M: TMatrix4; const P: TVector2): TVector2; overload; deprecated 'use M.MultDirection method';
function MatrixMultDirection(const M: TMatrix4; const P: TVector3): TVector3; overload; deprecated 'use M.MultDirection method';
function VectorLenSqr(const V: TVector2): Single; overload; deprecated 'use V.LengthSqr';
function VectorLenSqr(const V: TVector3): Single; overload; deprecated 'use V.LengthSqr';
function VectorLenSqr(const V: TVector4): Single; overload; deprecated 'use V.LengthSqr';
function VectorLen(const V: TVector2): Single; overload; deprecated 'use V.Length';
function VectorLen(const V: TVector3): Single; overload; deprecated 'use V.Length';
function VectorLen(const V: TVector4): Single; overload; deprecated 'use V.Length';
function VectorAverage(const V: TVector3): Single; overload; deprecated 'use V.Average';
function VectorToRawStr(const V: TVector2): string; overload; deprecated 'use V.ToRawString';
function VectorToRawStr(const V: TVector3): string; overload; deprecated 'use V.ToRawString';
function VectorToRawStr(const V: TVector4): string; overload; deprecated 'use V.ToRawString';
function VectorToNiceStr(const V: TVector2): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector3): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector4): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector2Integer): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector3Integer): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector4Integer): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector2Cardinal): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector3Cardinal): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector4Cardinal): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector2Byte): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector3Byte): string; overload; deprecated 'use V.ToString';
function VectorToNiceStr(const V: TVector4Byte): string; overload; deprecated 'use V.ToString';
function ZeroVector(const V: TVector2): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector3): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector4): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector2Byte): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector3Byte): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector4Byte): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector2Integer): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector3Integer): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector4Integer): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector2Cardinal): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector3Cardinal): boolean; overload; deprecated 'use V.IsZero';
function ZeroVector(const V: TVector4Cardinal): boolean; overload; deprecated 'use V.IsZero';
function PerfectlyZeroVector(const V: TVector2): boolean; overload; deprecated 'use V.IsPerfectlyZero';
function PerfectlyZeroVector(const V: TVector3): boolean; overload; deprecated 'use V.IsPerfectlyZero';
function PerfectlyZeroVector(const V: TVector4): boolean; overload; deprecated 'use V.IsPerfectlyZero';
function VectorAdjustToLength(const V: TVector2; const NewLength: Single): TVector2; overload; deprecated 'use V.AdjustToLength';
function VectorAdjustToLength(const V: TVector3; const NewLength: Single): TVector3; overload; deprecated 'use V.AdjustToLength';
function VectorAdjustToLength(const V: TVector4; const NewLength: Single): TVector4; overload; deprecated 'use V.AdjustToLength';
function Vector2SingleFromStr(const S: string): TVector2; overload; deprecated 'use Vector2FromStr';
function Vector3SingleFromStr(const s: string): TVector3; overload; deprecated 'use Vector3FromStr';
function Vector4SingleFromStr(const S: string): TVector4; overload; deprecated 'use Vector4FromStr';
function VectorDotProduct(const V1, V2: TVector2): Single; overload; deprecated 'use TVector2.DotProduct(V1, V2)';
function VectorDotProduct(const V1, V2: TVector3): Single; overload; deprecated 'use TVector3.DotProduct(V1, V2)';
function VectorDotProduct(const V1, V2: TVector4): Single; overload; deprecated 'use TVector4.DotProduct(V1, V2)';
function VectorsEqual(const V1, V2: TVector2): boolean; overload; deprecated 'use TVector2.Equals(V1, V2)';
function VectorsEqual(const V1, V2: TVector3): boolean; overload; deprecated 'use TVector3.Equals(V1, V2)';
function VectorsEqual(const V1, V2: TVector4): boolean; overload; deprecated 'use TVector4.Equals(V1, V2)';
function VectorsEqual(const V1, V2: TVector2; const Epsilon: Single): boolean; overload; deprecated 'use TVector2.Equals(V1, V2, Epsilon)';
function VectorsEqual(const V1, V2: TVector3; const Epsilon: Single): boolean; overload; deprecated 'use TVector3.Equals(V1, V2, Epsilon)';
function VectorsEqual(const V1, V2: TVector4; const Epsilon: Single): boolean; overload; deprecated 'use TVector4.Equals(V1, V2, Epsilon)';
function VectorsPerfectlyEqual(const V1, V2: TVector2): boolean; overload; deprecated 'use TVector2.PerfectlyEquals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector3): boolean; overload; deprecated 'use TVector3.PerfectlyEquals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector4): boolean; overload; deprecated 'use TVector4.PerfectlyEquals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector2Byte): boolean; overload; deprecated 'use TVector2Byte.Equals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector3Byte): boolean; overload; deprecated 'use TVector3Byte.Equals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector4Byte): boolean; overload; deprecated 'use TVector4Byte.Equals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector2Integer): boolean; overload; deprecated 'use TVector2Integer.Equals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector3Integer): boolean; overload; deprecated 'use TVector3Integer.Equals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector4Integer): boolean; overload; deprecated 'use TVector4Integer.Equals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector2Cardinal): boolean; overload; deprecated 'use TVector2Cardinal.Equals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector3Cardinal): boolean; overload; deprecated 'use TVector3Cardinal.Equals(V1, V2)';
function VectorsPerfectlyEqual(const V1, V2: TVector4Cardinal): boolean; overload; deprecated 'use TVector4Cardinal.Equals(V1, V2)';
function TryMatrixInverse(const M: TMatrix2; out MInverse: TMatrix2): boolean; overload; overload; deprecated 'use TMatrix2.TryInverse';
function TryMatrixInverse(const M: TMatrix3; out MInverse: TMatrix3): boolean; overload; overload; deprecated 'use TMatrix3.TryInverse';
function TryMatrixInverse(const M: TMatrix4; out MInverse: TMatrix4): boolean; overload; overload; deprecated 'use TMatrix4.TryInverse';
function MatrixToRawStr(const M: TMatrix2; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix2.ToRawString';
function MatrixToRawStr(const M: TMatrix3; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix3.ToRawString';
function MatrixToRawStr(const M: TMatrix4; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix4.ToRawString';
function MatrixToNiceStr(const M: TMatrix2; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix2.ToString';
function MatrixToNiceStr(const M: TMatrix3; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix3.ToString';
function MatrixToNiceStr(const M: TMatrix4; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix4.ToString';
function MatricesPerfectlyEqual(const V1, V2: TMatrix2): boolean; overload; deprecated 'use TMatrix2.PerfectlyEquals(V1, V2)';
function MatricesPerfectlyEqual(const V1, V2: TMatrix3): boolean; overload; deprecated 'use TMatrix3.PerfectlyEquals(V1, V2)';
function MatricesPerfectlyEqual(const V1, V2: TMatrix4): boolean; overload; deprecated 'use TMatrix4.PerfectlyEquals(V1, V2)';
function MatrixRow(const M: TMatrix2; const Row: Integer): TVector2; overload; overload; deprecated 'use TMatrix2.Rows[Row]';
function MatrixRow(const M: TMatrix3; const Row: Integer): TVector3; overload; overload; deprecated 'use TMatrix3.Rows[Row]';
function MatrixRow(const M: TMatrix4; const Row: Integer): TVector4; overload; overload; deprecated 'use TMatrix4.Rows[Row]';
function Vector2SingleCut(const V: TVector3): TVector2; overload; deprecated 'use V.XY';
function Vector3SingleCut(const V: TVector4): TVector3; overload; deprecated 'use V.XYZ';
function Matrix3Single(const V: TMatrix3Double): TMatrix3; overload; deprecated 'use Matrix3';
function Matrix4Single(const V: TMatrix4Double): TMatrix4; overload; deprecated 'use Matrix4';

Types

TVector2 = CastleVectorsInternalSingle.TGenericVector2;
PVector2 = ˆTVector2;
TVector2Double = CastleVectorsInternalDouble.TGenericVector2;
PVector2Double = ˆTVector2Double;
TVector3 = CastleVectorsInternalSingle.TGenericVector3;
PVector3 = ˆTVector3;
TVector3Double = CastleVectorsInternalDouble.TGenericVector3;
PVector3Double = ˆTVector3Double;
TVector4 = CastleVectorsInternalSingle.TGenericVector4;
PVector4 = ˆTVector4;
TVector4Double = CastleVectorsInternalDouble.TGenericVector4;
PVector4Double = ˆTVector4Double;
TMatrix2 = CastleVectorsInternalSingle.TGenericMatrix2;
PMatrix2 = ˆTMatrix2;
TMatrix2Double = CastleVectorsInternalDouble.TGenericMatrix2;
PMatrix2Double = ˆTMatrix2Double;
TMatrix3 = CastleVectorsInternalSingle.TGenericMatrix3;
PMatrix3 = ˆTMatrix3;
TMatrix3Double = CastleVectorsInternalDouble.TGenericMatrix3;
PMatrix3Double = ˆTMatrix3Double;
TMatrix4 = CastleVectorsInternalSingle.TGenericMatrix4;
PMatrix4 = ˆTMatrix4;
TMatrix4Double = CastleVectorsInternalDouble.TGenericMatrix4;
PMatrix4Double = ˆTMatrix4Double;
TVector2Array = packed array [0..MaxInt div SizeOf(TVector2) - 1] of TVector2;
PVector2Array = ˆTVector2Array;
TVector3Array = packed array [0..MaxInt div SizeOf(TVector3) - 1] of TVector3;
PVector3Array = ˆTVector3Array;
TVector4Array = packed array [0..MaxInt div SizeOf(TVector4) - 1] of TVector4;
PVector4Array = ˆTVector4Array;
TGetVertexFromIndexFunc = function (Index: integer): TVector3 of object;
PVector2Byte = ˆTVector2Byte;
PVector3Byte = ˆTVector3Byte;
PVector4Byte = ˆTVector4Byte;
TVector2ByteArray = packed array [0..MaxInt div SizeOf(TVector2Byte)-1] of TVector2Byte;
PVector2ByteArray = ˆTVector2ByteArray;
TVector3ByteArray = packed array [0..MaxInt div SizeOf(TVector3Byte)-1] of TVector3Byte;
PVector3ByteArray = ˆTVector3ByteArray;
TVector4ByteArray = packed array [0..MaxInt div SizeOf(TVector4Byte)-1] of TVector4Byte;
PVector4ByteArray = ˆTVector4ByteArray;
PVector2Integer = ˆTVector2Integer;
PVector3Integer = ˆTVector3Integer;
PVector4Integer = ˆTVector4Integer;
TVector2IntegerArray = packed array [0..MaxInt div SizeOf(TVector2Integer)-1] of TVector2Integer;
PVector2IntegerArray = ˆTVector2IntegerArray;
TVector3IntegerArray = packed array [0..MaxInt div SizeOf(TVector3Integer)-1] of TVector3Integer;
PVector3IntegerArray = ˆTVector3IntegerArray;
TVector4IntegerArray = packed array [0..MaxInt div SizeOf(TVector4Integer)-1] of TVector4Integer;
PVector4IntegerArray = ˆTVector4IntegerArray;
PVector2Cardinal = ˆTVector2Cardinal;
PVector3Cardinal = ˆTVector3Cardinal;
PVector4Cardinal = ˆTVector4Cardinal;
TVector2CardinalArray = packed array [0..MaxInt div SizeOf(TVector2Cardinal)-1] of TVector2Cardinal;
PVector2CardinalArray = ˆTVector2CardinalArray;
TVector3CardinalArray = packed array [0..MaxInt div SizeOf(TVector3Cardinal)-1] of TVector3Cardinal;
PVector3CardinalArray = ˆTVector3CardinalArray;
TVector4CardinalArray = packed array [0..MaxInt div SizeOf(TVector4Cardinal)-1] of TVector4Cardinal;
PVector4CardinalArray = ˆTVector4CardinalArray;
PVector2SmallInt = ˆTVector2SmallInt;
TVector2SmallIntList = specialize TStructList<TVector2SmallInt>;
TVector3CardinalList = specialize TStructList<TVector3Cardinal>;
TVector2Single = TVector2 deprecated;
TVector3Single = TVector3 deprecated;
TVector4Single = TVector4 deprecated;
TMatrix2Single = TMatrix2 deprecated;
TMatrix3Single = TMatrix3 deprecated;
TMatrix4Single = TMatrix4 deprecated;
TVector2SingleList = TVector2List deprecated;
TVector3SingleList = TVector3List deprecated;
TVector4SingleList = TVector4List deprecated;
TMatrix3SingleList = TMatrix3List deprecated;
TMatrix4SingleList = TMatrix4List deprecated;
TVector3LongInt = TVector3Integer deprecated;
PVector2Single = PVector2 deprecated;
PVector3Single = PVector3 deprecated;
PVector4Single = PVector4 deprecated;
PMatrix2Single = PMatrix2 deprecated;
PMatrix3Single = PMatrix3 deprecated;
PMatrix4Single = PMatrix4 deprecated;
PVector3LongInt = PVector3Integer deprecated;

Constants

ZeroVector2Single: TVector2 = (Data: (0, 0)) deprecated 'use TVector2.Zero';
ZeroVector3Single: TVector3 = (Data: (0, 0, 0)) deprecated 'use TVector3.Zero';
ZeroVector4Single: TVector4 = (Data: (0, 0, 0, 0)) deprecated 'use TVector4.Zero';
ZeroVector2Double: TVector2Double = (Data: (0, 0)) deprecated 'use TVector2Double.Zero';
ZeroVector3Double: TVector3Double = (Data: (0, 0, 0)) deprecated 'use TVector3Double.Zero';
ZeroVector4Double: TVector4Double = (Data: (0, 0, 0, 0)) deprecated 'use TVector4Double.Zero';
ZeroVector2Byte: TVector2Byte = (Data: (0, 0)) deprecated 'use TVector2Byte.Zero';
ZeroVector3Byte: TVector3Byte = (Data: (0, 0, 0)) deprecated 'use TVector3Byte.Zero';
ZeroVector4Byte: TVector4Byte = (Data: (0, 0, 0, 0)) deprecated 'use TVector4Byte.Zero';
ZeroVector2Integer: TVector2Integer = (Data: (0, 0)) deprecated 'use TVector2Integer.Zero';
ZeroVector3Integer: TVector3Integer = (Data: (0, 0, 0)) deprecated 'use TVector3Integer.Zero';
ZeroVector4Integer: TVector4Integer = (Data: (0, 0, 0, 0)) deprecated 'use TVector4Integer.Zero';
ZeroVector2Cardinal: TVector2Cardinal = (Data: (0, 0)) deprecated 'use TVector2Cardinal.Zero';
ZeroVector3Cardinal: TVector3Cardinal = (Data: (0, 0, 0)) deprecated 'use TVector3Cardinal.Zero';
ZeroVector4Cardinal: TVector4Cardinal = (Data: (0, 0, 0, 0)) deprecated 'use TVector4Cardinal.Zero';
ZeroMatrix2Single: TMatrix2 = (Data: ((0, 0), (0, 0))) deprecated 'use TMatrix2.Zero';
ZeroMatrix3Single: TMatrix3 = (Data: ((0, 0, 0), (0, 0, 0), (0, 0, 0))) deprecated 'use TMatrix3.Zero';
ZeroMatrix4Single: TMatrix4 = (Data: ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0))) deprecated 'use TMatrix4.Zero';
ZeroMatrix2Double: TMatrix2Double = (Data: ((0, 0), (0, 0))) deprecated 'use TMatrix2Double.Zero';
ZeroMatrix3Double: TMatrix3Double = (Data: ((0, 0, 0), (0, 0, 0), (0, 0, 0))) deprecated 'use TMatrix3Double.Zero';
ZeroMatrix4Double: TMatrix4Double = (Data: ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0))) deprecated 'use TMatrix4Double.Zero';
IdentityMatrix2Single: TMatrix2 = (Data: ((1, 0), (0, 1))) deprecated 'use TMatrix2.Identity';
IdentityMatrix3Single: TMatrix3 = (Data: ((1, 0, 0), (0, 1, 0), (0, 0, 1))) deprecated 'use TMatrix3.Identity';
IdentityMatrix4Single: TMatrix4 = (Data: ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))) deprecated 'use TMatrix4.Identity';
IdentityMatrix2Double: TMatrix2Double = (Data: ((1, 0), (0, 1))) deprecated 'use TMatrix2Double.Identity';
IdentityMatrix3Double: TMatrix3Double = (Data: ((1, 0, 0), (0, 1, 0), (0, 0, 1))) deprecated 'use TMatrix3Double.Identity';
IdentityMatrix4Double: TMatrix4Double = (Data: ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))) deprecated 'use TMatrix4Double.Identity';
UnitVector2Single: array [TVector2.TIndex] of TVector2 = ( (Data: (1, 0)), (Data: (0, 1)) ) deprecated 'use TVector2.One';
UnitVector3Single: array [TVector3.TIndex] of TVector3 = ( (Data: (1, 0, 0)), (Data: (0, 1, 0)), (Data: (0, 0, 1)) ) deprecated 'use TVector3.One';
UnitVector4Single: array [TVector4.TIndex] of TVector4 = ( (Data: (1, 0, 0, 0)), (Data: (0, 1, 0, 0)), (Data: (0, 0, 1, 0)), (Data: (0, 0, 0, 1)) ) deprecated 'use TVector4.One';
SingleEpsilon = 1E-4;
DoubleEpsilon = 1E-12;
SingleEqualityEpsilon = SingleEpsilon deprecated 'use SingleEpsilon';
DoubleEqualityEpsilon = DoubleEpsilon deprecated 'use DoubleEpsilon';
ExtendedEqualityEpsilon = 1E-16 deprecated 'use only Math functions, like SameValue and IsZero, to operate on Extended type; CastleVectors unit does not deal with Extended type anymore';

Description

Functions and Procedures

function Vector2(const X, Y: Single): TVector2; overload; inline;

Construct an initialized TVector2 value.

function Vector2(const V: TVector2Double): TVector2; overload; inline;
 
function Vector2Double(const X, Y: Double): TVector2Double; inline;

Construct an initialized TVector2Double value.

function Vector3(const X, Y, Z: Single): TVector3; overload; inline;

Construct an initialized TVector3 value.

function Vector3(const V: TVector2; const Z: Single): TVector3; overload; inline;
 
function Vector3(const V: TVector3Double): TVector3; overload; inline;
 
function Vector3Double(const X, Y, Z: Double): TVector3Double; overload; inline;

Construct an initialized TVector3Double value.

function Vector3Double(const V: TVector3): TVector3Double; overload; inline;
 
function Vector4(const X, Y, Z, W: Single): TVector4; overload; inline;

Construct an initialized TVector4 value.

function Vector4(const V: TVector3; const W: Single): TVector4; overload; inline;
 
function Vector4(const V: TVector2; const Z, W: Single): TVector4; overload; inline;
 
function Vector4(const V: TVector4Double): TVector4; overload; inline;
 
function Vector4Double(const X, Y, Z, W: Double): TVector4Double; overload; inline;

Construct an initialized TVector4Double value.

function Vector4Double(const V: TVector4): TVector4Double; overload; inline;
 
function Matrix3(const V: TMatrix3Double): TMatrix3;

Convert between Double-precision and Single-precision matrix.

function Matrix4(const V: TMatrix4Double): TMatrix4;
 
function Matrix3Double(const V: TMatrix3): TMatrix3Double;
 
function Matrix4Double(const V: TMatrix4): TMatrix4Double;
 
function Vector2FromStr(const S: string): TVector2;

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 Vector3FromStr(const S: string): TVector3;
 
function Vector4FromStr(const S: string): TVector4;
 
function Lerp(const A: Single; const V1, V2: TVector2): TVector2; overload; inline;

Linear interpolation between two vector values. Returns (1-A) * V1 + A * V2.

So:

  • A = 0 gives V1,

  • A = 1 gives V2,

  • values between are interpolated,

  • values outside are extrapolated.

function Lerp(const A: Single; const V1, V2: TVector3): TVector3; overload; inline;
 
function Lerp(const A: Single; const V1, V2: TVector4): TVector4; overload; inline;
 
function Lerp(const A: Single; const M1, M2: TMatrix2): TMatrix2; overload; inline;
 
function Lerp(const A: Single; const M1, M2: TMatrix3): TMatrix3; overload; inline;
 
function Lerp(const A: Single; const M1, M2: TMatrix4): TMatrix4; overload; inline;
 
function Lerp(const A: Double; const V1, V2: TVector2Double): TVector2Double; overload; inline;
 
function Lerp(const A: Double; const V1, V2: TVector3Double): TVector3Double; overload; inline;
 
function Lerp(const A: Double; const V1, V2: TVector4Double): TVector4Double; overload; inline;
 
function Lerp(const A: Double; const M1, M2: TMatrix2Double): TMatrix2Double; overload; inline;
 
function Lerp(const A: Double; const M1, M2: TMatrix3Double): TMatrix3Double; overload; inline;
 
function Lerp(const A: Double; const M1, M2: TMatrix4Double): TMatrix4Double; overload; inline;
 
function TryInverseHarder(const M: TMatrix4; out MInverse: TMatrix4): boolean;

Try to inverse single-precision matrix using double-precision, if necessary.

function CosAngleBetweenVectors(const V1, V2: TVector3): 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 CosAngleBetweenNormals(const V1, V2: TVector3): Single; overload;
 
function AngleRadBetweenVectors(const V1, V2: TVector3): 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 AngleRadBetweenNormals(const V1, V2: TVector3): Single; overload;
 
function RotationAngleRadBetweenVectors(const V1, V2: TVector3): 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, Cross: TVector3): Single; overload;
 
function RotatePointAroundAxisRad(const Angle: Single; const Point: TVector3; const Axis: TVector3): TVector3; overload;

Rotate Point around the Axis by given Angle. Axis does not have to be normalized (it will be normalized internally).

Axis can be an exact zero only if Angle is also an exact zero. This special case is supported to make it easier to initialize stuff. This way by default a vector and an angle can be left filled with zeros (like TCastleTransform.Rotation), and this function will accept them (in effect e.g. TCastleTransform.Direction will be valid). In all other cases, axis must be a non-zero vector.

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

M := RotationMatrixRad(Angle, Axis);
Result := M.MultPoint(Point);

Except this will be a little faster.

Rotations are done in the same direction as RotationMatrixRad, and as OpenGL.

function RotatePointAroundAxisDeg(const Angle: Single; const Point: TVector3; const Axis: TVector3): TVector3; overload;
 
function RotatePointAroundAxis(const AxisAngle: TVector4; const Point: TVector3): TVector3;

Rotate Point around the given axis by a given angle. Axis is specified in the first 3 components of AxisAngle, rotation angle (in radians) is specified in the last component of AxisAngle.

function MaxVectorCoord(const v: TVector2): 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: TVector3): integer; overload;
 
function MaxVectorCoord(const v: TVector4): integer; overload;
 
function MaxAbsVectorCoord(const v: TVector2): integer; overload;
 
function MaxAbsVectorCoord(const v: TVector3): integer; overload;
 
function MinVectorCoord(const v: TVector3): integer; overload;
 
procedure SortAbsVectorCoord(const v: TVector3; out Max, Middle, Min: Integer); overload;
 
function PlaneDirInDirection(const Plane: TVector4; const Direction: TVector3): TVector3; 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: TVector3): TVector3; overload;
 
function PlaneDirNotInDirection(const Plane: TVector4; const Direction: TVector3): TVector3; overload;
 
function PlaneDirNotInDirection(const PlaneDir, Direction: TVector3): TVector3; overload;
 
function SwapEndian(const V: TVector2): TVector2; overload;

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

function SwapEndian(const V: TVector3): TVector3; overload;
 
function SwapEndian(const V: TVector4): TVector4; overload;
 
function LEtoN(const V: TVector2): TVector2; overload;
 
function LEtoN(const V: TVector3): TVector3; overload;
 
function LEtoN(const V: TVector4): TVector4; overload;
 
function BEtoN(const V: TVector2): TVector2; overload;
 
function BEtoN(const V: TVector3): TVector3; overload;
 
function BEtoN(const V: TVector4): TVector4; overload;
 
function NtoLE(const V: TVector2): TVector2; overload;
 
function NtoLE(const V: TVector3): TVector3; overload;
 
function NtoLE(const V: TVector4): TVector4; overload;
 
function NtoBE(const V: TVector2): TVector2; overload;
 
function NtoBE(const V: TVector3): TVector3; overload;
 
function NtoBE(const V: TVector4): TVector4; overload;
 
procedure SwapValues(var V1, V2: TVector2); overload;
 
procedure SwapValues(var V1, V2: TVector3); overload;
 
procedure SwapValues(var V1, V2: TVector4); overload;
 
procedure NormalizePlaneVar(var v: TVector4); 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 TwoPlanesIntersectionLine(const Plane0, Plane1: TVector4; out Line0, LineVector: TVector3); overload;

Intersection of two 3D planes.

Exceptions raised
EPlanesParallel
If planes are parallel.
function Lines2DIntersection(const Line0, Line1: TVector3): TVector2; 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 ThreePlanesIntersectionPoint( const Plane0, Plane1, Plane2: TVector4): TVector3; 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 PlaneMove(const Plane: TVector4; const Move: TVector3): TVector4; 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).

procedure PlaneMoveVar(var Plane: TVector4; const Move: TVector3); overload;
 
function PlaneAntiMove(const Plane: TVector4; const Move: TVector3): TVector4; overload;
 
function VectorsSamePlaneDirections(const V1, V2: TVector3; const Plane: TVector4): 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: TVector3; const PlaneDir: TVector3): boolean; overload;
 
function PointsSamePlaneSides(const p1, p2: TVector3; const Plane: TVector4): 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 PointsDistance(const V1, V2: TVector2): Single; overload;
 
function PointsDistance(const V1, V2: TVector3): Single; overload;
 
function PointsDistanceSqr(const V1, V2: TVector2): Single; overload;
 
function PointsDistanceSqr(const V1, V2: TVector3): Single; overload;
 
function PointsDistance2DSqr(const V1, V2: TVector3; 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 VectorsPerp(const V1, V2: TVector3): boolean; overload;
 
function VectorsParallel(const V1, V2: TVector3): 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.

procedure MakeVectorsAngleRadOnTheirPlane(var v1: TVector3; const v2: TVector3; const AngleRad: Single; const ResultWhenParallel: TVector3); 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 TVector3.CrossProduct(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 TVector3.CrossProduct sign changes.

procedure MakeVectorsOrthoOnTheirPlane(var v1: TVector3; const v2: TVector3); overload;

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

function AnyOrthogonalVector(const v: TVector2): TVector2; overload;

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

function AnyOrthogonalVector(const v: TVector3): TVector3; overload;
 
function IsLineParallelToPlane(const lineVector: TVector3; const plane: TVector4): boolean; overload;
 
function IsLineParallelToSimplePlane(const lineVector: TVector3; const PlaneConstCoord: integer): boolean; overload;
 
function AreParallelVectorsSameDirection( const Vector1, Vector2: TVector3): 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 PointOnPlaneClosestToPoint(const plane: TVector4; const point: TVector3): TVector3; overload;

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

function PointToPlaneDistanceSqr(const Point: TVector3; const Plane: TVector4): Single; overload;
 
function PointToNormalizedPlaneDistance(const Point: TVector3; const Plane: TVector4): 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 PointToPlaneDistance(const Point: TVector3; const Plane: TVector4): Single; overload;

Distance from a point to a plane.

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

function PointToSimplePlaneDistance(const point: TVector3; const PlaneConstCoord: integer; const PlaneConstValue: Single): Single; overload;
 
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector2): TVector2; overload;
 
function PointOnLineClosestToPoint(const line0, lineVector, point: TVector3): TVector3; overload;
 
function PointToLineDistanceSqr(const point, line0, lineVector: TVector3): Single; overload;
 
function TryPlaneLineIntersection(out intersection: TVector3; const plane: TVector4; const line0, lineVector: TVector3): 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. T is always within [0,1] range.

function TryPlaneLineIntersection(out t: Single; const plane: TVector4; const line0, lineVector: TVector3): boolean; overload;
 
function TrySimplePlaneRayIntersection(out Intersection: TVector3; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3): 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. T is always >= 0.

function TrySimplePlaneRayIntersection(out Intersection: TVector3; out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3): boolean; overload;
 
function TrySimplePlaneRayIntersection(out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const RayOrigin, RayDirection: TVector3): boolean; overload;
 
function TryPlaneRayIntersection(out Intersection: TVector3; const Plane: TVector4; const RayOrigin, RayDirection: TVector3): boolean; overload;
 
function TryPlaneRayIntersection(out Intersection: TVector3; out T: Single; const Plane: TVector4; const RayOrigin, RayDirection: TVector3): boolean; overload;
 
function TrySimplePlaneSegmentIntersection( out Intersection: TVector3; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3): 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 = Segment0 + SegmentVector * T. T is always in range [0,1].

function TrySimplePlaneSegmentIntersection( out Intersection: TVector3; out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3): boolean; overload;
 
function TrySimplePlaneSegmentIntersection( out T: Single; const PlaneConstCoord: integer; const PlaneConstValue: Single; const Pos1, Pos2: TVector3): boolean; overload;
 
function TryPlaneSegmentDirIntersection(out Intersection: TVector3; const Plane: TVector4; const Segment0, SegmentVector: TVector3): boolean; overload;
 
function TryPlaneSegmentDirIntersection(out Intersection: TVector3; out T: Single; const Plane: TVector4; const Segment0, SegmentVector: TVector3): boolean; overload;
 
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector2): boolean; overload;
 
function IsPointOnSegmentLineWithinSegment(const intersection, pos1, pos2: TVector3): boolean; overload;
 
function LineOfTwoDifferentPoints2d(const p1, p2: TVector2): TVector3; overload;

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

function PointToSegmentDistanceSqr(const point, pos1, pos2: TVector3): Single; overload;
 
function PlaneTransform(const Plane: TVector4; const Matrix: TMatrix4): TVector4;

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 IsTunnelSphereCollision(const Tunnel1, Tunnel2: TVector3; const TunnelRadius: Single; const SphereCenter: TVector3; const SphereRadius: Single): boolean; overload;
 
function IsSpheresCollision(const Sphere1Center: TVector3; const Sphere1Radius: Single; const Sphere2Center: TVector3; const Sphere2Radius: Single): boolean; overload;
 
function IsSegmentSphereCollision(const pos1, pos2, SphereCenter: TVector3; const SphereRadius: Single): boolean; overload;
 
function TrySphereRayIntersection(out Intersection: TVector3; const SphereCenter: TVector3; const SphereRadius: Single; const RayOrigin, RayDirection: TVector3): boolean; overload;
 
function TryCylinderRayIntersection(out Intersection: TVector3; const CylinderAxisOrigin, CylinderAxis: TVector3; const CylinderRadius: Single; const RayOrigin, RayDirection: TVector3): boolean; overload;

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

function TranslationMatrix(const X, Y, Z: Single): TMatrix4; 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 Transl: TVector3): TMatrix4; overload;
 
procedure TranslationMatrices(const X, Y, Z: Single; out Matrix, InvertedMatrix: TMatrix4); overload;
 
procedure TranslationMatrices(const Transl: TVector3; out Matrix, InvertedMatrix: TMatrix4); overload;
 
procedure MultMatrixTranslation(var M: TMatrix4; const Transl: TVector3); overload;

Multiply matrix M by translation matrix.

This is equivalent to M := 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 := M * translation;
MInvert := 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 MultMatricesTranslation(var M, MInvert: TMatrix4; const Transl: TVector3); overload;
 
function TransformToCoordsMatrix(const NewX, NewY, NewZ: TVector3): TMatrix4; 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 NewOrigin, NewX, NewY, NewZ: TVector3): TMatrix4; overload;
 
function TransformToCoordsNoScaleMatrix(const NewOrigin, NewX, NewY, NewZ: TVector3): TMatrix4; overload;
 
function TransformFromCoordsMatrix(const OldX, OldY, OldZ: TVector3): TMatrix4; overload;
 
function TransformFromCoordsMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3): TMatrix4; overload;
 
function TransformFromCoordsNoScaleMatrix(const OldOrigin, OldX, OldY, OldZ: TVector3): TMatrix4; overload;
 
procedure TransformCoordsMatrices(const NewX, NewY, NewZ: TVector3; out ToCoords, FromCoords: TMatrix4); overload;

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

function TransformToCoords(const V, NewX, NewY, NewZ: TVector3): TVector3;

Transform vector into new coordinate space.

Equivalent to TransformToCoordsMatrix(TVector3.Zero, NewX, NewY, NewZ).MultPoint(V). 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 LookAtMatrix(const Eye, Center, Up: TVector3): TMatrix4; 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 LookDirMatrix(const Eye, Dir, Up: TVector3): TMatrix4; overload;
 
function LookDirMatrix(const Eye, Dir, Side, Up: TVector3): TMatrix4; overload;
 
function FastLookDirMatrix(const Direction, Up: TVector3): TMatrix4;

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 InverseFastLookDirMatrix(const Direction, Up: TVector3): TMatrix4;
 
function ModelViewToNormalMatrix(const M: TMatrix4): TMatrix3;

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: TVector3): TMatrix4;

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 ScalingMatrix(const ScaleFactor: TVector3): TMatrix4;
 
procedure ScalingMatrices(const ScaleFactor: TVector3; InvertedMatrixIdentityIfNotExists: boolean; out Matrix, InvertedMatrix: TMatrix4);
 
function RotationMatrixRad(const AngleRad: Single; const Axis: TVector3): TMatrix4; overload;
 
function RotationMatrixDeg(const AngleDeg: Single; const Axis: TVector3): TMatrix4; overload;
 
function RotationMatrixRad(const AngleRad: Single; const AxisX, AxisY, AxisZ: Single): TMatrix4; overload;
 
function RotationMatrixDeg(const AngleDeg: Single; const AxisX, AxisY, AxisZ: Single): TMatrix4; overload;
 
procedure RotationMatricesRad(const AngleRad: Single; const Axis: TVector3; out Matrix, InvertedMatrix: TMatrix4); overload;
 
procedure RotationMatricesRad(const AxisAngle: TVector4; out Matrix, InvertedMatrix: TMatrix4); overload;
 
function RotationNegate(const Rotation: TVector4): TVector4;

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: TVector2; const AngleRad: Single): TVector2;

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

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

When you really, really must approximate a 3D or 2D scale by a single float. E.g. if your algorithm cannot handle non-uniform 3D or 2D scale, you have to approximate 3D or 2D scale by a single float.

This is similar to an average of X, Y (and Z, in 3D), 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: TVector3): Single; overload;
 
function Approximate2DScale(const X, Y: Single): Single; overload;
 
function Approximate2DScale(const V: TVector2): Single; overload;
 
function ThreePlanesIntersectionPointDouble( const Plane0, Plane1, Plane2: TVector4Double): TVector3Double; 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 Vector2Byte(const X, Y: Byte): TVector2Byte; overload; inline;
 
function Vector3Byte(const X, Y, Z: Byte): TVector3Byte; overload; inline;
 
function Vector4Byte(const X, Y, Z, W: Byte): TVector4Byte; overload; inline;
 
function Vector2Byte(const V: TVector2): TVector2Byte; overload;

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

function Vector3Byte(const V: TVector3): TVector3Byte; overload;
 
function Vector4Byte(const V: TVector4): TVector4Byte; overload;
 
function Vector2(const V: TVector2Byte): TVector2; overload;
 
function Vector3(const V: TVector3Byte): TVector3; overload;
 
function Vector4(const V: TVector4Byte): TVector4; overload;
 
function Lerp(const A: Single; const V1, V2: TVector2Byte): TVector2Byte; overload; inline;
 
function Lerp(const A: Single; const V1, V2: TVector3Byte): TVector3Byte; overload; inline;
 
function Lerp(const A: Single; const V1, V2: TVector4Byte): TVector4Byte; overload; inline;
 
function Vector2Integer(const X, Y: Integer): TVector2Integer; inline;
 
function Vector3Integer(const X, Y, Z: Integer): TVector3Integer; inline;
 
function Vector4Integer(const X, Y, Z, W: Integer): TVector4Integer; inline;
 
function Vector2Cardinal(const X, Y: Cardinal): TVector2Cardinal; inline;
 
function Vector3Cardinal(const X, Y, Z: Cardinal): TVector3Cardinal; inline;
 
function Vector4Cardinal(const X, Y, Z, W: Cardinal): TVector4Cardinal; inline;
 
function Vector2SmallInt(const X, Y: SmallInt): TVector2SmallInt; inline;
 
function Vector2Single(const X, Y: Single): TVector2; overload; deprecated 'use Vector2';

Warning: this symbol is deprecated: use Vector2

Construct an initialized TVector2 value.

function Vector2Single(const V: TVector2Double): TVector2; overload; deprecated 'use Vector2';

Warning: this symbol is deprecated: use Vector2

 
function Vector3Single(const X, Y, Z: Single): TVector3; overload; deprecated 'use Vector3';

Warning: this symbol is deprecated: use Vector3

Construct an initialized TVector3 value.

function Vector3Single(const V: TVector2; const Z: Single): TVector3; overload; deprecated 'use Vector3';

Warning: this symbol is deprecated: use Vector3

 
function Vector3Single(const V: TVector3Double): TVector3; overload; deprecated 'use Vector3';

Warning: this symbol is deprecated: use Vector3

 
function Vector4Single(const X, Y, Z, W: Single): TVector4; overload; deprecated 'use Vector4';

Warning: this symbol is deprecated: use Vector4

Construct an initialized TVector4 value.

function Vector4Single(const V: TVector3; const W: Single): TVector4; overload; deprecated 'use Vector4';

Warning: this symbol is deprecated: use Vector4

 
function Vector4Single(const V: TVector4Double): TVector4; overload; deprecated 'use Vector4';

Warning: this symbol is deprecated: use Vector4

 
function FloatsEqual(const A, B: Single): boolean; overload; deprecated 'use Math.SameValue';

Warning: this symbol is deprecated: use Math.SameValue

Various compatibility functions (on Single)

function FloatsEqual(const A, B: Single; const Epsilon: Single): boolean; overload; deprecated 'use Math.SameValue';

Warning: this symbol is deprecated: use Math.SameValue

 
function FloatToNiceStr(const A: Single): string; overload; deprecated 'use Format(''%f'', [Value])';

Warning: this symbol is deprecated: use Format('%f', [Value])

 
function FloatToRawStr(const A: Single): string; overload; deprecated 'use Format(''%g'', [Value])';

Warning: this symbol is deprecated: use Format('%g', [Value])

 
function Zero(const A: Single): boolean; overload; deprecated 'use Math.IsZero';

Warning: this symbol is deprecated: use Math.IsZero

 
function VectorAdd(const V1, V2: TVector2): TVector2; overload; deprecated 'use V1 + V2';

Warning: this symbol is deprecated: use V1 + V2

Various compatibility functions (on vectors and matrices)

function VectorAdd(const V1, V2: TVector3): TVector3; overload; deprecated 'use V1 + V2';

Warning: this symbol is deprecated: use V1 + V2

 
function VectorAdd(const V1, V2: TVector4): TVector4; overload; deprecated 'use V1 + V2';

Warning: this symbol is deprecated: use V1 + V2

 
function VectorSubtract(const V1, V2: TVector2): TVector2; overload; deprecated 'use V1 - V2';

Warning: this symbol is deprecated: use V1 - V2

 
function VectorSubtract(const V1, V2: TVector3): TVector3; overload; deprecated 'use V1 - V2';

Warning: this symbol is deprecated: use V1 - V2

 
function VectorSubtract(const V1, V2: TVector4): TVector4; overload; deprecated 'use V1 - V2';

Warning: this symbol is deprecated: use V1 - V2

 
function VectorMultiplyComponents(const V1, V2: TVector2): TVector2; overload; deprecated 'use V1 * V2';

Warning: this symbol is deprecated: use V1 * V2

 
function VectorMultiplyComponents(const V1, V2: TVector3): TVector3; overload; deprecated 'use V1 * V2';

Warning: this symbol is deprecated: use V1 * V2

 
function VectorMultiplyComponents(const V1, V2: TVector4): TVector4; overload; deprecated 'use V1 * V2';

Warning: this symbol is deprecated: use V1 * V2

 
function VectorProduct(const V1, V2: TVector3): TVector3; overload; deprecated 'use TVector3.CrossProduct';

Warning: this symbol is deprecated: use TVector3.CrossProduct

 
function Normalized(const V: TVector2): TVector2; overload; deprecated 'use V.Normalize method';

Warning: this symbol is deprecated: use V.Normalize method

 
function Normalized(const V: TVector3): TVector3; overload; deprecated 'use V.Normalize method';

Warning: this symbol is deprecated: use V.Normalize method

 
procedure NormalizeVar(var V: TVector2); overload; deprecated 'use V.NormalizeMe method';

Warning: this symbol is deprecated: use V.NormalizeMe method

 
procedure NormalizeVar(var V: TVector3); overload; deprecated 'use V.NormalizeMe method';

Warning: this symbol is deprecated: use V.NormalizeMe method

 
function MatrixMult(const M1, M2: TMatrix4): TMatrix4; overload; deprecated 'use * operator to multiply matrices';

Warning: this symbol is deprecated: use * operator to multiply matrices

 
function MatrixMultPoint(const M: TMatrix4; const P: TVector2): TVector2; overload; deprecated 'use M.MultPoint method';

Warning: this symbol is deprecated: use M.MultPoint method

 
function MatrixMultPoint(const M: TMatrix4; const P: TVector3): TVector3; overload; deprecated 'use M.MultPoint method';

Warning: this symbol is deprecated: use M.MultPoint method

 
function MatrixMultDirection(const M: TMatrix4; const P: TVector2): TVector2; overload; deprecated 'use M.MultDirection method';

Warning: this symbol is deprecated: use M.MultDirection method

 
function MatrixMultDirection(const M: TMatrix4; const P: TVector3): TVector3; overload; deprecated 'use M.MultDirection method';

Warning: this symbol is deprecated: use M.MultDirection method

 
function VectorLenSqr(const V: TVector2): Single; overload; deprecated 'use V.LengthSqr';

Warning: this symbol is deprecated: use V.LengthSqr

 
function VectorLenSqr(const V: TVector3): Single; overload; deprecated 'use V.LengthSqr';

Warning: this symbol is deprecated: use V.LengthSqr

 
function VectorLenSqr(const V: TVector4): Single; overload; deprecated 'use V.LengthSqr';

Warning: this symbol is deprecated: use V.LengthSqr

 
function VectorLen(const V: TVector2): Single; overload; deprecated 'use V.Length';

Warning: this symbol is deprecated: use V.Length

 
function VectorLen(const V: TVector3): Single; overload; deprecated 'use V.Length';

Warning: this symbol is deprecated: use V.Length

 
function VectorLen(const V: TVector4): Single; overload; deprecated 'use V.Length';

Warning: this symbol is deprecated: use V.Length

 
function VectorAverage(const V: TVector3): Single; overload; deprecated 'use V.Average';

Warning: this symbol is deprecated: use V.Average

 
function VectorToRawStr(const V: TVector2): string; overload; deprecated 'use V.ToRawString';

Warning: this symbol is deprecated: use V.ToRawString

 
function VectorToRawStr(const V: TVector3): string; overload; deprecated 'use V.ToRawString';

Warning: this symbol is deprecated: use V.ToRawString

 
function VectorToRawStr(const V: TVector4): string; overload; deprecated 'use V.ToRawString';

Warning: this symbol is deprecated: use V.ToRawString

 
function VectorToNiceStr(const V: TVector2): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector3): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector4): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector2Integer): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector3Integer): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector4Integer): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector2Cardinal): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector3Cardinal): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector4Cardinal): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector2Byte): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector3Byte): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function VectorToNiceStr(const V: TVector4Byte): string; overload; deprecated 'use V.ToString';

Warning: this symbol is deprecated: use V.ToString

 
function ZeroVector(const V: TVector2): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector3): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector4): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector2Byte): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector3Byte): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector4Byte): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector2Integer): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector3Integer): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector4Integer): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector2Cardinal): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector3Cardinal): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function ZeroVector(const V: TVector4Cardinal): boolean; overload; deprecated 'use V.IsZero';

Warning: this symbol is deprecated: use V.IsZero

 
function PerfectlyZeroVector(const V: TVector2): boolean; overload; deprecated 'use V.IsPerfectlyZero';

Warning: this symbol is deprecated: use V.IsPerfectlyZero

 
function PerfectlyZeroVector(const V: TVector3): boolean; overload; deprecated 'use V.IsPerfectlyZero';

Warning: this symbol is deprecated: use V.IsPerfectlyZero

 
function PerfectlyZeroVector(const V: TVector4): boolean; overload; deprecated 'use V.IsPerfectlyZero';

Warning: this symbol is deprecated: use V.IsPerfectlyZero

 
function VectorAdjustToLength(const V: TVector2; const NewLength: Single): TVector2; overload; deprecated 'use V.AdjustToLength';

Warning: this symbol is deprecated: use V.AdjustToLength

 
function VectorAdjustToLength(const V: TVector3; const NewLength: Single): TVector3; overload; deprecated 'use V.AdjustToLength';

Warning: this symbol is deprecated: use V.AdjustToLength

 
function VectorAdjustToLength(const V: TVector4; const NewLength: Single): TVector4; overload; deprecated 'use V.AdjustToLength';

Warning: this symbol is deprecated: use V.AdjustToLength

 
function Vector2SingleFromStr(const S: string): TVector2; overload; deprecated 'use Vector2FromStr';

Warning: this symbol is deprecated: use Vector2FromStr

 
function Vector3SingleFromStr(const s: string): TVector3; overload; deprecated 'use Vector3FromStr';

Warning: this symbol is deprecated: use Vector3FromStr

 
function Vector4SingleFromStr(const S: string): TVector4; overload; deprecated 'use Vector4FromStr';

Warning: this symbol is deprecated: use Vector4FromStr

 
function VectorDotProduct(const V1, V2: TVector2): Single; overload; deprecated 'use TVector2.DotProduct(V1, V2)';

Warning: this symbol is deprecated: use TVector2.DotProduct(V1, V2)

 
function VectorDotProduct(const V1, V2: TVector3): Single; overload; deprecated 'use TVector3.DotProduct(V1, V2)';

Warning: this symbol is deprecated: use TVector3.DotProduct(V1, V2)

 
function VectorDotProduct(const V1, V2: TVector4): Single; overload; deprecated 'use TVector4.DotProduct(V1, V2)';

Warning: this symbol is deprecated: use TVector4.DotProduct(V1, V2)

 
function VectorsEqual(const V1, V2: TVector2): boolean; overload; deprecated 'use TVector2.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector2.Equals(V1, V2)

 
function VectorsEqual(const V1, V2: TVector3): boolean; overload; deprecated 'use TVector3.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector3.Equals(V1, V2)

 
function VectorsEqual(const V1, V2: TVector4): boolean; overload; deprecated 'use TVector4.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector4.Equals(V1, V2)

 
function VectorsEqual(const V1, V2: TVector2; const Epsilon: Single): boolean; overload; deprecated 'use TVector2.Equals(V1, V2, Epsilon)';

Warning: this symbol is deprecated: use TVector2.Equals(V1, V2, Epsilon)

 
function VectorsEqual(const V1, V2: TVector3; const Epsilon: Single): boolean; overload; deprecated 'use TVector3.Equals(V1, V2, Epsilon)';

Warning: this symbol is deprecated: use TVector3.Equals(V1, V2, Epsilon)

 
function VectorsEqual(const V1, V2: TVector4; const Epsilon: Single): boolean; overload; deprecated 'use TVector4.Equals(V1, V2, Epsilon)';

Warning: this symbol is deprecated: use TVector4.Equals(V1, V2, Epsilon)

 
function VectorsPerfectlyEqual(const V1, V2: TVector2): boolean; overload; deprecated 'use TVector2.PerfectlyEquals(V1, V2)';

Warning: this symbol is deprecated: use TVector2.PerfectlyEquals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector3): boolean; overload; deprecated 'use TVector3.PerfectlyEquals(V1, V2)';

Warning: this symbol is deprecated: use TVector3.PerfectlyEquals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector4): boolean; overload; deprecated 'use TVector4.PerfectlyEquals(V1, V2)';

Warning: this symbol is deprecated: use TVector4.PerfectlyEquals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector2Byte): boolean; overload; deprecated 'use TVector2Byte.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector2Byte.Equals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector3Byte): boolean; overload; deprecated 'use TVector3Byte.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector3Byte.Equals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector4Byte): boolean; overload; deprecated 'use TVector4Byte.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector4Byte.Equals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector2Integer): boolean; overload; deprecated 'use TVector2Integer.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector2Integer.Equals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector3Integer): boolean; overload; deprecated 'use TVector3Integer.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector3Integer.Equals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector4Integer): boolean; overload; deprecated 'use TVector4Integer.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector4Integer.Equals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector2Cardinal): boolean; overload; deprecated 'use TVector2Cardinal.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector2Cardinal.Equals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector3Cardinal): boolean; overload; deprecated 'use TVector3Cardinal.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector3Cardinal.Equals(V1, V2)

 
function VectorsPerfectlyEqual(const V1, V2: TVector4Cardinal): boolean; overload; deprecated 'use TVector4Cardinal.Equals(V1, V2)';

Warning: this symbol is deprecated: use TVector4Cardinal.Equals(V1, V2)

 
function TryMatrixInverse(const M: TMatrix2; out MInverse: TMatrix2): boolean; overload; overload; deprecated 'use TMatrix2.TryInverse';

Warning: this symbol is deprecated: use TMatrix2.TryInverse

 
function TryMatrixInverse(const M: TMatrix3; out MInverse: TMatrix3): boolean; overload; overload; deprecated 'use TMatrix3.TryInverse';

Warning: this symbol is deprecated: use TMatrix3.TryInverse

 
function TryMatrixInverse(const M: TMatrix4; out MInverse: TMatrix4): boolean; overload; overload; deprecated 'use TMatrix4.TryInverse';

Warning: this symbol is deprecated: use TMatrix4.TryInverse

 
function MatrixToRawStr(const M: TMatrix2; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix2.ToRawString';

Warning: this symbol is deprecated: use TMatrix2.ToRawString

 
function MatrixToRawStr(const M: TMatrix3; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix3.ToRawString';

Warning: this symbol is deprecated: use TMatrix3.ToRawString

 
function MatrixToRawStr(const M: TMatrix4; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix4.ToRawString';

Warning: this symbol is deprecated: use TMatrix4.ToRawString

 
function MatrixToNiceStr(const M: TMatrix2; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix2.ToString';

Warning: this symbol is deprecated: use TMatrix2.ToString

 
function MatrixToNiceStr(const M: TMatrix3; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix3.ToString';

Warning: this symbol is deprecated: use TMatrix3.ToString

 
function MatrixToNiceStr(const M: TMatrix4; const LineIndent: string): string; overload; overload; deprecated 'use TMatrix4.ToString';

Warning: this symbol is deprecated: use TMatrix4.ToString

 
function MatricesPerfectlyEqual(const V1, V2: TMatrix2): boolean; overload; deprecated 'use TMatrix2.PerfectlyEquals(V1, V2)';

Warning: this symbol is deprecated: use TMatrix2.PerfectlyEquals(V1, V2)

 
function MatricesPerfectlyEqual(const V1, V2: TMatrix3): boolean; overload; deprecated 'use TMatrix3.PerfectlyEquals(V1, V2)';

Warning: this symbol is deprecated: use TMatrix3.PerfectlyEquals(V1, V2)

 
function MatricesPerfectlyEqual(const V1, V2: TMatrix4): boolean; overload; deprecated 'use TMatrix4.PerfectlyEquals(V1, V2)';

Warning: this symbol is deprecated: use TMatrix4.PerfectlyEquals(V1, V2)

 
function MatrixRow(const M: TMatrix2; const Row: Integer): TVector2; overload; overload; deprecated 'use TMatrix2.Rows[Row]';

Warning: this symbol is deprecated: use TMatrix2.Rows[Row]

 
function MatrixRow(const M: TMatrix3; const Row: Integer): TVector3; overload; overload; deprecated 'use TMatrix3.Rows[Row]';

Warning: this symbol is deprecated: use TMatrix3.Rows[Row]

 
function MatrixRow(const M: TMatrix4; const Row: Integer): TVector4; overload; overload; deprecated 'use TMatrix4.Rows[Row]';

Warning: this symbol is deprecated: use TMatrix4.Rows[Row]

 
function Vector2SingleCut(const V: TVector3): TVector2; overload; deprecated 'use V.XY';

Warning: this symbol is deprecated: use V.XY

 
function Vector3SingleCut(const V: TVector4): TVector3; overload; deprecated 'use V.XYZ';

Warning: this symbol is deprecated: use V.XYZ

 
function Matrix3Single(const V: TMatrix3Double): TMatrix3; overload; deprecated 'use Matrix3';

Warning: this symbol is deprecated: use Matrix3

 
function Matrix4Single(const V: TMatrix4Double): TMatrix4; overload; deprecated 'use Matrix4';

Warning: this symbol is deprecated: use Matrix4

 

Types

TVector2 = CastleVectorsInternalSingle.TGenericVector2;

Vector of 2 floating-point values (Single precision).

PVector2 = ˆTVector2;
 
TVector2Double = CastleVectorsInternalDouble.TGenericVector2;

Vector of 2 floating-point values (Double precision).

PVector2Double = ˆTVector2Double;
 
TVector3 = CastleVectorsInternalSingle.TGenericVector3;

Vector of 3 floating-point values (Single precision).

PVector3 = ˆTVector3;
 
TVector3Double = CastleVectorsInternalDouble.TGenericVector3;

Vector of 3 floating-point values (Double precision).

PVector3Double = ˆTVector3Double;
 
TVector4 = CastleVectorsInternalSingle.TGenericVector4;

Vector of 4 floating-point values (Single precision).

PVector4 = ˆTVector4;
 
TVector4Double = CastleVectorsInternalDouble.TGenericVector4;

Vector of 4 floating-point values (Double precision).

PVector4Double = ˆTVector4Double;
 
TMatrix2 = CastleVectorsInternalSingle.TGenericMatrix2;

2x2 matrix of floating-point values (Single precision).

PMatrix2 = ˆTMatrix2;
 
TMatrix2Double = CastleVectorsInternalDouble.TGenericMatrix2;

2x2 matrix of floating-point values (Double precision).

PMatrix2Double = ˆTMatrix2Double;
 
TMatrix3 = CastleVectorsInternalSingle.TGenericMatrix3;

3x3 matrix of floating-point values (Single precision).

PMatrix3 = ˆTMatrix3;
 
TMatrix3Double = CastleVectorsInternalDouble.TGenericMatrix3;

3x3 matrix of floating-point values (Double precision).

PMatrix3Double = ˆTMatrix3Double;
 
TMatrix4 = CastleVectorsInternalSingle.TGenericMatrix4;

4x4 matrix of floating-point values (Single precision).

PMatrix4 = ˆTMatrix4;
 
TMatrix4Double = CastleVectorsInternalDouble.TGenericMatrix4;

4x4 matrix of floating-point values (Double precision).

PMatrix4Double = ˆTMatrix4Double;
 
TVector2Array = packed array [0..MaxInt div SizeOf(TVector2) - 1] of TVector2;
 
PVector2Array = ˆTVector2Array;
 
TVector3Array = packed array [0..MaxInt div SizeOf(TVector3) - 1] of TVector3;
 
PVector3Array = ˆTVector3Array;
 
TVector4Array = packed array [0..MaxInt div SizeOf(TVector4) - 1] of TVector4;
 
PVector4Array = ˆTVector4Array;
 
TGetVertexFromIndexFunc = function (Index: integer): TVector3 of object;

CastleVectors routines (global functions, procedures) for Single precision of vectors and matrices.

PVector2Byte = ˆTVector2Byte;
 
PVector3Byte = ˆTVector3Byte;
 
PVector4Byte = ˆTVector4Byte;
 
TVector2ByteArray = packed array [0..MaxInt div SizeOf(TVector2Byte)-1] of TVector2Byte;
 
PVector2ByteArray = ˆTVector2ByteArray;
 
TVector3ByteArray = packed array [0..MaxInt div SizeOf(TVector3Byte)-1] of TVector3Byte;
 
PVector3ByteArray = ˆTVector3ByteArray;
 
TVector4ByteArray = packed array [0..MaxInt div SizeOf(TVector4Byte)-1] of TVector4Byte;
 
PVector4ByteArray = ˆTVector4ByteArray;
 
PVector2Integer = ˆTVector2Integer;
 
PVector3Integer = ˆTVector3Integer;
 
PVector4Integer = ˆTVector4Integer;
 
TVector2IntegerArray = packed array [0..MaxInt div SizeOf(TVector2Integer)-1] of TVector2Integer;
 
PVector2IntegerArray = ˆTVector2IntegerArray;
 
TVector3IntegerArray = packed array [0..MaxInt div SizeOf(TVector3Integer)-1] of TVector3Integer;
 
PVector3IntegerArray = ˆTVector3IntegerArray;
 
TVector4IntegerArray = packed array [0..MaxInt div SizeOf(TVector4Integer)-1] of TVector4Integer;
 
PVector4IntegerArray = ˆTVector4IntegerArray;
 
PVector2Cardinal = ˆTVector2Cardinal;
 
PVector3Cardinal = ˆTVector3Cardinal;
 
PVector4Cardinal = ˆTVector4Cardinal;
 
TVector2CardinalArray = packed array [0..MaxInt div SizeOf(TVector2Cardinal)-1] of TVector2Cardinal;
 
PVector2CardinalArray = ˆTVector2CardinalArray;
 
TVector3CardinalArray = packed array [0..MaxInt div SizeOf(TVector3Cardinal)-1] of TVector3Cardinal;
 
PVector3CardinalArray = ˆTVector3CardinalArray;
 
TVector4CardinalArray = packed array [0..MaxInt div SizeOf(TVector4Cardinal)-1] of TVector4Cardinal;
 
PVector4CardinalArray = ˆTVector4CardinalArray;
 
PVector2SmallInt = ˆTVector2SmallInt;
 
TVector2SmallIntList = specialize TStructList<TVector2SmallInt>;

List of TVector2SmallInt.

TVector3CardinalList = specialize TStructList<TVector3Cardinal>;

List of TVector2Cardinal.

TVector2Single = TVector2 deprecated;

Warning: this symbol is deprecated.

 
TVector3Single = TVector3 deprecated;

Warning: this symbol is deprecated.

 
TVector4Single = TVector4 deprecated;

Warning: this symbol is deprecated.

 
TMatrix2Single = TMatrix2 deprecated;

Warning: this symbol is deprecated.

 
TMatrix3Single = TMatrix3 deprecated;

Warning: this symbol is deprecated.

 
TMatrix4Single = TMatrix4 deprecated;

Warning: this symbol is deprecated.

 
TVector2SingleList = TVector2List deprecated;

Warning: this symbol is deprecated.

 
TVector3SingleList = TVector3List deprecated;

Warning: this symbol is deprecated.

 
TVector4SingleList = TVector4List deprecated;

Warning: this symbol is deprecated.

 
TMatrix3SingleList = TMatrix3List deprecated;

Warning: this symbol is deprecated.

 
TMatrix4SingleList = TMatrix4List deprecated;

Warning: this symbol is deprecated.

 
TVector3LongInt = TVector3Integer deprecated;

Warning: this symbol is deprecated.

 
PVector2Single = PVector2 deprecated;

Warning: this symbol is deprecated.

 
PVector3Single = PVector3 deprecated;

Warning: this symbol is deprecated.

 
PVector4Single = PVector4 deprecated;

Warning: this symbol is deprecated.

 
PMatrix2Single = PMatrix2 deprecated;

Warning: this symbol is deprecated.

 
PMatrix3Single = PMatrix3 deprecated;

Warning: this symbol is deprecated.

 
PMatrix4Single = PMatrix4 deprecated;

Warning: this symbol is deprecated.

 
PVector3LongInt = PVector3Integer deprecated;

Warning: this symbol is deprecated.

 

Constants

ZeroVector2Single: TVector2 = (Data: (0, 0)) deprecated 'use TVector2.Zero';

Warning: this symbol is deprecated: use TVector2.Zero

Vector with all components zero.

ZeroVector3Single: TVector3 = (Data: (0, 0, 0)) deprecated 'use TVector3.Zero';

Warning: this symbol is deprecated: use TVector3.Zero

 
ZeroVector4Single: TVector4 = (Data: (0, 0, 0, 0)) deprecated 'use TVector4.Zero';

Warning: this symbol is deprecated: use TVector4.Zero

 
ZeroVector2Double: TVector2Double = (Data: (0, 0)) deprecated 'use TVector2Double.Zero';

Warning: this symbol is deprecated: use TVector2Double.Zero

 
ZeroVector3Double: TVector3Double = (Data: (0, 0, 0)) deprecated 'use TVector3Double.Zero';

Warning: this symbol is deprecated: use TVector3Double.Zero

 
ZeroVector4Double: TVector4Double = (Data: (0, 0, 0, 0)) deprecated 'use TVector4Double.Zero';

Warning: this symbol is deprecated: use TVector4Double.Zero

 
ZeroVector2Byte: TVector2Byte = (Data: (0, 0)) deprecated 'use TVector2Byte.Zero';

Warning: this symbol is deprecated: use TVector2Byte.Zero

 
ZeroVector3Byte: TVector3Byte = (Data: (0, 0, 0)) deprecated 'use TVector3Byte.Zero';

Warning: this symbol is deprecated: use TVector3Byte.Zero

 
ZeroVector4Byte: TVector4Byte = (Data: (0, 0, 0, 0)) deprecated 'use TVector4Byte.Zero';

Warning: this symbol is deprecated: use TVector4Byte.Zero

 
ZeroVector2Integer: TVector2Integer = (Data: (0, 0)) deprecated 'use TVector2Integer.Zero';

Warning: this symbol is deprecated: use TVector2Integer.Zero

 
ZeroVector3Integer: TVector3Integer = (Data: (0, 0, 0)) deprecated 'use TVector3Integer.Zero';

Warning: this symbol is deprecated: use TVector3Integer.Zero

 
ZeroVector4Integer: TVector4Integer = (Data: (0, 0, 0, 0)) deprecated 'use TVector4Integer.Zero';

Warning: this symbol is deprecated: use TVector4Integer.Zero

 
ZeroVector2Cardinal: TVector2Cardinal = (Data: (0, 0)) deprecated 'use TVector2Cardinal.Zero';

Warning: this symbol is deprecated: use TVector2Cardinal.Zero

 
ZeroVector3Cardinal: TVector3Cardinal = (Data: (0, 0, 0)) deprecated 'use TVector3Cardinal.Zero';

Warning: this symbol is deprecated: use TVector3Cardinal.Zero

 
ZeroVector4Cardinal: TVector4Cardinal = (Data: (0, 0, 0, 0)) deprecated 'use TVector4Cardinal.Zero';

Warning: this symbol is deprecated: use TVector4Cardinal.Zero

 
ZeroMatrix2Single: TMatrix2 = (Data: ((0, 0), (0, 0))) deprecated 'use TMatrix2.Zero';

Warning: this symbol is deprecated: use TMatrix2.Zero

 
ZeroMatrix3Single: TMatrix3 = (Data: ((0, 0, 0), (0, 0, 0), (0, 0, 0))) deprecated 'use TMatrix3.Zero';

Warning: this symbol is deprecated: use TMatrix3.Zero

 
ZeroMatrix4Single: TMatrix4 = (Data: ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0))) deprecated 'use TMatrix4.Zero';

Warning: this symbol is deprecated: use TMatrix4.Zero

 
ZeroMatrix2Double: TMatrix2Double = (Data: ((0, 0), (0, 0))) deprecated 'use TMatrix2Double.Zero';

Warning: this symbol is deprecated: use TMatrix2Double.Zero

 
ZeroMatrix3Double: TMatrix3Double = (Data: ((0, 0, 0), (0, 0, 0), (0, 0, 0))) deprecated 'use TMatrix3Double.Zero';

Warning: this symbol is deprecated: use TMatrix3Double.Zero

 
ZeroMatrix4Double: TMatrix4Double = (Data: ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0))) deprecated 'use TMatrix4Double.Zero';

Warning: this symbol is deprecated: use TMatrix4Double.Zero

 
IdentityMatrix2Single: TMatrix2 = (Data: ((1, 0), (0, 1))) deprecated 'use TMatrix2.Identity';

Warning: this symbol is deprecated: use TMatrix2.Identity

 
IdentityMatrix3Single: TMatrix3 = (Data: ((1, 0, 0), (0, 1, 0), (0, 0, 1))) deprecated 'use TMatrix3.Identity';

Warning: this symbol is deprecated: use TMatrix3.Identity

 
IdentityMatrix4Single: TMatrix4 = (Data: ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))) deprecated 'use TMatrix4.Identity';

Warning: this symbol is deprecated: use TMatrix4.Identity

 
IdentityMatrix2Double: TMatrix2Double = (Data: ((1, 0), (0, 1))) deprecated 'use TMatrix2Double.Identity';

Warning: this symbol is deprecated: use TMatrix2Double.Identity

 
IdentityMatrix3Double: TMatrix3Double = (Data: ((1, 0, 0), (0, 1, 0), (0, 0, 1))) deprecated 'use TMatrix3Double.Identity';

Warning: this symbol is deprecated: use TMatrix3Double.Identity

 
IdentityMatrix4Double: TMatrix4Double = (Data: ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))) deprecated 'use TMatrix4Double.Identity';

Warning: this symbol is deprecated: use TMatrix4Double.Identity

 
UnitVector2Single: array [TVector2.TIndex] of TVector2 = ( (Data: (1, 0)), (Data: (0, 1)) ) deprecated 'use TVector2.One';

Warning: this symbol is deprecated: use TVector2.One

 
UnitVector3Single: array [TVector3.TIndex] of TVector3 = ( (Data: (1, 0, 0)), (Data: (0, 1, 0)), (Data: (0, 0, 1)) ) deprecated 'use TVector3.One';

Warning: this symbol is deprecated: use TVector3.One

 
UnitVector4Single: array [TVector4.TIndex] of TVector4 = ( (Data: (1, 0, 0, 0)), (Data: (0, 1, 0, 0)), (Data: (0, 0, 1, 0)), (Data: (0, 0, 0, 1)) ) deprecated 'use TVector4.One';

Warning: this symbol is deprecated: use TVector4.One

 
SingleEpsilon = 1E-4;

Epsilon used by default when compating Single (Single-precision float values). Compatible with Math unit value, used by standard routines like Math.SameValue and Math.IsZero.

DoubleEpsilon = 1E-12;

Epsilon used by default when compating Double (Double-precision float values). Compatible with Math unit value, used by standard routines like Math.SameValue and Math.IsZero.

SingleEqualityEpsilon = SingleEpsilon deprecated 'use SingleEpsilon';

Warning: this symbol is deprecated: use SingleEpsilon

 
DoubleEqualityEpsilon = DoubleEpsilon deprecated 'use DoubleEpsilon';

Warning: this symbol is deprecated: use DoubleEpsilon

 
ExtendedEqualityEpsilon = 1E-16 deprecated 'use only Math functions, like SameValue and IsZero, to operate on Extended type; CastleVectors unit does not deal with Extended type anymore';

Warning: this symbol is deprecated: use only Math functions, like SameValue and IsZero, to operate on Extended type; CastleVectors unit does not deal with Extended type anymore

 

Generated by PasDoc 0.15.0.