Browse Source

* [ugluVectorEx] added some helper methods

master
Bergmann89 8 years ago
parent
commit
37b1fe1035
1 changed files with 30 additions and 6 deletions
  1. +30
    -6
      ugluVectorEx.inc

+ 30
- 6
ugluVectorEx.inc View File

@@ -3,10 +3,13 @@
type __HELPER = type helper for __VEC
public
{$IF __SIZE = 2}
class function Create(const s: __IMPL.TBaseType): __IMPL.TVector2; static; inline;
class function Create(const x, y: __IMPL.TBaseType): __IMPL.TVector2; static; inline;
{$ELSEIF __SIZE = 3}
class function Create(const s: __IMPL.TBaseType): __IMPL.TVector3; static; inline;
class function Create(const x, y, z: __IMPL.TBaseType): __IMPL.TVector3; static; inline;
{$ELSEIF __SIZE = 4}
class function Create(const s: __IMPL.TBaseType): __IMPL.TVector4; static; inline;
class function Create(const x, y, z, w: __IMPL.TBaseType): __IMPL.TVector4; static; inline;
{$ELSE}
{$ERROR only vectors of size 2, 3 or 4 are supported}
@@ -451,25 +454,41 @@
function Angle2(const v: __VEC): Double; inline;
{$ENDIF}
end;
operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC;
operator * (const s: __IMPL.TBaseType; const v: __VEC): __VEC;
operator * (const v1, v2: __VEC): __IMPL.TBaseType;
operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC; inline;
operator * (const s: __IMPL.TBaseType; const v: __VEC): __VEC; inline;
operator * (const v1, v2: __VEC): __IMPL.TBaseType; inline;
operator / (const v: __VEC; const s: __IMPL.TBaseType): __VEC; inline;
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ELSEIF DEFINED (__VECTOR_HELPER_IMPL)}
{$IFDEF __HELPER}
{$IF __SIZE = 2}
class function __HELPER.Create(const s: __IMPL.TBaseType): __VEC;
begin
result := __IMPL.Vector2(s, s);
end;

class function __HELPER.Create(const x, y: __IMPL.TBaseType): __VEC;
begin
result := __IMPL.Vector2(x, y);
end;
{$ELSEIF __SIZE = 3}
class function __HELPER.Create(const s: __IMPL.TBaseType): __VEC;
begin
result := __IMPL.Vector3(s, s, s);
end;

class function __HELPER.Create(const x, y, z: __IMPL.TBaseType): __VEC;
begin
result := __IMPL.Vector3(x, y, z);
end;
{$ELSEIF __SIZE = 4}
class function __HELPER.Create(const s: __IMPL.TBaseType): __VEC;
begin
result := __IMPL.Vector4(s, s, s, s);
end;

class function __HELPER.Create(const x, y, z, w: __IMPL.TBaseType): __VEC;
begin
result := __IMPL.Vector4(x, y, z, w);
@@ -994,17 +1013,22 @@

operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC;
begin
result := __IMPl.Multiply(v, s);
result := __IMPL.Multiply(v, s);
end;

operator * (const s: __IMPL.TBaseType; const v: __VEC): __VEC;
begin
result := __IMPl.Multiply(v, s);
result := __IMPL.Multiply(v, s);
end;

operator * (const v1, v2: __VEC): __IMPL.TBaseType;
begin
result := __IMPl.Dot(v1, v2);
result := __IMPL.Dot(v1, v2);
end;

operator / (const v: __VEC; const s: __IMPL.TBaseType): __VEC;
begin
result := __IMPL.Divide(v, s);
end;
{$ENDIF}
{$ENDIF}


Loading…
Cancel
Save