KrisLibrary  1.0.0
math3d/basis.h
Go to the documentation of this file.
1 #ifndef MATH3D_BASIS_H
2 #define MATH3D_BASIS_H
3 
4 #include "primitives.h"
5 
12 namespace Math3D {
13 
16 
19  inline void GetCanonicalBasis(const Vector2& x,Vector2&y) {
20  y.setPerpendicular(x);
21  }
24  inline void GetCanonicalBasis(const Vector3& x,Vector3&y,Vector3& z) {
25  Real scale;
26  if(FuzzyEquals(x.x,1.0)) scale = 0;
27  else if(FuzzyEquals(x.x,-1.0)) { //A complete flip of the basis
28  y.set(0.0,-1.0,0.0);
29  z.set(0.0,0.0,1.0);
30  return;
31  }
32  else scale = (1.0-x.x)/(1.0-Sqr(x.x));
33  y.x = -x.y;
34  y.y = x.x + scale*Sqr(x.z);
35  y.z = -scale*x.y*x.z;
36  z.x = -x.z;
37  z.y = -scale*x.y*x.z;
38  z.z = x.x + scale*Sqr(x.y);
39  }
40 
43 } //namespace Math3D
44 
45 #endif
A 3D vector class.
Definition: math3d/primitives.h:136
Class declarations for useful 3D math types.
void GetCanonicalBasis(const Vector2 &x, Vector2 &y)
Definition: math3d/basis.h:19
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:12
void setPerpendicular(const Vector2 &)
sets this to the vector rotated 90 degrees ccw
Definition: math3d/primitives.h:1000
A 2D vector class.
Definition: math3d/primitives.h:41
bool FuzzyEquals(double a, double b, double eps=dEpsilon)
Returns true if a and b are within +/- eps.
Definition: math.h:222