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 <OgrePlane.h>25 #endif26 #ifdef MATH_URHO3D_INTEROP27 #include <Urho3D/Math/Plane.h>28 #endif29 30 [MATH_BEGIN_NAMESPACE]31 32 33 34 class [Plane]35 {36 public:37 38 39 40 vec [normal];41 42 43 44 45 46 47 48 49 float [d];50 51 52 53 54 55 [Plane]() {}56 57 58 59 60 [Plane](const vec &[normal], float [d]);61 62 63 64 65 66 [Plane](const vec &v1, const vec &v2, const vec &v3);67 68 69 70 [Plane](const vec &point, const vec &[normal]);71 72 73 74 75 76 [Plane](const [Ray] &line, const vec &[normal]);77 [Plane](const [Line] &line, const vec &[normal]);78 [Plane](const [LineSegment] &line, const vec &[normal]);79 80 bool [IsDegenerate]() const;81 82 83 84 85 86 void [Set](const vec &v1, const vec &v2, const vec &v3);87 88 89 void [Set](const vec &point, const vec &[normal]);90 91 92 93 94 void [ReverseNormal]();95 96 97 98 99 100 vec [PointOnPlane]() const;101 102 103 104 105 106 vec [Point](float u, float v) const;107 108 109 110 111 112 113 114 115 vec [Point](float u, float v, const vec &referenceOrigin) const;116 117 118 119 120 void [Translate](const vec &offset);121 122 123 124 125 void [Transform](const [float3x3] &transform);126 void [Transform](const [float3x4] &transform);127 void [Transform](const [float4x4] &transform);128 void [Transform](const [Quat] &transform);129 130 131 132 133 134 bool [IsInPositiveDirection](const vec &directionVector) const;135 136 137 138 139 140 141 142 bool [IsOnPositiveSide](const vec &point) const;143 144 145 146 147 148 int [ExamineSide](const [Triangle] &triangle) const;149 150 151 152 153 154 bool [AreOnSameSide](const vec &p1, const vec &p2) const;155 156 157 158 159 160 161 162 float [Distance](const [float3] &point) const;163 float [Distance](const [float4] &point) const;164 float [Distance](const [LineSegment] &lineSegment) const;165 float [Distance](const [Sphere] &sphere) const;166 float [Distance](const [Capsule] &capsule) const;167 168 169 170 171 172 float [SignedDistance](const vec &point) const;173 174 float [SignedDistance](const [AABB] &aabb) const;175 float [SignedDistance](const [OBB] &obb) const;176 float [SignedDistance](const [Capsule] &capsule) const;177 178 float [SignedDistance](const [Frustum] &frustum) const;179 float [SignedDistance](const [Line] &line) const;180 float [SignedDistance](const [LineSegment] &lineSegment) const;181 float [SignedDistance](const [Ray] &ray) const;182 183 float [SignedDistance](const [Polygon] &polygon) const;184 float [SignedDistance](const [Polyhedron] &polyhedron) const;185 float [SignedDistance](const [Sphere] &sphere) const;186 float [SignedDistance](const [Triangle] &triangle) const;187 188 189 190 [float3x4] [OrthoProjection]() const;191 192 193 194 195 vec [Project](const vec &point) const;196 [LineSegment] [Project](const [LineSegment] &lineSegment) const;197 198 199 200 201 [Line] [Project](const [Line] &line, bool *nonDegenerate) const;202 [Ray] [Project](const [Ray] &ray, bool *nonDegenerate) const;203 204 [Triangle] [Project](const [Triangle] &triangle) const;205 [Polygon] [Project](const [Polygon] &polygon) const;206 207 208 209 210 211 vec [ProjectToNegativeHalf](const vec &point) const;212 213 214 215 vec [ProjectToPositiveHalf](const vec &point) const;216 217 #if 0218 219 220 221 222 [float3x4] ObliqueProjection(const [float3] &obliqueProjectionDir) const;223 224 225 226 227 228 229 [float3] ObliqueProject(const [float3] &point, const [float3] &obliqueProjectionDir) const;230 #endif231 232 233 234 235 [float3x4] [MirrorMatrix]() const;236 237 238 239 240 241 242 vec [Mirror](const vec &point) const;243 244 245 246 247 248 249 250 251 252 vec [Refract](const vec &vec, float negativeSideRefractionIndex, float positiveSideRefractionIndex) const;253 254 255 256 257 258 vec [ClosestPoint](const vec &point) const { return [Project](point); }259 vec [ClosestPoint](const [Ray] &ray) const;260 vec [ClosestPoint](const [LineSegment] &lineSegment) const;261 262 263 264 265 266 bool [Contains](const vec &point, float [epsilon] = 1[e]-3f) const;267 bool [Contains](const [Line] &line, float [epsilon] = 1[e]-3f) const;268 bool [Contains](const [Ray] &ray, float [epsilon] = 1[e]-3f) const;269 bool [Contains](const [LineSegment] &lineSegment, float [epsilon] = 1[e]-3f) const;270 bool [Contains](const [Triangle] &triangle, float [epsilon] = 1[e]-3f) const;271 bool [Contains](const [Circle] &circle, float [epsilon] = 1[e]-3f) const;272 bool [Contains](const [Polygon] &polygon, float [epsilon] = 1[e]-3f) const;273 274 275 276 277 278 bool [SetEquals](const [Plane] &plane, float [epsilon] = 1[e]-3f) const;279 280 281 282 bool [Equals](const [Plane] &other, float [epsilon] = 1[e]-3f) const;283 284 285 286 bool [BitEquals](const [Plane] &other) const { return [normal].[BitEquals](other.[normal]) && [ReinterpretAsU32]([d]) == [ReinterpretAsU32](other.[d]); }287 288 289 290 bool [IsParallel](const [Plane] &plane, float [epsilon] = 1[e]-3f) const;291 292 293 294 float [DihedralAngle](const [Plane] &plane) const;295 296 297 298 299 300 301 302 303 304 305 bool [Intersects](const [Plane] &plane, const [Plane] &plane2, [Line] *outLine = 0, vec *outPoint = 0) const;306 307 308 309 310 311 bool [Intersects](const [Plane] &plane, [Line] *outLine = 0) const;312 313 314 315 bool [Intersects](const [Ray] &ray, float *[d] = 0) const;316 bool [Intersects](const [Line] &line, float *[d] = 0) const;317 bool [Intersects](const [LineSegment] &lineSegment, float *[d] = 0) const;318 bool [Intersects](const [Sphere] &sphere) const;319 bool [Intersects](const [AABB] &aabb) const;320 bool [Intersects](const [OBB] &obb) const;321 bool [Intersects](const [Polygon] &polygon) const;322 bool [Intersects](const [Polyhedron] &polyhedron) const;323 324 bool [Intersects](const [Triangle] &triangle) const;325 bool [Intersects](const [Frustum] &frustum) const;326 bool [Intersects](const [Capsule] &capsule) const;327 328 329 330 331 int [Intersects](const [Circle] &circle, vec *pt1, vec *pt2) const;332 int [Intersects](const [Circle] &circle) const;333 334 335 336 337 338 339 340 341 bool [Clip]([LineSegment] &line) const;342 bool [Clip](vec &a, vec &b) const;343 344 345 346 347 348 349 350 351 int [Clip](const [Line] &line, [Ray] &outRay) const;352 353 354 355 356 357 358 359 int [Clip](const [Triangle] &triangle, [Triangle] &t1, [Triangle] &t2) const;360 361 362 363 364 365 bool [PassesThroughOrigin](float [epsilon] = 1[e]-3f) const;366 367 368 369 370 371 372 373 [Circle] [GenerateCircle](const vec &circleCenter, float radius) const;374 375 376 377 378 379 380 381 382 383 384 385 386 387 static bool [IntersectLinePlane](const vec &planeNormal, float planeD, const vec &linePos, const vec &lineDir, float &t);388 389 #ifdef MATH_ENABLE_STL_SUPPORT390 391 std::string [ToString]() const;392 std::string [SerializeToString]() const;393 394 395 std::string [SerializeToCodeString]() const;396 #endif397 398 static [Plane] [FromString](const char *str, const char **outEndStr = 0);399 #ifdef MATH_ENABLE_STL_SUPPORT400 static [Plane] [FromString](const std::string &str) { return [FromString](str.c_str()); }401 #endif402 403 #ifdef MATH_OGRE_INTEROP404 [Plane](const Ogre::Plane &other):[normal](other.[normal]), [d](other.[d]) {}405 operator Ogre::Plane() const { return Ogre::Plane([normal], [d]); }406 #endif407 #ifdef MATH_QT_INTEROP408 operator QString() const { return toString(); }409 QString toString() const { return QString::fromStdString([ToString]()); }410 #endif411 #ifdef MATH_GRAPHICSENGINE_INTEROP412 void Triangulate(VertexBuffer &vb, float uWidth, float vHeight, const vec ¢erPoint, int numFacesU, int numFacesV, bool ccwIsFrontFacing) const;413 void ToLineList(VertexBuffer &vb, float uWidth, float vHeight, const vec ¢erPoint, int numLinesU, int numLinesV) const;414 #endif415 #ifdef MATH_URHO3D_INTEROP416 [Plane](const Urho3D::Plane &other) : [normal](other.normal_), [d](other.d_) {}417 operator Urho3D::Plane() const { return Urho3D::Plane([float4]([normal], [d])); }418 #endif419 };420 421 [Plane] [operator *](const [float3x3] &transform, const [Plane] &plane);422 [Plane] [operator *](const [float3x4] &transform, const [Plane] &plane);423 [Plane] [operator *](const [float4x4] &transform, const [Plane] &plane);424 [Plane] [operator *](const [Quat] &transform, const [Plane] &plane);425 426 #ifdef MATH_QT_INTEROP427 Q_DECLARE_METATYPE([Plane])428 Q_DECLARE_METATYPE([Plane]*)429 #endif430 431 #ifdef MATH_ENABLE_STL_SUPPORT432 std::ostream &[operator <<](std::ostream &o, const [Plane] &plane);433 #endif434 435 [MATH_END_NAMESPACE] Go back to previous page