diff options
author | Brad Davis <[email protected]> | 2013-10-10 23:31:48 -0700 |
---|---|---|
committer | Brad Davis <[email protected]> | 2013-10-10 23:31:48 -0700 |
commit | cf0441a1dc790d6fdca7400a7db7a939c2fa6000 (patch) | |
tree | edaf4e78195d789b1e3b724328951324db085324 /LibOVR/Src/Kernel/OVR_Math.cpp | |
parent | abfcde20cd83aa36e83186a0745425bcdead6144 (diff) |
Adding Linux 0.2.5 changes
Diffstat (limited to 'LibOVR/Src/Kernel/OVR_Math.cpp')
-rw-r--r-- | LibOVR/Src/Kernel/OVR_Math.cpp | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/LibOVR/Src/Kernel/OVR_Math.cpp b/LibOVR/Src/Kernel/OVR_Math.cpp index 3c35bde..d971d65 100644 --- a/LibOVR/Src/Kernel/OVR_Math.cpp +++ b/LibOVR/Src/Kernel/OVR_Math.cpp @@ -3,7 +3,7 @@ Filename : OVR_Math.h Content : Implementation of 3D primitives such as vectors, matrices. Created : September 4, 2012 -Authors : Andrew Reisse, Michael Antonov +Authors : Andrew Reisse, Michael Antonov, Anna Yershova Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved. @@ -14,9 +14,11 @@ otherwise accompanies this software in either electronic or hard copy form. *************************************************************************************/ #include "OVR_Math.h" +#include "OVR_Log.h" #include <float.h> + namespace OVR { @@ -31,15 +33,14 @@ const float Math<float>::PiOver2 = 3.1415926f / 2.0f; const float Math<float>::PiOver4 = 3.1415926f / 4.0f; const float Math<float>::E = 2.7182818f; -const float Math<float>::MaxValue = FLT_MAX; -const float Math<float>::MinPositiveValue = FLT_MIN; - -const float Math<float>::RadToDegreeFactor = 360.0f / Math<float>::TwoPi; -const float Math<float>::DegreeToRadFactor = Math<float>::TwoPi / 360.0f; +const float Math<float>::MaxValue = FLT_MAX; +const float Math<float>::MinPositiveValue = FLT_MIN; -const float Math<float>::Tolerance = 0.00001f; -const float Math<float>::SingularityRadius = 0.0000001f; // Use for Gimbal lock numerical problems +const float Math<float>::RadToDegreeFactor = 360.0f / Math<float>::TwoPi; +const float Math<float>::DegreeToRadFactor = Math<float>::TwoPi / 360.0f; +const float Math<float>::Tolerance = 0.00001f; +const float Math<float>::SingularityRadius = 0.0000001f; // Use for Gimbal lock numerical problems // Double-precision Math constants class. const double Math<double>::Pi = 3.14159265358979; @@ -48,14 +49,14 @@ const double Math<double>::PiOver2 = 3.14159265358979 / 2.0; const double Math<double>::PiOver4 = 3.14159265358979 / 4.0; const double Math<double>::E = 2.71828182845905; -const double Math<double>::MaxValue = DBL_MAX; -const double Math<double>::MinPositiveValue = DBL_MIN; +const double Math<double>::MaxValue = DBL_MAX; +const double Math<double>::MinPositiveValue = DBL_MIN; -const double Math<double>::RadToDegreeFactor = 360.0 / Math<double>::TwoPi; -const double Math<double>::DegreeToRadFactor = Math<double>::TwoPi / 360.0; +const double Math<double>::RadToDegreeFactor = 360.0 / Math<double>::TwoPi; +const double Math<double>::DegreeToRadFactor = Math<double>::TwoPi / 360.0; -const double Math<double>::Tolerance = 0.00001; -const double Math<double>::SingularityRadius = 0.000000000001; // Use for Gimbal lock numerical problems +const double Math<double>::Tolerance = 0.00001; +const double Math<double>::SingularityRadius = 0.000000000001; // Use for Gimbal lock numerical problems @@ -69,9 +70,9 @@ Matrix4f Matrix4f::LookAtRH(const Vector3f& eye, const Vector3f& at, const Vecto Vector3f x = up.Cross(z).Normalized(); // Right Vector3f y = z.Cross(x); - Matrix4f m(x.x, x.y, x.z, -(x * eye), - y.x, y.y, y.z, -(y * eye), - z.x, z.y, z.z, -(z * eye), + Matrix4f m(x.x, x.y, x.z, -(x.Dot(eye)), + y.x, y.y, y.z, -(y.Dot(eye)), + z.x, z.y, z.z, -(z.Dot(eye)), 0, 0, 0, 1 ); return m; } @@ -82,9 +83,9 @@ Matrix4f Matrix4f::LookAtLH(const Vector3f& eye, const Vector3f& at, const Vecto Vector3f x = up.Cross(z).Normalized(); // Right Vector3f y = z.Cross(x); - Matrix4f m(x.x, x.y, x.z, -(x * eye), - y.x, y.y, y.z, -(y * eye), - z.x, z.y, z.z, -(z * eye), + Matrix4f m(x.x, x.y, x.z, -(x.Dot(eye)), + y.x, y.y, y.z, -(y.Dot(eye)), + z.x, z.y, z.z, -(z.Dot(eye)), 0, 0, 0, 1 ); return m; } @@ -127,18 +128,6 @@ Matrix4f Matrix4f::PerspectiveRH(float yfov, float aspect, float znear, float zf return m; } - -/* -OffCenterLH - -2*zn/(r-l) 0 0 0 -0 2*zn/(t-b) 0 0 -(l+r)/(l-r) (t+b)/(b-t) zf/(zf-zn) 1 -0 0 zn*zf/(zn-zf) 0 - -*/ - - Matrix4f Matrix4f::Ortho2D(float w, float h) { Matrix4f m; @@ -150,4 +139,5 @@ Matrix4f Matrix4f::Ortho2D(float w, float h) return m; } -} + +} // Namespace OVR |