1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #pragma once19 20 #include "[Math/MathFwd.h]"21 #include "[Math/float3.h]"22 23 #ifdef MATH_OGRE_INTEROP24 #include <OgreRay.h>25 #endif26 27 [MATH_BEGIN_NAMESPACE]28 29 30 class [Ray]31 {32 public:33 34 [float3] [pos];35 36 37 38 39 [float3] [dir];40 41 42 43 44 45 [Ray]() {}46 47 48 49 50 51 52 [Ray](const [float3] &[pos], const [float3] &[dir]);53 54 55 56 57 58 59 explicit [Ray](const [Line] &line);60 61 62 63 64 explicit [Ray](const [LineSegment] &lineSegment);65 66 67 68 69 70 71 72 73 [float3] [GetPoint](float distance) const;74 75 76 77 void [Transform](const [float3x3] &transform);78 void [Transform](const [float3x4] &transform);79 void [Transform](const [float4x4] &transform);80 void [Transform](const [Quat] &transform);81 82 83 84 85 86 87 88 bool [Contains](const [float3] &point, float distanceThreshold = 1[e]-3f) const;89 bool [Contains](const [LineSegment] &lineSegment, float distanceThreshold = 1[e]-3f) const;90 91 92 93 bool [Equals](const [Ray] &otherRay, float epsilon = 1[e]-3f) const;94 95 96 97 98 99 100 101 102 float [Distance](const [float3] &point, float *d) const;103 float [Distance](const [float3] &point) const;104 105 106 107 108 float [Distance](const [Ray] &other, float *d, float *d2 = 0) const;109 float [Distance](const [Ray] &other) const;110 float [Distance](const [Line] &other, float *d, float *d2 = 0) const;111 float [Distance](const [Line] &other) const;112 float [Distance](const [LineSegment] &other, float *d, float *d2 = 0) const;113 float [Distance](const [LineSegment] &other) const;114 float [Distance](const [Sphere] &sphere) const;115 float [Distance](const [Capsule] &capsule) const;116 117 118 119 120 121 122 123 124 [float3] [ClosestPoint](const [float3] &targetPoint, float *d = 0) const;125 126 127 128 [float3] [ClosestPoint](const [Ray] &other, float *d = 0, float *d2 = 0) const;129 [float3] [ClosestPoint](const [Line] &other, float *d = 0, float *d2 = 0) const;130 [float3] [ClosestPoint](const [LineSegment] &other, float *d = 0, float *d2 = 0) const;131 132 133 134 135 136 137 138 139 140 141 142 bool [Intersects](const [Triangle] &triangle, float *d, [float3] *intersectionPoint) const;143 bool [Intersects](const [Triangle] &triangle) const;144 bool [Intersects](const [Plane] &plane, float *d) const;145 bool [Intersects](const [Plane] &plane) const;146 147 148 bool [Intersects](const [Sphere] &s, [float3] *intersectionPoint, [float3] *intersectionNormal, float *d) const;149 bool [Intersects](const [Sphere] &s) const;150 151 152 153 154 bool [Intersects](const [AABB] &aabb, float *dNear, float *dFar) const;155 bool [Intersects](const [AABB] &aabb) const;156 bool [Intersects](const [OBB] &obb, float *dNear, float *dFar) const;157 bool [Intersects](const [OBB] &obb) const;158 bool [Intersects](const [Capsule] &capsule) const;159 bool [Intersects](const [Polygon] &polygon) const;160 bool [Intersects](const [Frustum] &frustum) const;161 bool [Intersects](const [Polyhedron] &polyhedron) const;162 163 164 bool [IntersectsDisc](const [Circle] &disc) const;165 166 167 168 169 170 171 [Line] [ToLine]() const;172 173 174 175 176 177 [LineSegment] [ToLineSegment](float d) const;178 179 #ifdef MATH_ENABLE_STL_SUPPORT180 181 182 std::string ToString() const;183 #endif184 #ifdef MATH_QT_INTEROP185 operator QString() const { return toString(); }186 QString toString() const { return QString::fromStdString(ToString()); }187 #endif188 189 #ifdef MATH_OGRE_INTEROP190 [Ray](const Ogre::Ray &other) { [pos] = other.getOrigin(); [dir] = other.getDirection(); }191 [operator Ogre::Ray]() const { return [Ogre::Ray]([pos], [dir]); }192 #endif193 194 };195 196 [Ray] [operator *](const [float3x3] &transform, const [Ray] &ray);197 [Ray] [operator *](const [float3x4] &transform, const [Ray] &ray);198 [Ray] [operator *](const [float4x4] &transform, const [Ray] &ray);199 [Ray] [operator *](const [Quat] &transform, const [Ray] &ray);200 201 [MATH_END_NAMESPACE]202 203 #ifdef MATH_QT_INTEROP204 Q_DECLARE_METATYPE([Ray])205 Q_DECLARE_METATYPE([Ray]*)206 #endif Go back to previous page