1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #pragma once19 20 #include "../MathGeoLibFwd.h"21 #include "../Math/float3.h"22 23 #ifdef MATH_OGRE_INTEROP24 #include <OgreRay.h>25 #endif26 #ifdef MATH_URHO3D_INTEROP27 #include <Urho3D/Math/Ray.h>28 #endif29 30 [MATH_BEGIN_NAMESPACE]31 32 33 class [Ray]34 {35 public:36 37 vec [pos];38 39 40 41 42 vec [dir];43 44 45 46 47 48 [Ray]() {}49 50 51 52 53 54 55 [Ray](const vec &[pos], const vec &[dir]);56 57 58 59 60 61 62 explicit [Ray](const [Line] &line);63 64 65 66 67 explicit [Ray](const [LineSegment] &lineSegment);68 69 bool [IsFinite]() const;70 71 72 73 74 75 76 77 78 vec [GetPoint](float distance) const;79 80 81 82 83 void [Translate](const vec &offset);84 85 86 87 void [Transform](const [float3x3] &transform);88 void [Transform](const [float3x4] &transform);89 void [Transform](const [float4x4] &transform);90 void [Transform](const [Quat] &transform);91 92 93 94 95 96 97 98 bool [Contains](const vec &point, float distanceThreshold = 1[e]-3f) const;99 bool [Contains](const [LineSegment] &lineSegment, float distanceThreshold = 1[e]-3f) const;100 101 102 103 bool [Equals](const [Ray] &otherRay, float [epsilon] = 1[e]-3f) const;104 105 106 107 bool [BitEquals](const [Ray] &other) const { return [pos].[BitEquals](other.[pos]) && [dir].[BitEquals](other.[dir]); }108 109 110 111 112 113 114 115 float [Distance](const vec &point) const { float [d]; return [Distance](point, d); }116 float [Distance](const vec &point, float &[d]) const;117 118 119 120 float [Distance](const [Ray] &other) const { float [d], d2; return [Distance](other, d, d2); }121 float [Distance](const [Ray] &other, float &[d]) const { float d2; return [Distance](other, d, d2); }122 float [Distance](const [Ray] &other, float &[d], float &d2) const;123 float [Distance](const [Line] &other) const { float [d], d2; return [Distance](other, d, d2); }124 float [Distance](const [Line] &other, float &[d]) const { float d2; return [Distance](other, d, d2); }125 float [Distance](const [Line] &other, float &[d], float &d2) const;126 float [Distance](const [LineSegment] &other) const { float [d], d2; return [Distance](other, d, d2); }127 float [Distance](const [LineSegment] &other, float &[d]) const { float d2; return [Distance](other, d, d2); }128 float [Distance](const [LineSegment] &other, float &[d], float &d2) const;129 float [Distance](const [Sphere] &sphere) const;130 float [Distance](const [Capsule] &capsule) const;131 132 133 134 135 136 137 138 vec [ClosestPoint](const vec &targetPoint) const { float [d]; return [ClosestPoint](targetPoint, d); }139 vec [ClosestPoint](const vec &targetPoint, float &[d]) const;140 141 142 vec [ClosestPoint](const [Ray] &other) const { float [d], d2; return [ClosestPoint](other, d, d2); }143 vec [ClosestPoint](const [Ray] &other, float &[d]) const { float d2; return [ClosestPoint](other, d, d2); }144 vec [ClosestPoint](const [Ray] &other, float &[d], float &d2) const;145 vec [ClosestPoint](const [Line] &other) const { float [d], d2; return [ClosestPoint](other, d, d2); }146 vec [ClosestPoint](const [Line] &other, float &[d]) const { float d2; return [ClosestPoint](other, d, d2); }147 vec [ClosestPoint](const [Line] &other, float &[d], float &d2) const;148 vec [ClosestPoint](const [LineSegment] &other) const { float [d], d2; return [ClosestPoint](other, d, d2); }149 vec [ClosestPoint](const [LineSegment] &other, float &[d]) const { float d2; return [ClosestPoint](other, d, d2); }150 vec [ClosestPoint](const [LineSegment] &other, float &[d], float &d2) const;151 152 153 154 155 156 157 158 159 160 161 162 bool [Intersects](const [Triangle] &triangle, float *[d], vec *intersectionPoint) const;163 bool [Intersects](const [Triangle] &triangle) const;164 bool [Intersects](const [Plane] &plane, float *[d]) const;165 bool [Intersects](const [Plane] &plane) const;166 167 168 bool [Intersects](const [Sphere] &s, vec *intersectionPoint, vec *intersectionNormal, float *[d]) const;169 bool [Intersects](const [Sphere] &s) const;170 171 172 173 174 bool [Intersects](const [AABB] &aabb, float &dNear, float &dFar) const;175 bool [Intersects](const [AABB] &aabb) const;176 bool [Intersects](const [OBB] &obb, float &dNear, float &dFar) const;177 bool [Intersects](const [OBB] &obb) const;178 bool [Intersects](const [Capsule] &capsule) const;179 bool [Intersects](const [Polygon] &polygon) const;180 bool [Intersects](const [Frustum] &frustum) const;181 bool [Intersects](const [Polyhedron] &polyhedron) const;182 183 184 bool [IntersectsDisc](const [Circle] &disc) const;185 186 187 188 189 190 191 [Line] [ToLine]() const;192 193 194 195 196 197 [LineSegment] [ToLineSegment](float [d]) const;198 199 200 201 202 203 204 205 206 void [ProjectToAxis](const vec &direction, float &outMin, float &outMax) const;207 208 209 210 211 212 213 214 [LineSegment] [ToLineSegment](float dStart, float dEnd) const;215 216 #ifdef MATH_ENABLE_STL_SUPPORT217 218 219 std::string [ToString]() const;220 std::string [SerializeToString]() const;221 222 223 std::string [SerializeToCodeString]() const;224 #endif225 226 static [Ray] [FromString](const char *str, const char **outEndStr = 0);227 #ifdef MATH_ENABLE_STL_SUPPORT228 static [Ray] [FromString](const std::string &str) { return [FromString](str.c_str()); }229 #endif230 231 #ifdef MATH_QT_INTEROP232 operator QString() const { return toString(); }233 QString toString() const { return QString::fromStdString([ToString]()); }234 #endif235 #ifdef MATH_OGRE_INTEROP236 [Ray](const Ogre::Ray &other):[pos](other.getOrigin()), [dir](other.getDirection()) {}237 operator Ogre::Ray() const { return Ogre::Ray([pos], [dir]); }238 #endif239 #ifdef MATH_URHO3D_INTEROP240 [Ray](const Urho3D::Ray &other) : [pos](other.origin_), [dir](other.direction_) {}241 operator Urho3D::Ray() const { return Urho3D::Ray([pos], [dir]); }242 #endif243 };244 245 246 247 [Ray] [operator *](const [float3x3] &transform, const [Ray] &ray);248 249 250 [Ray] [operator *](const [float3x4] &transform, const [Ray] &ray);251 252 253 [Ray] [operator *](const [float4x4] &transform, const [Ray] &ray);254 [Ray] [operator *](const [Quat] &transform, const [Ray] &ray);255 256 #ifdef MATH_QT_INTEROP257 Q_DECLARE_METATYPE([Ray])258 Q_DECLARE_METATYPE([Ray]*)259 #endif260 261 #ifdef MATH_ENABLE_STL_SUPPORT262 std::ostream &[operator <<](std::ostream &o, const [Ray] &ray);263 #endif264 265 [MATH_END_NAMESPACE] Go back to previous page