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 24 #include <vector>25 26 27 [MATH_BEGIN_NAMESPACE]28 29 30 31 32 33 34 35 36 class [Polygon]37 {38 public:39 40 41 42 [Polygon]() {}43 44 45 [VecArray] [p];46 47 [FORCE_INLINE] static int [NumFaces]() { return 1; }48 49 50 51 52 int [NumEdges]() const;53 54 55 56 57 int [NumVertices]() const;58 59 60 61 vec *[VertexArrayPtr]() { return ![p].empty() ? (vec*)&[p][0] : 0; }62 const vec *[VertexArrayPtr]() const { return ![p].empty() ? (vec*)&[p][0] : 0; }63 64 65 vec [AnyPointFast]() const { return ![p].empty() ? [p][0] : [vec::nan]; }66 67 68 69 70 vec [Vertex](int vertexIndex) const;71 72 73 74 75 76 [LineSegment] [Edge](int edgeIndex) const;77 78 79 80 81 82 83 84 [LineSegment] [Edge2D](int edgeIndex) const;85 86 87 88 89 90 91 92 vec [EdgeNormal](int edgeIndex) const;93 94 95 96 97 98 [Plane] [EdgePlane](int edgeIndex) const;99 100 101 102 103 104 105 106 107 108 vec [ExtremePoint](const vec &direction) const;109 vec [ExtremePoint](const vec &direction, float &projectionDistance) const;110 111 112 113 114 115 116 117 118 void [ProjectToAxis](const vec &direction, float &outMin, float &outMax) const;119 120 121 122 123 124 125 126 127 128 129 130 bool [DiagonalExists](int i, int j) const;131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 [LineSegment] [Diagonal](int i, int j) const;146 147 148 149 150 151 152 153 154 bool [IsConvex]() const;155 156 157 158 159 160 161 162 bool [IsPlanar](float epsilonSq = 1[e]-4f) const;163 164 165 166 167 168 169 170 bool [IsSimple]() const;171 172 173 174 175 176 bool [IsNull]() const;177 178 179 180 181 182 bool [IsFinite]() const;183 184 185 186 187 188 bool [IsDegenerate](float [epsilon] = 1[e]-4f) const;189 190 191 192 193 vec [BasisU]() const;194 195 196 197 198 vec [BasisV]() const;199 200 201 202 203 204 205 206 [float2] [MapTo2D](int i) const;207 208 209 210 211 [float2] [MapTo2D](const vec &point) const;212 213 214 215 vec [MapFrom2D](const [float2] &point) const;216 217 218 219 220 221 vec [NormalCCW]() const;222 223 224 225 226 227 228 vec [NormalCW]() const;229 230 231 232 233 234 [Plane] [PlaneCCW]() const;235 236 237 238 239 [Plane] [PlaneCW]() const;240 241 242 243 244 void [Translate](const vec &offset);245 246 247 248 249 void [Transform](const [float3x3] &transform);250 void [Transform](const [float3x4] &transform);251 void [Transform](const [float4x4] &transform);252 void [Transform](const [Quat] &transform);253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 bool [Contains](const vec &point, float polygonThicknessSq = 1[e]-5f) const;278 bool [Contains](const [LineSegment] &lineSegment, float polygonThickness = 1[e]-3f) const;279 bool [Contains](const [Triangle] &triangle, float polygonThickness = 1[e]-3f) const;280 bool [Contains](const [Polygon] &polygon, float polygonThickness = 1[e]-3f) const;281 282 283 284 285 286 287 288 bool [Contains2D](const [LineSegment] &localSpaceLineSegment) const;289 290 291 292 293 294 295 296 297 298 299 300 bool [Intersects](const [Line] &line) const;301 bool [Intersects](const [Ray] &ray) const;302 bool [Intersects](const [LineSegment] &lineSegment) const;303 bool [Intersects](const [Plane] &plane) const;304 bool [Intersects](const [AABB] &aabb) const;305 bool [Intersects](const [OBB] &obb) const;306 bool [Intersects](const [Triangle] &triangle, float polygonThickness = 1[e]-3f) const;307 bool [Intersects](const [Polygon] &polygon, float polygonThickness = 1[e]-3f) const;308 bool [Intersects](const [Frustum] &frustum) const;309 bool [Intersects](const [Polyhedron] &polyhedron) const;310 bool [Intersects](const [Sphere] &sphere) const;311 bool [Intersects](const [Capsule] &capsule) const;312 313 314 315 316 317 318 bool [ConvexIntersects](const [AABB] &aabb) const;319 bool [ConvexIntersects](const [OBB] &obb) const;320 bool [ConvexIntersects](const [Frustum] &frustum) const;321 322 323 324 325 326 327 328 329 330 vec [ClosestPoint](const [LineSegment] &lineSegment, vec *lineSegmentPt) const;331 vec [ClosestPoint](const [LineSegment] &lineSegment) const;332 vec [ClosestPoint](const vec &point) const;333 334 335 336 float [Distance](const vec &point) const;337 338 339 340 float [Area]() const;341 342 343 344 float [Perimeter]() const;345 346 347 348 vec [Centroid]() const;349 350 351 vec [CenterPoint]() const { return [Centroid](); }352 353 354 355 356 357 358 359 vec [PointOnEdge](float normalizedDistance) const;360 361 362 363 364 vec [RandomPointOnEdge]([LCG] &rng) const;365 366 vec [FastRandomPointInside]([LCG] &rng) const;367 368 369 370 371 372 373 [Polyhedron] [ToPolyhedron]() const;374 375 376 377 378 379 380 [TriangleArray] [Triangulate]() const;381 382 383 384 385 [AABB] [MinimalEnclosingAABB]() const;386 387 std::string [ToString]() const;388 389 std::string [SerializeToString]() const;390 391 static [Polygon] [FromString](const char *str, const char **outEndStr = 0);392 static [Polygon] [FromString](const std::string &str) { return [FromString](str.c_str()); }393 394 bool [Equals](const [Polygon] &other) const;395 bool [BitEquals](const [Polygon] &other) const;396 397 398 399 400 401 402 403 404 405 406 407 408 409 };410 411 [Polygon] [operator *](const [float3x3] &transform, const [Polygon] &polygon);412 [Polygon] [operator *](const [float3x4] &transform, const [Polygon] &polygon);413 [Polygon] [operator *](const [float4x4] &transform, const [Polygon] &polygon);414 [Polygon] [operator *](const [Quat] &transform, const [Polygon] &polygon);415 416 #ifdef MATH_QT_INTEROP417 Q_DECLARE_METATYPE([Polygon])418 Q_DECLARE_METATYPE([Polygon]*)419 #endif420 421 422 423 424 425 426 [MATH_END_NAMESPACE] Go back to previous page