Commit 827bc67d authored by Bergmann89's avatar Bergmann89

* added some more usefull methods to ugluMatrixEx

parent 15fd6367
......@@ -15,44 +15,54 @@
function Transpose: __MAT; inline;
function Determinant: Double; inline;
function Invert: __MAT; inline;
function Multiply(const m: __MAT): __MAT; inline;
class function TryFromString(const s: String; out m: __MAT): Boolean; inline; static;
class function FromString(const s: String): __MAT; inline; static;
{$IF __SIZE = 3}
function AxisX: __VEC3; inline;
function AxisY: __VEC3; inline;
function Position: __VEC3; inline;
function Sub(const aCol, aRow: Integer): __IMPL.TMat2; inline;
function Adjoint: __MAT; inline;
function Translate(const v: __IMPL.TVectorHelper.TVector2): __MAT; inline;
function Translate(const v: __VEC2): __MAT; inline;
function Translate(const x, y: __IMPL.TBaseType): __MAT; inline;
function Scale(const v: __IMPL.TVectorHelper.TVector2): __MAT; inline;
function Scale(const v: __VEC2): __MAT; inline;
function Scale(const v: __IMPL.TBaseType): __MAT; inline;
function Shear(const v: __IMPL.TVectorHelper.TVector2): __MAT; inline;
function Shear(const v: __VEC2): __MAT; inline;
function Shear(const x, y: __IMPL.TBaseType): __MAT; inline;
function Rotate(const a: Double): __MAT; inline;
class function CreateTranslate(const v: __IMPL.TVectorHelper.TVector2): __MAT; inline; static;
class function CreateTranslate(const v: __VEC2): __MAT; inline; static;
class function CreateTranslate(const x, y: __IMPL.TBaseType): __MAT; inline; static;
class function CreateScale(const v: __IMPL.TVectorHelper.TVector2): __MAT; inline; static;
class function CreateScale(const v: __VEC2): __MAT; inline; static;
class function CreateScale(const v: __IMPL.TBaseType): __MAT; inline; static;
class function CreateShear(const v: __IMPL.TVectorHelper.TVector2): __MAT; inline; static;
class function CreateShear(const v: __VEC2): __MAT; inline; static;
class function CreateShear(const x, y: __IMPL.TBaseType): __MAT; inline; static;
class function CreateRotate(const a: Double): __MAT; inline; static;
{$ELSEIF __SIZE = 4}
function AxisX: __VEC4; inline;
function AxisY: __VEC4; inline;
function AxisZ: __VEC4; inline;
function Position: __VEC4; inline;
function Sub(const aCol, aRow: Integer): __IMPL.TMat3; inline;
function Adjoint: __MAT; inline;
function Translate(const v: __IMPL.TVectorHelper.TVector3): __MAT; inline;
function Translate(const v: __VEC3): __MAT; inline;
function Translate(const x, y, z: __IMPL.TBaseType): __MAT; inline;
function Scale(const v: __IMPL.TVectorHelper.TVector3): __MAT; inline;
function Scale(const v: __VEC3): __MAT; inline;
function Scale(const v: __IMPL.TBaseType): __MAT; inline;
function Rotate(const axis: __IMPL.TVectorHelper.TVector3; const a: Double): __MAT; inline;
function Rotate(const axis: __VEC3; const a: Double): __MAT; inline;
class function CreateTranslate(const v: __IMPL.TVectorHelper.TVector3): __MAT; inline; static;
class function CreateTranslate(const v: __VEC3): __MAT; inline; static;
class function CreateTranslate(const x, y, z: __IMPL.TBaseType): __MAT; inline; static;
class function CreateScale(const v: __IMPL.TVectorHelper.TVector3): __MAT; inline; static;
class function CreateScale(const v: __VEC3): __MAT; inline; static;
class function CreateScale(const v: __IMPL.TBaseType): __MAT; inline; static;
class function CreateShear(const x, y, z: __IMPL.TVectorHelper.TVector2): __MAT; inline; static;
class function CreateShear(const x, y, z: __VEC2): __MAT; inline; static;
class function CreateShear(const xy, xz, yx, yz, zx, zy: __IMPL.TBaseType): __MAT; inline; static;
class function CreateRotate(const axis: __IMPL.TVectorHelper.TVector3; const a: Double): __MAT; inline; static;
class function CreateRotate(const axis: __VEC3; const a: Double): __MAT; inline; static;
{$ENDIF}
end;
......@@ -107,6 +117,11 @@
result := __IMPL.Invert(self);
end;
function __HELPER.Multiply(const m: __MAT): __MAT;
begin
result := __IMPL.Multiply(self, m);
end;
class function __HELPER.TryFromString(const s: String; out m: __MAT): Boolean;
begin
result := __IMPL.TryFromString(s, m);
......@@ -119,6 +134,21 @@
end;
{$IF __SIZE = 3}
function __HELPER.AxisX: __VEC3;
begin
result := self[0];
end;
function __HELPER.AxisY: __VEC3;
begin
result := self[1];
end;
function __HELPER.Position: __VEC3;
begin
result := self[2];
end;
function __HELPER.Sub(const aCol, aRow: Integer): __IMPL.TMat2;
begin
result := __IMPL.Sub(self, aCol, aRow);
......@@ -129,7 +159,7 @@
result := __IMPL.Adjoint(self);
end;
function __HELPER.Translate(const v: __IMPL.TVectorHelper.TVector2): __MAT;
function __HELPER.Translate(const v: __VEC2): __MAT;
begin
result := __IMPL.Multiply(self, __IMPL.CreateTranslate(v));
end;
......@@ -139,7 +169,7 @@
result := __IMPL.Multiply(self, __IMPL.CreateTranslate(__IMPL.TVectorHelper.Vector2(x, y)));
end;
function __HELPER.Scale(const v: __IMPL.TVectorHelper.TVector2): __MAT;
function __HELPER.Scale(const v: __VEC2): __MAT;
begin
result := __IMPL.Multiply(self, __IMPL.CreateScale(v));
end;
......@@ -149,7 +179,7 @@
result := __IMPL.Multiply(self, __IMPL.CreateScale(__IMPL.TVectorHelper.Vector2(v, v)));
end;
function __HELPER.Shear(const v: __IMPL.TVectorHelper.TVector2): __MAT;
function __HELPER.Shear(const v: __VEC2): __MAT;
begin
result := __IMPL.Multiply(self, __IMPL.CreateShear(v));
end;
......@@ -164,7 +194,7 @@
result := __IMPL.Multiply(self, __IMPL.CreateRotate(a));
end;
class function __HELPER.CreateTranslate(const v: __IMPL.TVectorHelper.TVector2): __MAT;
class function __HELPER.CreateTranslate(const v: __VEC2): __MAT;
begin
result := __IMPL.CreateTranslate(v);
end;
......@@ -174,7 +204,7 @@
result := __IMPL.CreateTranslate(__IMPL.TVectorHelper.Vector2(x, y));
end;
class function __HELPER.CreateScale(const v: __IMPL.TVectorHelper.TVector2): __MAT;
class function __HELPER.CreateScale(const v: __VEC2): __MAT;
begin
result := __IMPL.CreateScale(v);
end;
......@@ -184,7 +214,7 @@
result := __IMPL.CreateScale(__IMPL.TVectorHelper.Vector2(v, v));
end;
class function __HELPER.CreateShear(const v: __IMPL.TVectorHelper.TVector2): __MAT;
class function __HELPER.CreateShear(const v: __VEC2): __MAT;
begin
result := __IMPL.CreateShear(v);
end;
......@@ -199,6 +229,26 @@
result := __IMPL.CreateRotate(a);
end;
{$ELSEIF __SIZE = 4}
function __HELPER.AxisX: __VEC4;
begin
result := self[0];
end;
function __HELPER.AxisY: __VEC4;
begin
result := self[1];
end;
function __HELPER.AxisZ: __VEC4;
begin
result := self[2];
end;
function __HELPER.Position: __VEC4;
begin
result := self[3];
end;
function __HELPER.Sub(const aCol, aRow: Integer): __IMPL.TMat3;
begin
result := __IMPL.Sub(self, aRow, aCol);
......@@ -209,7 +259,7 @@
result := __IMPL.Adjoint(self);
end;
function __HELPER.Translate(const v: __IMPL.TVectorHelper.TVector3): __MAT;
function __HELPER.Translate(const v: __VEC3): __MAT;
begin
result := __IMPL.Multiply(self, __IMPL.CreateTranslate(v));
end;
......@@ -219,7 +269,7 @@
result := __IMPL.Multiply(self, __IMPL.CreateTranslate(__IMPL.TVectorHelper.Vector3(x, y, z)));
end;
function __HELPER.Scale(const v: __IMPL.TVectorHelper.TVector3): __MAT;
function __HELPER.Scale(const v: __VEC3): __MAT;
begin
result := __IMPL.Multiply(self, __IMPL.CreateScale(v));
end;
......@@ -229,12 +279,12 @@
result := __IMPL.Multiply(self, __IMPL.CreateScale(__IMPL.TVectorHelper.Vector3(v, v, v)));
end;
function __HELPER.Rotate(const axis: __IMPL.TVectorHelper.TVector3; const a: Double): __MAT;
function __HELPER.Rotate(const axis: __VEC3; const a: Double): __MAT;
begin
result := __IMPL.Multiply(self, __IMPL.CreateRotate(axis, a));
end;
class function __HELPER.CreateTranslate(const v: __IMPL.TVectorHelper.TVector3): __MAT;
class function __HELPER.CreateTranslate(const v: __VEC3): __MAT;
begin
result := __IMPL.CreateTranslate(v);
end;
......@@ -244,7 +294,7 @@
result := __IMPL.CreateTranslate(__IMPL.TVectorHelper.Vector3(x, y, z));
end;
class function __HELPER.CreateScale(const v: __IMPL.TVectorHelper.TVector3): __MAT;
class function __HELPER.CreateScale(const v: __VEC3): __MAT;
begin
result := __IMPL.CreateScale(v);
end;
......@@ -254,7 +304,7 @@
result := __IMPL.CreateScale(__IMPL.TVectorHelper.Vector3(v, v, v));
end;
class function __HELPER.CreateShear(const x, y, z: __IMPL.TVectorHelper.TVector2): __MAT;
class function __HELPER.CreateShear(const x, y, z: __VEC2): __MAT;
begin
result := __IMPL.CreateShear(x, y, z);
end;
......@@ -267,7 +317,7 @@
__IMPL.TVectorHelper.Vector2(zx, zy));
end;
class function __HELPER.CreateRotate(const axis: __IMPL.TVectorHelper.TVector3; const a: Double): __MAT;
class function __HELPER.CreateRotate(const axis: __VEC3; const a: Double): __MAT;
begin
result := __IMPL.CreateRotate(axis, a);
end;
......
......@@ -32,6 +32,10 @@ type
{$DEFINE __MATRIX_HELPER_INTERFACE}
{$DEFINE __VEC2 := TgluVector2f}
{$DEFINE __VEC3 := TgluVector3f}
{$DEFINE __VEC4 := TgluVector4f}
{$DEFINE __IMPL := TgluMatrixF}
{$DEFINE __SIZE := 2}
{$DEFINE __VEC := TgluVector2f}
......@@ -55,6 +59,10 @@ type
{$DEFINE __VEC2 := TgluVector2d}
{$DEFINE __VEC3 := TgluVector3d}
{$DEFINE __VEC4 := TgluVector4d}
{$DEFINE __IMPL := TgluMatrixD}
{$DEFINE __SIZE := 2}
{$DEFINE __VEC := TgluVector2d}
......@@ -80,6 +88,10 @@ type
implementation
{$DEFINE __MATRIX_HELPER_IMPL}
{$DEFINE __VEC2 := TgluVector2f}
{$DEFINE __VEC3 := TgluVector3f}
{$DEFINE __VEC4 := TgluVector4f}
{$DEFINE __IMPL := TgluMatrixF}
{$DEFINE __SIZE := 2}
{$DEFINE __VEC := TgluVector2f}
......@@ -103,6 +115,10 @@ implementation
{$DEFINE __VEC2 := TgluVector2d}
{$DEFINE __VEC3 := TgluVector3d}
{$DEFINE __VEC4 := TgluVector4d}
{$DEFINE __IMPL := TgluMatrixD}
{$DEFINE __SIZE := 2}
{$DEFINE __VEC := TgluVector2d}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment