Intersection.h
Go to the documentation of this file.00001 #ifndef INTERSECTION_H_
00002 #define INTERSECTION_H_
00003
00004 #include "math/Vector3.h"
00005 #include "math/line.h"
00006
00007 void point_for_device_point (Vector3& point, const Matrix4& device2object, const float x, const float y, const float z);
00008 void ray_for_device_point (Ray& ray, const Matrix4& device2object, const float x, const float y);
00009
00010 bool sphere_intersect_ray (const Vector3& origin, float radius, const Ray& ray, Vector3& intersection);
00011 void ray_intersect_ray (const Ray& ray, const Ray& other, Vector3& intersection);
00012
00013 void point_on_sphere (Vector3& point, const Matrix4& device2object, const float x, const float y);
00014 void point_on_axis (Vector3& point, const Vector3& axis, const Matrix4& device2object, const float x, const float y);
00015 void point_on_plane (Vector3& point, const Matrix4& device2object, const float x, const float y);
00016
00018 inline float angle_between (const Vector3& a, const Vector3& b)
00019 {
00020 return static_cast<float> (2.0 * atan2((a - b).getLength(), (a + b).getLength()));
00021 }
00022
00024 inline void constrain_to_axis (Vector3& vec, const Vector3& axis)
00025 {
00026 vec = (vec + axis * (-vec.dot(axis))).getNormalised();
00027 }
00028
00030 float angle_for_axis (const Vector3& a, const Vector3& b, const Vector3& axis);
00031
00032 float distance_for_axis (const Vector3& a, const Vector3& b, const Vector3& axis);
00033
00034 #endif