Leviathan  0.8.0.0
Leviathan game engine
Leviathan::Float3 Struct Reference

#include <Types.h>

Public Member Functions

DLLEXPORT Float3 ()
 
DLLEXPORT Float3 (float x, float y, float z)
 
DLLEXPORT Float3 (Float2 floats, float z)
 
DLLEXPORT Float3 (float data)
 
DLLEXPORT Float3 (const Int3 &values)
 
DLLEXPORT Float3 (const Float3 &other)
 
DLLEXPORT bool HasInvalidValues () const
 
DLLEXPORT void CheckForNans ()
 
DLLEXPORT float & operator[] (const int &nindex)
 
DLLEXPORT Float3 operator+ (const Float3 &val) const
 
DLLEXPORT Float3operator+= (const Float3 &val)
 
DLLEXPORT Float3operator-= (const Float3 &val)
 
DLLEXPORT Float3 operator- (const Float3 &val) const
 
DLLEXPORT Float3 operator- () const
 
DLLEXPORT Float3 operator* (const Float3 &val) const
 
DLLEXPORT Float3 operator/ (const float &val) const
 
DLLEXPORT Float3operator/= (const float &val)
 
DLLEXPORT Float3 operator* (float f) const
 
DLLEXPORT Float3operator*= (float f)
 
DLLEXPORT Float3 operator/ (const Float3 &val) const
 
DLLEXPORT Float3 operator/ (float f) const
 
DLLEXPORT bool operator< (const Float3 &other) const
 
DLLEXPORT bool operator<= (const Float3 &other) const
 
DLLEXPORT bool operator> (const Float3 &other) const
 
DLLEXPORT bool operator>= (const Float3 &other) const
 
DLLEXPORT bool operator== (const Float3 &other) const
 
DLLEXPORT bool operator!= (const Float3 &other) const
 
DLLEXPORT float GetX () const
 
DLLEXPORT float GetY () const
 
DLLEXPORT float GetZ () const
 
DLLEXPORT void SetX (const float &val)
 
DLLEXPORT void SetY (const float &val)
 
DLLEXPORT void SetZ (const float &val)
 
DLLEXPORT float HAdd () const
 
DLLEXPORT float HAddAbs () const
 
DLLEXPORT Float3 MinElements (const Float3 &other) const
 
DLLEXPORT Float3 MaxElements (const Float3 &other) const
 
DLLEXPORT Float3 Clamp (const Float3 &min, const Float3 &max)
 
DLLEXPORT Float3 DegreesToRadians ()
 
DLLEXPORT float Dot (const Float3 &val) const
 
DLLEXPORT Float3 Cross (const Float3 &val) const
 
DLLEXPORT float Length () const
 
DLLEXPORT float LengthSquared () const
 
DLLEXPORT Float3 Normalize () const
 
DLLEXPORT Float3 NormalizeSafe (const Float3 &safer=Float3(1, 0, 0)) const
 
DLLEXPORT bool IsNormalized () const
 
DLLEXPORT Float3 Lerp (const Float3 &other, float f) const
 
DLLEXPORT bool Compare (const Float3 &other, float tolerance) const
 
DLLEXPORT Float3 (const Ogre::Vector3 &vec)
 
DLLEXPORT operator Ogre::Vector3 () const
 
DLLEXPORT Float3 (const btVector3 &vec)
 
DLLEXPORT operator btVector3 () const
 
 VALUE_TYPE (Float3)
 

Static Public Member Functions

static DLLEXPORT Float3 CreateVectorFromAngles (const float &yaw, const float &pitch)
 
static DLLEXPORT Float3 zero ()
 
static DLLEXPORT Float3 one ()
 
static DLLEXPORT Float3 x_axis ()
 
static DLLEXPORT Float3 y_axis ()
 
static DLLEXPORT Float3 z_axis ()
 

Public Attributes

float X
 
float Y
 
float Z
 

Static Public Attributes

static const Float3 UnitVForward = Float3(0.f, 0.f, -1.f)
 
static const Float3 UnitVUp = Float3(0.f, 1.f, 0.f)
 
static const Float3 Zeroed = Float3::zero()
 

Detailed Description

Definition at line 638 of file Types.h.

Constructor & Destructor Documentation

◆ Float3() [1/8]

DLLEXPORT Leviathan::Float3::Float3 ( )
inline

Definition at line 641 of file Types.h.

642  {
643  X = Y = Z = 0;
644  };

◆ Float3() [2/8]

DLLEXPORT Leviathan::Float3::Float3 ( float  x,
float  y,
float  z 
)
inline

Definition at line 645 of file Types.h.

646  {
647  X = x;
648  Y = y;
649  Z = z;
650  DO_NAN_CHECK;
651  }
#define DO_NAN_CHECK
Definition: Types.h:21

◆ Float3() [3/8]

DLLEXPORT Leviathan::Float3::Float3 ( Float2  floats,
float  z 
)
inline

Definition at line 652 of file Types.h.

653  {
654  X = floats.X;
655  Y = floats.Y;
656  Z = z;
657  DO_NAN_CHECK;
658  }
#define DO_NAN_CHECK
Definition: Types.h:21

◆ Float3() [4/8]

DLLEXPORT Leviathan::Float3::Float3 ( float  data)
inlineexplicit

Definition at line 659 of file Types.h.

660  {
661  X = Y = Z = data;
662  DO_NAN_CHECK;
663  }
#define DO_NAN_CHECK
Definition: Types.h:21

◆ Float3() [5/8]

DLLEXPORT Leviathan::Float3::Float3 ( const Int3 values)
inline

Definition at line 664 of file Types.h.

665  {
666  X = static_cast<float>(values.X);
667  Y = static_cast<float>(values.Y);
668  Z = static_cast<float>(values.Z);
669 
670  DO_NAN_CHECK;
671  }
#define DO_NAN_CHECK
Definition: Types.h:21

◆ Float3() [6/8]

DLLEXPORT Leviathan::Float3::Float3 ( const Float3 other)
inline

Definition at line 672 of file Types.h.

673  {
674  // copy values //
675  X = other.X;
676  Y = other.Y;
677  Z = other.Z;
678 
679  DO_NAN_CHECK;
680  }
#define DO_NAN_CHECK
Definition: Types.h:21

◆ Float3() [7/8]

DLLEXPORT Leviathan::Float3::Float3 ( const Ogre::Vector3 &  vec)
inline

Definition at line 968 of file Types.h.

969  {
970  // copy values //
971  X = vec.x;
972  Y = vec.y;
973  Z = vec.z;
974  DO_NAN_CHECK;
975  }
#define DO_NAN_CHECK
Definition: Types.h:21

◆ Float3() [8/8]

DLLEXPORT Leviathan::Float3::Float3 ( const btVector3 &  vec)
inline

Definition at line 982 of file Types.h.

983  {
984  // copy values //
985  X = vec.x();
986  Y = vec.y();
987  Z = vec.z();
988  DO_NAN_CHECK;
989  }
#define DO_NAN_CHECK
Definition: Types.h:21

Member Function Documentation

◆ CheckForNans()

DLLEXPORT void Leviathan::Float3::CheckForNans ( )
inline

Definition at line 691 of file Types.h.

692  {
693  if(HasInvalidValues()) {
694  DEBUG_BREAK;
695  throw std::runtime_error("Float3 has NaNs (or infinites in it) in it!");
696  }
697  }
DLLEXPORT bool HasInvalidValues() const
Definition: Types.h:682

◆ Clamp()

DLLEXPORT Float3 Leviathan::Float3::Clamp ( const Float3 min,
const Float3 max 
)
inline

Definition at line 860 of file Types.h.

861  {
862  const Float3 minval = this->MinElements(max);
863  return min.MaxElements(minval);
864  }
DLLEXPORT Float3 MinElements(const Float3 &other) const
Definition: Types.h:849
DLLEXPORT Float3()
Definition: Types.h:641

◆ Compare()

DLLEXPORT bool Leviathan::Float3::Compare ( const Float3 other,
float  tolerance 
) const
inline

Definition at line 924 of file Types.h.

925  {
926  const Float3 difference = (*this) - other;
927  return difference.Dot(difference) < tolerance * tolerance;
928  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ CreateVectorFromAngles()

static DLLEXPORT Float3 Leviathan::Float3::CreateVectorFromAngles ( const float &  yaw,
const float &  pitch 
)
inlinestatic

Definition at line 930 of file Types.h.

931  {
932  return Float3(-sin(yaw * DEGREES_TO_RADIANS), sin(pitch * DEGREES_TO_RADIANS),
933  -cos(yaw * DEGREES_TO_RADIANS))
934  .NormalizeSafe(Zeroed);
935  }
static const Float3 Zeroed
Definition: Types.h:1004
DLLEXPORT Float3()
Definition: Types.h:641
constexpr float DEGREES_TO_RADIANS
Definition: Define.h:61

◆ Cross()

DLLEXPORT Float3 Leviathan::Float3::Cross ( const Float3 val) const
inline

Definition at line 878 of file Types.h.

879  {
880  return Float3(Y * val.Z - val.Y * Z, Z * val.X - val.Z * X, X * val.Y - val.X * Y);
881  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ DegreesToRadians()

DLLEXPORT Float3 Leviathan::Float3::DegreesToRadians ( )
inline

Definition at line 866 of file Types.h.

867  {
868 
870  }
DLLEXPORT Float3()
Definition: Types.h:641
constexpr float DEGREES_TO_RADIANS
Definition: Define.h:61

◆ Dot()

DLLEXPORT float Leviathan::Float3::Dot ( const Float3 val) const
inline

Definition at line 874 of file Types.h.

875  {
876  return X * val.X + Y * val.Y + Z * val.Z;
877  }

◆ GetX()

DLLEXPORT float Leviathan::Float3::GetX ( ) const
inline

Definition at line 810 of file Types.h.

811  {
812  return X;
813  };

◆ GetY()

DLLEXPORT float Leviathan::Float3::GetY ( ) const
inline

Definition at line 814 of file Types.h.

815  {
816  return Y;
817  };

◆ GetZ()

DLLEXPORT float Leviathan::Float3::GetZ ( ) const
inline

Definition at line 818 of file Types.h.

819  {
820  return Z;
821  };

◆ HAdd()

DLLEXPORT float Leviathan::Float3::HAdd ( ) const
inline

Definition at line 839 of file Types.h.

840  {
841  return X + Y + Z;
842  }

◆ HAddAbs()

DLLEXPORT float Leviathan::Float3::HAddAbs ( ) const
inline

Definition at line 844 of file Types.h.

845  {
846  return std::abs(X) + std::abs(Y) + std::abs(Z);
847  }

◆ HasInvalidValues()

DLLEXPORT bool Leviathan::Float3::HasInvalidValues ( ) const
inline

Definition at line 682 of file Types.h.

683  {
684  if(!std::isfinite(X) || !std::isfinite(Y) || !std::isfinite(Z)) {
685  return true;
686  }
687 
688  return false;
689  }
#define isfinite
Definition: jsoncpp.cpp:4247

◆ IsNormalized()

DLLEXPORT bool Leviathan::Float3::IsNormalized ( ) const
inline

Definition at line 912 of file Types.h.

913  {
914  // is absolute -1.f under normalization tolerance //
915  return fabs(X * X + Y * Y + Z * Z - 1.0f) < NORMALIZATION_TOLERANCE;
916  }
constexpr float NORMALIZATION_TOLERANCE
For checking vector normalization.
Definition: Define.h:44

◆ Length()

DLLEXPORT float Leviathan::Float3::Length ( ) const
inline

Definition at line 883 of file Types.h.

884  {
885  return sqrt(X * X + Y * Y + Z * Z);
886  }

◆ LengthSquared()

DLLEXPORT float Leviathan::Float3::LengthSquared ( ) const
inline

Definition at line 887 of file Types.h.

888  {
889  return X * X + Y * Y + Z * Z;
890  }

◆ Lerp()

DLLEXPORT Float3 Leviathan::Float3::Lerp ( const Float3 other,
float  f 
) const
inline

Definition at line 919 of file Types.h.

920  {
921  return Float3((other.X - X) * f + X, (other.Y - Y) * f + Y, (other.Z - Z) * f + Z);
922  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ MaxElements()

DLLEXPORT Float3 Leviathan::Float3::MaxElements ( const Float3 other) const
inline

Definition at line 854 of file Types.h.

855  {
856  return Float3(
857  X > other.X ? X : other.X, Y > other.Y ? Y : other.Y, Z > other.Z ? Z : other.Z);
858  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ MinElements()

DLLEXPORT Float3 Leviathan::Float3::MinElements ( const Float3 other) const
inline

Definition at line 849 of file Types.h.

850  {
851  return Float3(
852  X < other.X ? X : other.X, Y < other.Y ? Y : other.Y, Z < other.Z ? Z : other.Z);
853  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ Normalize()

DLLEXPORT Float3 Leviathan::Float3::Normalize ( ) const
inline

Definition at line 892 of file Types.h.

893  {
894  const float length = Length();
895  if(length == 0)
896  return Float3(0, 0, 0);
897  return Float3(X / length, Y / length, Z / length);
898  }
DLLEXPORT float Length() const
Definition: Types.h:883
DLLEXPORT Float3()
Definition: Types.h:641

◆ NormalizeSafe()

DLLEXPORT Float3 Leviathan::Float3::NormalizeSafe ( const Float3 safer = Float3(1, 0, 0)) const
inline

Definition at line 900 of file Types.h.

901  {
902  // security //
903  // assert(safer.IsNormalized() && "safer not normalized");
904  const float len = X * X + Y * Y + Z * Z;
905  if(len == 0) {
906  return safer;
907  }
908  const float length = sqrt(len);
909  return Float3(X / length, Y / length, Z / length);
910  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ one()

static DLLEXPORT Float3 Leviathan::Float3::one ( )
inlinestatic

Definition at line 944 of file Types.h.

945  {
946  return Float3(1.f, 1.f, 1.f);
947  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ operator btVector3()

DLLEXPORT Leviathan::Float3::operator btVector3 ( ) const
inline

Definition at line 991 of file Types.h.

992  {
993  return btVector3(X, Y, Z);
994  }

◆ operator Ogre::Vector3()

DLLEXPORT Leviathan::Float3::operator Ogre::Vector3 ( ) const
inline

Definition at line 977 of file Types.h.

978  {
979  return Ogre::Vector3(X, Y, Z);
980  }

◆ operator!=()

DLLEXPORT bool Leviathan::Float3::operator!= ( const Float3 other) const
inline

Definition at line 805 of file Types.h.

806  {
807  return !(*this == other);
808  };

◆ operator*() [1/2]

DLLEXPORT Float3 Leviathan::Float3::operator* ( const Float3 val) const
inline

Definition at line 743 of file Types.h.

744  {
745  return Float3(X * val.X, Y * val.Y, Z * val.Z);
746  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ operator*() [2/2]

DLLEXPORT Float3 Leviathan::Float3::operator* ( float  f) const
inline

Definition at line 761 of file Types.h.

762  {
763  return Float3(X * f, Y * f, Z * f);
764  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ operator*=()

DLLEXPORT Float3& Leviathan::Float3::operator*= ( float  f)
inline

Definition at line 765 of file Types.h.

766  {
767  X *= f;
768  Y *= f;
769  Z *= f;
770  DO_NAN_CHECK;
771  return *this;
772  }
#define DO_NAN_CHECK
Definition: Types.h:21

◆ operator+()

DLLEXPORT Float3 Leviathan::Float3::operator+ ( const Float3 val) const
inline

Definition at line 713 of file Types.h.

714  {
715  return Float3(X + val.X, Y + val.Y, Z + val.Z);
716  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ operator+=()

DLLEXPORT Float3& Leviathan::Float3::operator+= ( const Float3 val)
inline

Definition at line 717 of file Types.h.

718  {
719  X += val.X;
720  Y += val.Y;
721  Z += val.Z;
722  return *this;
723  }

◆ operator-() [1/2]

DLLEXPORT Float3 Leviathan::Float3::operator- ( const Float3 val) const
inline

Definition at line 733 of file Types.h.

734  {
735  return Float3(X - val.X, Y - val.Y, Z - val.Z);
736  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ operator-() [2/2]

DLLEXPORT Float3 Leviathan::Float3::operator- ( ) const
inline

Definition at line 738 of file Types.h.

739  {
740  return Float3(-X, -Y, -Z);
741  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ operator-=()

DLLEXPORT Float3& Leviathan::Float3::operator-= ( const Float3 val)
inline

Definition at line 724 of file Types.h.

725  {
726  X -= val.X;
727  Y -= val.Y;
728  Z -= val.Z;
729  return *this;
730  }

◆ operator/() [1/3]

DLLEXPORT Float3 Leviathan::Float3::operator/ ( const float &  val) const
inline

Definition at line 748 of file Types.h.

749  {
750  return Float3(X / val, Y / val, Z / val);
751  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ operator/() [2/3]

DLLEXPORT Float3 Leviathan::Float3::operator/ ( const Float3 val) const
inline

Definition at line 774 of file Types.h.

775  {
776  return Float3(X / val.X, Y / val.Y, Z / val.Z);
777  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ operator/() [3/3]

DLLEXPORT Float3 Leviathan::Float3::operator/ ( float  f) const
inline

Definition at line 779 of file Types.h.

780  {
781  return Float3(X / f, Y / f, Z / f);
782  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ operator/=()

DLLEXPORT Float3& Leviathan::Float3::operator/= ( const float &  val)
inline

Definition at line 752 of file Types.h.

753  {
754  X /= val;
755  Y /= val;
756  Z /= val;
757  DO_NAN_CHECK;
758  return *this;
759  }
#define DO_NAN_CHECK
Definition: Types.h:21

◆ operator<()

DLLEXPORT bool Leviathan::Float3::operator< ( const Float3 other) const
inline

Definition at line 785 of file Types.h.

786  {
787  return X < other.X && Y < other.Y && Z < other.Z;
788  };

◆ operator<=()

DLLEXPORT bool Leviathan::Float3::operator<= ( const Float3 other) const
inline

Definition at line 789 of file Types.h.

790  {
791  return X <= other.X && Y <= other.Y && Z <= other.Z;
792  };

◆ operator==()

DLLEXPORT bool Leviathan::Float3::operator== ( const Float3 other) const
inline

Definition at line 801 of file Types.h.

802  {
803  return X == other.X && Y == other.Y && Z == other.Z;
804  };

◆ operator>()

DLLEXPORT bool Leviathan::Float3::operator> ( const Float3 other) const
inline

Definition at line 793 of file Types.h.

794  {
795  return X > other.X && Y > other.Y && Z > other.Z;
796  };

◆ operator>=()

DLLEXPORT bool Leviathan::Float3::operator>= ( const Float3 other) const
inline

Definition at line 797 of file Types.h.

798  {
799  return X >= other.X && Y >= other.Y && Z > other.Z;
800  };

◆ operator[]()

DLLEXPORT float& Leviathan::Float3::operator[] ( const int &  nindex)
inline

Definition at line 700 of file Types.h.

701  {
702  switch(nindex) {
703  case 0: return X;
704  case 1: return Y;
705  case 2: return Z;
706  }
707  LEVIATHAN_ASSERT(0, "invalid [] access");
708  return X;
709  }
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:92

◆ SetX()

DLLEXPORT void Leviathan::Float3::SetX ( const float &  val)
inline

Definition at line 822 of file Types.h.

823  {
824  X = val;
825  DO_NAN_CHECK;
826  };
#define DO_NAN_CHECK
Definition: Types.h:21

◆ SetY()

DLLEXPORT void Leviathan::Float3::SetY ( const float &  val)
inline

Definition at line 827 of file Types.h.

828  {
829  Y = val;
830  DO_NAN_CHECK;
831  };
#define DO_NAN_CHECK
Definition: Types.h:21

◆ SetZ()

DLLEXPORT void Leviathan::Float3::SetZ ( const float &  val)
inline

Definition at line 832 of file Types.h.

833  {
834  Z = val;
835  DO_NAN_CHECK;
836  };
#define DO_NAN_CHECK
Definition: Types.h:21

◆ VALUE_TYPE()

Leviathan::Float3::VALUE_TYPE ( Float3  )

◆ x_axis()

static DLLEXPORT Float3 Leviathan::Float3::x_axis ( )
inlinestatic

Definition at line 950 of file Types.h.

951  {
952  return Float3(1.f, 0.f, 0.f);
953  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ y_axis()

static DLLEXPORT Float3 Leviathan::Float3::y_axis ( )
inlinestatic

Definition at line 956 of file Types.h.

957  {
958  return Float3(0.f, 1.f, 0.f);
959  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ z_axis()

static DLLEXPORT Float3 Leviathan::Float3::z_axis ( )
inlinestatic

Definition at line 962 of file Types.h.

963  {
964  return Float3(0.f, 0.f, 1.f);
965  }
DLLEXPORT Float3()
Definition: Types.h:641

◆ zero()

static DLLEXPORT Float3 Leviathan::Float3::zero ( )
inlinestatic

Definition at line 939 of file Types.h.

940  {
941  return Float3(0.f, 0.f, 0.f);
942  }
DLLEXPORT Float3()
Definition: Types.h:641

Member Data Documentation

◆ UnitVForward

const Float3 Leviathan::Float3::UnitVForward = Float3(0.f, 0.f, -1.f)
static

Definition at line 1002 of file Types.h.

◆ UnitVUp

const Float3 Leviathan::Float3::UnitVUp = Float3(0.f, 1.f, 0.f)
static

Definition at line 1003 of file Types.h.

◆ X

float Leviathan::Float3::X

Definition at line 1000 of file Types.h.

◆ Y

float Leviathan::Float3::Y

Definition at line 1000 of file Types.h.

◆ Z

float Leviathan::Float3::Z

Definition at line 1000 of file Types.h.

◆ Zeroed

const Float3 Leviathan::Float3::Zeroed = Float3::zero()
static

Definition at line 1004 of file Types.h.


The documentation for this struct was generated from the following files: