TDME2 1.9.121
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LineSegment.h
Go to the documentation of this file.
1#pragma once
2
3#include <tdme/tdme.h>
6
10
11/**
12 * Line segment helper functions
13 * @author Andreas Drewke
14 * @version $Id$
15 */
17{
18public:
19
20 /**
21 * Compute closest point on line segment
22 * @param p1 p1 line 1 point 1
23 * @param q1 q1 line 1 point 2
24 * @param p p point
25 * @param c c closest point
26 * @return if collides or not
27 */
28 static void computeClosestPointOnLineSegment(const Vector3& p1, const Vector3& q1, const Vector3& p, Vector3& c);
29
30 /**
31 * Does line segments collide
32 * @param p1 p1 line 1 point 1
33 * @param q1 q1 line 1 point 2
34 * @param p2 p2 line 2 point 1
35 * @param q2 q2 line 2 point 2
36 * @param p p intersection point
37 * @return if collides or not
38 */
39 static bool doesLineSegmentsCollide(const Vector3& p1, const Vector3& q1, const Vector3& p2, const Vector3& q2, Vector3& p);
40
41 /**
42 * Computes closest points c1, c2 on line segment p1->q1, p2->q2
43 * based on an algorithm from "Real-Time Collision Detection" / Ericson"
44 * Credit:
45 * "From Real-Time Collision Detection by Christer Ericson
46 * published by Morgan Kaufman Publishers, (c) 2005 Elsevier Inc"
47 * @param p1 point p1 on line segment 1
48 * @param q1 point q1 on line segment 1
49 * @param p2 point p2 on line segment 2
50 * @param q2 point q2 on line segment 2
51 * @param c1 closest point on line segment 1 c1
52 * @param c2 closest point on line segment 2 c2
53 */
54 static void computeClosestPointsOnLineSegments(const Vector3& p1, const Vector3& q1, const Vector3& p2, const Vector3& q2, Vector3& c1, Vector3& c2);
55
56 /**
57 * Check if segment collides with bounding box
58 * based on an algorithm from "Real-Time Collision Detection" / Ericson
59 * Credit:
60 * "From Real-Time Collision Detection by Christer Ericson
61 * published by Morgan Kaufman Publishers, (c) 2005 Elsevier Inc"
62 * @param boundingBox bounding box
63 * @param p point p on line segment
64 * @param q point q on line segment
65 * @param contactMin contact point min
66 * @param contactMax contact point max
67 * @return true if collides or false if not
68 */
69 static bool doesBoundingBoxCollideWithLineSegment(BoundingBox* boundingBox, const Vector3& p, const Vector3& q, Vector3& contactMin, Vector3& contactMax);
70
71 /**
72 * Check if segment collides with oriented bounding box
73 * based on an algorithm from "Real-Time Collision Detection" / Ericson
74 * Credit:
75 * "From Real-Time Collision Detection by Christer Ericson
76 * published by Morgan Kaufman Publishers, (c) 2005 Elsevier Inc"
77 * @param orientedBoundingBox oriented bounding box
78 * @param p point p on line segment
79 * @param q point q on line segment
80 * @param contactMin contact point min
81 * @param contactMax contact point max
82 * @return true if collides or false if not
83 */
84 static bool doesOrientedBoundingBoxCollideWithLineSegment(OrientedBoundingBox* orientedBoundingBox, const Vector3& p, const Vector3& q, Vector3& contactMin, Vector3& contactMax);
85
86 /**
87 * Does line segment collides with triangle
88 * @param p1 p1 triangle point 1
89 * @param p2 p2 triangle point 2
90 * @param p3 p3 triangle point 3
91 * @param r1 r1 line segment point 1
92 * @param r2 r2 line segment point 2
93 * @param contact point of intersection
94 * @return line segment collides with triangle
95 */
96 static bool doesLineSegmentCollideWithTriangle(const Vector3& p1, const Vector3& p2, const Vector3& p3, const Vector3& r1, const Vector3& r2, Vector3& contact);
97
98 /**
99 * Does line segment collides with triangle
100 * @param n n plane normal
101 * @param d d plane distance from origin
102 * @param p1 p1 line segment point 1
103 * @param p2 p2 line segment point 2
104 * @param contact point of intersection
105 * @return line segment collides with plane
106 */
107 static bool doesLineSegmentCollideWithPlane(const Vector3& n, float d, const Vector3& p1, const Vector3& p2, Vector3& contact);
108
109};
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:25
Line segment helper functions.
Definition: LineSegment.h:17
static bool doesLineSegmentCollideWithPlane(const Vector3 &n, float d, const Vector3 &p1, const Vector3 &p2, Vector3 &contact)
Does line segment collides with triangle.
static void computeClosestPointsOnLineSegments(const Vector3 &p1, const Vector3 &q1, const Vector3 &p2, const Vector3 &q2, Vector3 &c1, Vector3 &c2)
Computes closest points c1, c2 on line segment p1->q1, p2->q2 based on an algorithm from "Real-Time C...
Definition: LineSegment.cpp:40
static bool doesBoundingBoxCollideWithLineSegment(BoundingBox *boundingBox, const Vector3 &p, const Vector3 &q, Vector3 &contactMin, Vector3 &contactMax)
Check if segment collides with bounding box based on an algorithm from "Real-Time Collision Detection...
Definition: LineSegment.cpp:93
static bool doesOrientedBoundingBoxCollideWithLineSegment(OrientedBoundingBox *orientedBoundingBox, const Vector3 &p, const Vector3 &q, Vector3 &contactMin, Vector3 &contactMax)
Check if segment collides with oriented bounding box based on an algorithm from "Real-Time Collision ...
static bool doesLineSegmentCollideWithTriangle(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &r1, const Vector3 &r2, Vector3 &contact)
Does line segment collides with triangle.
static void computeClosestPointOnLineSegment(const Vector3 &p1, const Vector3 &q1, const Vector3 &p, Vector3 &c)
Compute closest point on line segment.
Definition: LineSegment.cpp:15
static bool doesLineSegmentsCollide(const Vector3 &p1, const Vector3 &q1, const Vector3 &p2, const Vector3 &q2, Vector3 &p)
Does line segments collide.
Definition: LineSegment.cpp:27
Oriented bounding box physics primitive.
3D vector 3 class
Definition: Vector3.h:22