1 /// @ref gtx_intersect
2 /// @file glm/gtx/intersect.hpp
3 ///
4 /// @see core (dependence)
5 /// @see gtx_closest_point (dependence)
6 ///
7 /// @defgroup gtx_intersect GLM_GTX_intersect
8 /// @ingroup gtx
9 ///
10 /// @brief Add intersection functions
11 ///
12 /// <glm/gtx/intersect.hpp> need to be included to use these functionalities.
13 
14 #pragma once
15 
16 // Dependency:
17 #include <cfloat>
18 #include <limits>
19 #include "../glm.hpp"
20 #include "../geometric.hpp"
21 #include "../gtx/closest_point.hpp"
22 #include "../gtx/vector_query.hpp"
23 
24 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
25 #	pragma message("GLM: GLM_GTX_closest_point extension included")
26 #endif
27 
28 namespace glm
29 {
30 	/// @addtogroup gtx_intersect
31 	/// @{
32 
33 	//! Compute the intersection of a ray and a plane.
34 	//! Ray direction and plane normal must be unit length.
35 	//! From GLM_GTX_intersect extension.
36 	template <typename genType>
37 	GLM_FUNC_DECL bool intersectRayPlane(
38 		genType const & orig, genType const & dir,
39 		genType const & planeOrig, genType const & planeNormal,
40 		typename genType::value_type & intersectionDistance);
41 
42 	//! Compute the intersection of a ray and a triangle.
43 	//! From GLM_GTX_intersect extension.
44 	template <typename genType>
45 	GLM_FUNC_DECL bool intersectRayTriangle(
46 		genType const & orig, genType const & dir,
47 		genType const & vert0, genType const & vert1, genType const & vert2,
48 		genType & baryPosition);
49 
50 	//! Compute the intersection of a line and a triangle.
51 	//! From GLM_GTX_intersect extension.
52 	template <typename genType>
53 	GLM_FUNC_DECL bool intersectLineTriangle(
54 		genType const & orig, genType const & dir,
55 		genType const & vert0, genType const & vert1, genType const & vert2,
56 		genType & position);
57 
58 	//! Compute the intersection distance of a ray and a sphere.
59 	//! The ray direction vector is unit length.
60 	//! From GLM_GTX_intersect extension.
61 	template <typename genType>
62 	GLM_FUNC_DECL bool intersectRaySphere(
63 		genType const & rayStarting, genType const & rayNormalizedDirection,
64 		genType const & sphereCenter, typename genType::value_type const sphereRadiusSquered,
65 		typename genType::value_type & intersectionDistance);
66 
67 	//! Compute the intersection of a ray and a sphere.
68 	//! From GLM_GTX_intersect extension.
69 	template <typename genType>
70 	GLM_FUNC_DECL bool intersectRaySphere(
71 		genType const & rayStarting, genType const & rayNormalizedDirection,
72 		genType const & sphereCenter, const typename genType::value_type sphereRadius,
73 		genType & intersectionPosition, genType & intersectionNormal);
74 
75 	//! Compute the intersection of a line and a sphere.
76 	//! From GLM_GTX_intersect extension
77 	template <typename genType>
78 	GLM_FUNC_DECL bool intersectLineSphere(
79 		genType const & point0, genType const & point1,
80 		genType const & sphereCenter, typename genType::value_type sphereRadius,
81 		genType & intersectionPosition1, genType & intersectionNormal1,
82 		genType & intersectionPosition2 = genType(), genType & intersectionNormal2 = genType());
83 
84 	/// @}
85 }//namespace glm
86 
87 #include "intersect.inl"
88