| @@ -10,6 +10,12 @@ uses | |||||
| Classes, SysUtils, | Classes, SysUtils, | ||||
| ugluVectorEx, ugluMatrixExHelper; | ugluVectorEx, ugluMatrixExHelper; | ||||
| const | |||||
| maAxisX = 0; | |||||
| maAxisY = 1; | |||||
| maAxisZ = 2; | |||||
| maPos = 3; | |||||
| type | type | ||||
| TgluMatrix2f = TgluMatrixF.TMat2; | TgluMatrix2f = TgluMatrixF.TMat2; | ||||
| TgluMatrix3f = TgluMatrixF.TMat3; | TgluMatrix3f = TgluMatrixF.TMat3; | ||||
| @@ -428,6 +428,7 @@ | |||||
| type __HELPER_I = type helper(__HELPER) for __VEC | type __HELPER_I = type helper(__HELPER) for __VEC | ||||
| public | public | ||||
| function Length: Double; inline; | function Length: Double; inline; | ||||
| function SqrLength: Double; inline; | |||||
| function Abs: __VEC; | function Abs: __VEC; | ||||
| {$IF __SIZE <> 4} | {$IF __SIZE <> 4} | ||||
| function Add(const v: __VEC): __VEC; inline; | function Add(const v: __VEC): __VEC; inline; | ||||
| @@ -453,6 +454,9 @@ | |||||
| {$IF __SIZE = 2} | {$IF __SIZE = 2} | ||||
| function Angle2(const v: __VEC): Double; inline; | function Angle2(const v: __VEC): Double; inline; | ||||
| {$ENDIF} | {$ENDIF} | ||||
| {$IF __SIZE = 3} | |||||
| function Cross(const v: __VEC): __VEC; inline; | |||||
| {$ENDIF} | |||||
| end; | end; | ||||
| operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC; inline; | operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC; inline; | ||||
| operator * (const s: __IMPL.TBaseType; const v: __VEC): __VEC; inline; | operator * (const s: __IMPL.TBaseType; const v: __VEC): __VEC; inline; | ||||
| @@ -936,6 +940,11 @@ | |||||
| result := __IMPL.Length(self); | result := __IMPL.Length(self); | ||||
| end; | end; | ||||
| function __HELPER_I.SqrLength: Double; | |||||
| begin | |||||
| result := __IMPL.SqrLength(self); | |||||
| end; | |||||
| function __HELPER_I.Abs: __VEC; | function __HELPER_I.Abs: __VEC; | ||||
| var i: Integer; | var i: Integer; | ||||
| begin | begin | ||||
| @@ -1011,6 +1020,13 @@ | |||||
| end; | end; | ||||
| {$ENDIF} | {$ENDIF} | ||||
| {$IF __SIZE = 3} | |||||
| function __HELPER_F.Cross(const v: __VEC): __VEC; inline; | |||||
| begin | |||||
| result := __IMPL.Cross(self, v); | |||||
| end; | |||||
| {$ENDIF} | |||||
| operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC; | operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC; | ||||
| begin | begin | ||||
| result := __IMPL.Multiply(v, s); | result := __IMPL.Multiply(v, s); | ||||
| @@ -47,6 +47,10 @@ type | |||||
| class function Length(const v: TVector3): Double; overload; inline; | class function Length(const v: TVector3): Double; overload; inline; | ||||
| class function Length(const v: TVector4): Double; overload; inline; | class function Length(const v: TVector4): Double; overload; inline; | ||||
| class function SqrLength(const v: TVector2): Double; overload; inline; | |||||
| class function SqrLength(const v: TVector3): Double; overload; inline; | |||||
| class function SqrLength(const v: TVector4): Double; overload; inline; | |||||
| class function Multiply(const v: TVector2; const a: T): TVector2; overload; inline; | class function Multiply(const v: TVector2; const a: T): TVector2; overload; inline; | ||||
| class function Multiply(const v: TVector3; const a: T): TVector3; overload; inline; | class function Multiply(const v: TVector3; const a: T): TVector3; overload; inline; | ||||
| class function Multiply(const v: TVector4; const a: T): TVector4; overload; inline; | class function Multiply(const v: TVector4; const a: T): TVector4; overload; inline; | ||||
| @@ -386,6 +390,21 @@ begin | |||||
| result := SQRT(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]) * v[3]; | result := SQRT(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]) * v[3]; | ||||
| end; | end; | ||||
| class function TgluVectorHelperI.SqrLength(const v: TVector2): Double; | |||||
| begin | |||||
| result := v[0]*v[0] + v[1]*v[1]; | |||||
| end; | |||||
| class function TgluVectorHelperI.SqrLength(const v: TVector3): Double; | |||||
| begin | |||||
| result := v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; | |||||
| end; | |||||
| class function TgluVectorHelperI.SqrLength(const v: TVector4): Double; | |||||
| begin | |||||
| result := (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]) * v[3]; | |||||
| end; | |||||
| class function TgluVectorHelperI.Multiply(const v: TVector2; const a: T): TVector2; | class function TgluVectorHelperI.Multiply(const v: TVector2; const a: T): TVector2; | ||||
| begin | begin | ||||
| result[0] := v[0] * a; | result[0] := v[0] * a; | ||||