IceRay.h
Go to the documentation of this file.
1 
8 
11 // Include Guard
12 #ifndef __ICERAY_H__
13 #define __ICERAY_H__
14 
16  {
17  public:
19  inline_ Ray() {}
21  inline_ Ray(const Point& orig, const Point& dir) : mOrig(orig), mDir(dir) {}
23  inline_ Ray(const Ray& ray) : mOrig(ray.mOrig), mDir(ray.mDir) {}
26 
27  float SquareDistance(const Point& point, float* t=null) const;
28  inline_ float Distance(const Point& point, float* t=null) const { return sqrtf(SquareDistance(point, t)); }
29 
32  };
33 
34  inline_ void ComputeReflexionVector(Point& reflected, const Point& incoming_dir, const Point& outward_normal)
35  {
36  reflected = incoming_dir - outward_normal * 2.0f * (incoming_dir|outward_normal);
37  }
38 
39  inline_ void ComputeReflexionVector(Point& reflected, const Point& source, const Point& impact, const Point& normal)
40  {
41  Point V = impact - source;
42  reflected = V - normal * 2.0f * (V|normal);
43  }
44 
45  inline_ void DecomposeVector(Point& normal_compo, Point& tangent_compo, const Point& outward_dir, const Point& outward_normal)
46  {
47  normal_compo = outward_normal * (outward_dir|outward_normal);
48  tangent_compo = outward_dir - normal_compo;
49  }
50 
52 
58  inline_ void ComputeLocalDirection(Point& local_dir, const Point& world_dir, const Matrix4x4& world)
60  {
61  // Get world direction back in local space
62 // Matrix3x3 InvWorld = world;
63 // local_dir = InvWorld * world_dir;
64  local_dir = Matrix3x3(world) * world_dir;
65  }
66 
68 
74  inline_ void ComputeLocalPoint(Point& local_pt, const Point& world_pt, const Matrix4x4& world)
76  {
77  // Get world vertex back in local space
78  Matrix4x4 InvWorld = world;
79  InvWorld.Invert();
80  local_pt = world_pt * InvWorld;
81  }
82 
84 
90  inline_ void ComputeLocalRay(Ray& local_ray, const Ray& world_ray, const Matrix4x4& world)
92  {
93  // Get world ray back in local space
94  ComputeLocalDirection(local_ray.mDir, world_ray.mDir, world);
95  ComputeLocalPoint(local_ray.mOrig, world_ray.mOrig, world);
96  }
97 
98 #endif // __ICERAY_H__
Point mDir
Normalized direction.
Definition: IceRay.h:31
#define null
our own NULL pointer
Definition: IceTypes.h:57
#define inline_
Definition: IcePoint.h:25
#define ICEMATHS_API
Definition: OPC_IceHook.h:51
inline_ Ray()
Constructor.
Definition: IceRay.h:19
inline_ Ray(const Point &orig, const Point &dir)
Constructor.
Definition: IceRay.h:21
inline_ void ComputeLocalDirection(Point &local_dir, const Point &world_dir, const Matrix4x4 &world)
Definition: IceRay.h:59
inline_ void ComputeReflexionVector(Point &reflected, const Point &incoming_dir, const Point &outward_normal)
Definition: IceRay.h:34
inline_ void ComputeLocalRay(Ray &local_ray, const Ray &world_ray, const Matrix4x4 &world)
Definition: IceRay.h:91
Point mOrig
Ray origin.
Definition: IceRay.h:30
inline_ void ComputeLocalPoint(Point &local_pt, const Point &world_pt, const Matrix4x4 &world)
Definition: IceRay.h:75
Matrix4x4 & Invert()
Inverts the matrix. Determinant must be different from zero, else matrix can't be inverted...
t
Definition: IceRay.h:15
inline_ Ray(const Ray &ray)
Copy constructor.
Definition: IceRay.h:23
inline_ float Distance(const Point &point, float *t=null) const
Definition: IceRay.h:28
inline_ void DecomposeVector(Point &normal_compo, Point &tangent_compo, const Point &outward_dir, const Point &outward_normal)
Definition: IceRay.h:45
inline_ ~Ray()
Destructor.
Definition: IceRay.h:25


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:38