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 [MATH_BEGIN_NAMESPACE]24 25 26 class [Line]27 {28 public:29 30 vec [pos];31 32 33 34 35 vec [dir];36 37 38 39 40 41 [Line]() {}42 43 44 45 46 47 48 [Line](const vec &[pos], const vec &[dir]);49 50 51 52 53 54 55 explicit [Line](const [Ray] &ray);56 57 58 59 60 explicit [Line](const [LineSegment] &lineSegment);61 62 bool [IsFinite]() const;63 64 65 66 67 68 69 70 71 vec [GetPoint](float distance) const;72 73 74 75 76 void [Translate](const vec &offset);77 78 79 80 void [Transform](const [float3x3] &transform);81 void [Transform](const [float3x4] &transform);82 void [Transform](const [float4x4] &transform);83 void [Transform](const [Quat] &transform);84 85 86 87 88 89 90 91 bool [Contains](const vec &point, float distanceThreshold = 1[e]-3f) const;92 bool [Contains](const [Ray] &ray, float distanceThreshold = 1[e]-3f) const;93 bool [Contains](const [LineSegment] &lineSegment, float distanceThreshold = 1[e]-3f) const;94 95 96 97 98 99 bool [Equals](const [Line] &line, float [epsilon] = 1[e]-3f) const;100 101 102 103 bool [BitEquals](const [Line] &other) const { return [pos].[BitEquals](other.[pos]) && [dir].[BitEquals](other.[dir]); }104 105 106 107 108 109 110 111 float [Distance](const vec &point) const { float [d]; return [Distance](point, d); }112 float [Distance](const vec &point, float &[d]) const;113 114 115 float [Distance](const [Ray] &other) const { float [d], d2; return [Distance](other, d, d2); }116 float [Distance](const [Ray] &other, float &[d]) const { float d2; return [Distance](other, d, d2); }117 float [Distance](const [Ray] &other, float &[d], float &d2) const;118 float [Distance](const [Line] &other) const { float [d], d2; return [Distance](other, d, d2); }119 float [Distance](const [Line] &other, float &[d]) const { float d2; return [Distance](other, d, d2); }120 float [Distance](const [Line] &other, float &[d], float &d2) const;121 float [Distance](const [LineSegment] &other) const { float [d], d2; return [Distance](other, d, d2); }122 float [Distance](const [LineSegment] &other, float &[d]) const { float d2; return [Distance](other, d, d2); }123 float [Distance](const [LineSegment] &other, float &[d], float &d2) const;124 float [Distance](const [Sphere] &other) const;125 float [Distance](const [Capsule] &other) const;126 127 128 129 130 131 132 133 vec [ClosestPoint](const vec &targetPoint) const { float [d]; return [ClosestPoint](targetPoint, d); }134 vec [ClosestPoint](const vec &targetPoint, float &[d]) const;135 136 137 vec [ClosestPoint](const [Ray] &other) const { float [d], d2; return [ClosestPoint](other, d, d2); }138 vec [ClosestPoint](const [Ray] &other, float &[d]) const { float d2; return [ClosestPoint](other, d, d2); }139 vec [ClosestPoint](const [Ray] &other, float &[d], float &d2) const;140 vec [ClosestPoint](const [Line] &other) const { float [d], d2; return [ClosestPoint](other, d, d2); }141 vec [ClosestPoint](const [Line] &other, float &[d]) const { float d2; return [ClosestPoint](other, d, d2); }142 vec [ClosestPoint](const [Line] &other, float &[d], float &d2) const;143 vec [ClosestPoint](const [LineSegment] &other) const { float [d], d2; return [ClosestPoint](other, d, d2); }144 vec [ClosestPoint](const [LineSegment] &other, float &[d]) const { float d2; return [ClosestPoint](other, d, d2); }145 vec [ClosestPoint](const [LineSegment] &other, float &[d], float &d2) const;146 147 148 149 vec [ClosestPoint](const [Triangle] &triangle) const { float [d]; return [ClosestPoint](triangle, d); }150 vec [ClosestPoint](const [Triangle] &triangle, float &[d]) const;151 vec [ClosestPoint](const [Triangle] &triangle, float &[d], [float2] &outBarycentricUV) const;152 153 154 155 156 157 158 159 160 161 162 163 bool [Intersects](const [Triangle] &triangle, float *[d], vec *intersectionPoint) const;164 bool [Intersects](const [Plane] &plane, float *[d]) const;165 166 167 bool [Intersects](const [Sphere] &s, vec *intersectionPoint = 0, vec *intersectionNormal = 0, float *[d] = 0) const;168 169 170 171 172 bool [Intersects](const [AABB] &aabb, float &dNear, float &dFar) const;173 bool [Intersects](const [AABB] &aabb) const;174 bool [Intersects](const [OBB] &obb, float &dNear, float &dFar) const;175 bool [Intersects](const [OBB] &obb) const;176 bool [Intersects](const [Capsule] &capsule) const;177 bool [Intersects](const [Polygon] &polygon) const;178 bool [Intersects](const [Frustum] &frustum) const;179 bool [Intersects](const [Polyhedron] &polyhedron) const;180 181 182 bool [IntersectsDisc](const [Circle] &disc) const;183 184 185 186 187 188 189 [Ray] [ToRay]() const;190 191 192 193 194 195 [LineSegment] [ToLineSegment](float [d]) const;196 197 198 199 200 201 202 203 [LineSegment] [ToLineSegment](float dStart, float dEnd) const;204 205 206 207 208 209 210 211 212 void [ProjectToAxis](const vec &direction, float &outMin, float &outMax) const;213 214 215 216 217 static bool [AreCollinear](const vec &p1, const vec &p2, const vec &p3, float [epsilon] = 1[e]-3f);218 219 static void [ClosestPointLineLine](const vec &start0, const vec &dir0, const vec &start1, const vec &dir1, float &[d], float &d2);220 221 #ifdef MATH_ENABLE_STL_SUPPORT222 223 224 std::string [ToString]() const;225 std::string [SerializeToString]() const;226 227 228 std::string [SerializeToCodeString]() const;229 #endif230 231 static [Line] [FromString](const char *str, const char **outEndStr = 0);232 #ifdef MATH_ENABLE_STL_SUPPORT233 static [Line] [FromString](const std::string &str) { return [FromString](str.c_str()); }234 #endif235 236 #ifdef MATH_QT_INTEROP237 operator QString() const { return toString(); }238 QString toString() const { return QString::fromStdString([ToString]()); }239 #endif240 };241 242 [Line] [operator *](const [float3x3] &transform, const [Line] &line);243 [Line] [operator *](const [float3x4] &transform, const [Line] &line);244 [Line] [operator *](const [float4x4] &transform, const [Line] &line);245 [Line] [operator *](const [Quat] &transform, const [Line] &line);246 247 #ifdef MATH_QT_INTEROP248 Q_DECLARE_METATYPE([Line])249 Q_DECLARE_METATYPE([Line]*)250 #endif251 252 #ifdef MATH_ENABLE_STL_SUPPORT253 std::ostream &[operator <<](std::ostream &o, const [Line] &line);254 #endif255 256 [MATH_END_NAMESPACE] Go back to previous page