IceRay.h
Go to the documentation of this file.
00001 
00002 
00008 
00009 
00011 // Include Guard
00012 #ifndef __ICERAY_H__
00013 #define __ICERAY_H__
00014 
00015         class ICEMATHS_API Ray
00016         {
00017                 public:
00019                 inline_                                 Ray()                                                                                                                           {}
00021                 inline_                                 Ray(const Point& orig, const Point& dir) : mOrig(orig), mDir(dir)       {}
00023                 inline_                                 Ray(const Ray& ray) : mOrig(ray.mOrig), mDir(ray.mDir)                          {}
00025                 inline_                                 ~Ray()                                                                                                                          {}
00026 
00027                                                 float   SquareDistance(const Point& point, float* t=null)       const;
00028                 inline_                 float   Distance(const Point& point, float* t=null)                     const                   { return sqrtf(SquareDistance(point, t));       }
00029 
00030                                                 Point   mOrig;          
00031                                                 Point   mDir;           
00032         };
00033 
00034         inline_ void ComputeReflexionVector(Point& reflected, const Point& incoming_dir, const Point& outward_normal)
00035         {
00036                 reflected = incoming_dir - outward_normal * 2.0f * (incoming_dir|outward_normal);
00037         }
00038 
00039         inline_ void ComputeReflexionVector(Point& reflected, const Point& source, const Point& impact, const Point& normal)
00040         {
00041                 Point V = impact - source;
00042                 reflected = V - normal * 2.0f * (V|normal);
00043         }
00044 
00045         inline_ void DecomposeVector(Point& normal_compo, Point& tangent_compo, const Point& outward_dir, const Point& outward_normal)
00046         {
00047                 normal_compo = outward_normal * (outward_dir|outward_normal);
00048                 tangent_compo = outward_dir - normal_compo;
00049         }
00050 
00052 
00058 
00059         inline_ void ComputeLocalDirection(Point& local_dir, const Point& world_dir, const Matrix4x4& world)
00060         {
00061                 // Get world direction back in local space
00062 //              Matrix3x3 InvWorld = world;
00063 //              local_dir = InvWorld * world_dir;
00064                 local_dir = Matrix3x3(world) * world_dir;
00065         }
00066 
00068 
00074 
00075         inline_ void ComputeLocalPoint(Point& local_pt, const Point& world_pt, const Matrix4x4& world)
00076         {
00077                 // Get world vertex back in local space
00078                 Matrix4x4 InvWorld = world;
00079                 InvWorld.Invert();
00080                 local_pt = world_pt * InvWorld;
00081         }
00082 
00084 
00090 
00091         inline_ void ComputeLocalRay(Ray& local_ray, const Ray& world_ray, const Matrix4x4& world)
00092         {
00093                 // Get world ray back in local space
00094                 ComputeLocalDirection(local_ray.mDir, world_ray.mDir, world);
00095                 ComputeLocalPoint(local_ray.mOrig, world_ray.mOrig, world);
00096         }
00097 
00098 #endif // __ICERAY_H__


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:17