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 [LineSegment]27 {28 public:29 30 vec [a];31 32 vec [b];33 34 35 36 37 38 [LineSegment]() {}39 40 41 42 [LineSegment](const vec &[a], const vec &[b]);43 44 45 46 47 48 49 50 51 explicit [LineSegment](const [Ray] &ray, float [d]);52 explicit [LineSegment](const [Line] &line, float [d]);53 54 55 56 57 58 59 60 61 62 63 vec [GetPoint](float [d]) const;64 65 66 67 68 vec [CenterPoint]() const;69 70 71 72 73 74 75 76 void [Reverse]();77 78 79 80 81 vec [Dir]() const;82 83 84 inline vec [AnyPointFast]() const { return [a]; }85 86 87 88 89 90 91 92 93 94 vec [ExtremePoint](const vec &direction) const;95 vec [ExtremePoint](const vec &direction, float &projectionDistance) const;96 97 98 99 100 void [Translate](const vec &offset);101 102 103 104 105 void [Transform](const [float3x3] &transform);106 void [Transform](const [float3x4] &transform);107 void [Transform](const [float4x4] &transform);108 void [Transform](const [Quat] &transform);109 110 111 112 113 float [Length]() const;114 115 116 117 118 119 float [LengthSq]() const;120 121 122 123 124 125 bool [IsFinite]() const;126 127 128 129 130 bool [Equals](const [LineSegment] &rhs, float distanceThreshold = 1[e]-3f) const;131 132 133 134 bool [BitEquals](const [LineSegment] &other) const { return [a].[BitEquals](other.[a]) && [b].[BitEquals](other.[b]); }135 136 137 138 139 140 141 142 bool [Contains](const vec &point, float distanceThreshold = 1[e]-3f) const;143 bool [Contains](const [LineSegment] &lineSegment, float distanceThreshold = 1[e]-3f) const;144 145 146 147 148 149 150 151 vec [ClosestPoint](const vec &point) const { float [d]; return [ClosestPoint](point, d); }152 vec [ClosestPoint](const vec &point, float &[d]) const;153 154 155 156 vec [ClosestPoint](const [Ray] &other) const { float [d], d2; return [ClosestPoint](other, d, d2); }157 vec [ClosestPoint](const [Ray] &other, float &[d]) const { float d2; return [ClosestPoint](other, d, d2); }158 vec [ClosestPoint](const [Ray] &other, float &[d], float &d2) const;159 vec [ClosestPoint](const [Line] &other) const { float [d], d2; return [ClosestPoint](other, d, d2); }160 vec [ClosestPoint](const [Line] &other, float &[d]) const { float d2; return [ClosestPoint](other, d, d2); }161 vec [ClosestPoint](const [Line] &other, float &[d], float &d2) const;162 vec [ClosestPoint](const [LineSegment] &other) const { float [d], d2; return [ClosestPoint](other, d, d2); }163 vec [ClosestPoint](const [LineSegment] &other, float &[d]) const { float d2; return [ClosestPoint](other, d, d2); }164 vec [ClosestPoint](const [LineSegment] &other, float &[d], float &d2) const;165 166 167 168 169 170 171 172 float [Distance](const vec &point) const { float [d]; return [Distance](point, d); }173 float [Distance](const vec &point, float &[d]) const;174 175 176 177 float [Distance](const [Ray] &other) const { float [d], d2; return [Distance](other, d, d2); }178 float [Distance](const [Ray] &other, float &[d]) const { float d2; return [Distance](other, d, d2); }179 float [Distance](const [Ray] &other, float &[d], float &d2) const;180 float [Distance](const [Line] &other) const { float [d], d2; return [Distance](other, d, d2); }181 float [Distance](const [Line] &other, float &[d]) const { float d2; return [Distance](other, d, d2); }182 float [Distance](const [Line] &other, float &[d], float &d2) const;183 float [Distance](const [LineSegment] &other) const { float [d], d2; return [Distance](other, d, d2); }184 float [Distance](const [LineSegment] &other, float &[d]) const { float d2; return [Distance](other, d, d2); }185 float [Distance](const [LineSegment] &other, float &[d], float &d2) const;186 float [Distance](const [Plane] &other) const;187 float [Distance](const [Sphere] &other) const;188 float [Distance](const [Capsule] &other) const;189 190 float [DistanceSq](const vec &point) const;191 float [DistanceSq](const [LineSegment] &other) const;192 193 194 195 196 197 bool [Intersects](const [Plane] &plane) const;198 199 200 201 bool [Intersects](const [Plane] &plane, float *[d]) const;202 203 bool [Intersects](const [Triangle] &triangle, float *[d], vec *intersectionPoint) const;204 205 206 bool [Intersects](const [Sphere] &s, vec *intersectionPoint = 0, vec *intersectionNormal = 0, float *[d] = 0) const;207 208 209 210 211 bool [Intersects](const [AABB] &aabb, float &dNear, float &dFar) const;212 bool [Intersects](const [AABB] &aabb) const;213 bool [Intersects](const [OBB] &obb, float &dNear, float &dFar) const;214 bool [Intersects](const [OBB] &obb) const;215 bool [Intersects](const [Capsule] &capsule) const;216 bool [Intersects](const [Polygon] &polygon) const;217 bool [Intersects](const [Frustum] &frustum) const;218 bool [Intersects](const [Polyhedron] &polyhedron) const;219 220 221 bool [Intersects](const [LineSegment] &lineSegment, float [epsilon] = 1[e]-3f) const;222 223 224 bool [IntersectsDisc](const [Circle] &disc) const;225 226 227 228 229 [Ray] [ToRay]() const;230 231 232 233 [Line] [ToLine]() const;234 235 236 237 238 239 240 241 242 void [ProjectToAxis](const vec &direction, float &outMin, float &outMax) const;243 244 #ifdef MATH_ENABLE_STL_SUPPORT245 246 std::string [ToString]() const;247 std::string [SerializeToString]() const;248 249 250 std::string [SerializeToCodeString]() const;251 #endif252 253 static [LineSegment] [FromString](const char *str, const char **outEndStr = 0);254 #ifdef MATH_ENABLE_STL_SUPPORT255 static [LineSegment] [FromString](const std::string &str) { return [FromString](str.c_str()); }256 #endif257 258 #ifdef MATH_QT_INTEROP259 operator QString() const { return toString(); }260 QString toString() const { return QString::fromStdString([ToString]()); }261 #endif262 263 #ifdef MATH_GRAPHICSENGINE_INTEROP264 void ToLineList(VertexBuffer &vb) const;265 #endif266 };267 268 struct [LineSegment_storage]269 {270 [vec_storage] [a],[b];271 [LineSegment_storage](){}272 [LineSegment_storage](const [LineSegment] &rhs)273 {274 *reinterpret_cast<[LineSegment]*>(this) = rhs;275 }276 operator [LineSegment]() const { return *reinterpret_cast<const [LineSegment]*>(this); }277 };278 279 [LineSegment] [operator *](const [float3x3] &transform, const [LineSegment] &line);280 [LineSegment] [operator *](const [float3x4] &transform, const [LineSegment] &line);281 [LineSegment] [operator *](const [float4x4] &transform, const [LineSegment] &line);282 [LineSegment] [operator *](const [Quat] &transform, const [LineSegment] &line);283 284 #ifdef MATH_QT_INTEROP285 Q_DECLARE_METATYPE([LineSegment])286 Q_DECLARE_METATYPE([LineSegment]*)287 #endif288 289 #ifdef MATH_ENABLE_STL_SUPPORT290 std::ostream &[operator <<](std::ostream &o, const [LineSegment] &lineSegment);291 #endif292 293 [MATH_END_NAMESPACE] Go back to previous page