#include <Plane.h>
Collaboration diagram for pge::Plane:
Public Member Functions | |
Plane (void) | |
Standard constructor. | |
Plane (Vector3f a, Vector3f b, Vector3f c) | |
Create a plane out of the three points. | |
Plane (Vector3f start, Vector3f u, Vector3f v, int i) | |
Create a plane out of a startpoint and two vectors. | |
Plane (Vector3f normal, float d) | |
Create a plane out of the normal and the d component. | |
Plane (Triangle *triangle) | |
Create a plane from a triangle. | |
~Plane (void) | |
Destructor. | |
float | a (void) |
Return A component. | |
float | b (void) |
Return B component. | |
float | c (void) |
Return C component. | |
float | d (void) |
Return D component. | |
bool | isPointOnPlane (Vector3f point) |
Returns 1 if the point is on the plane. | |
float | getDistanceToPoint (Vector3f point) |
Returns the distance to the nearest point on the plane. | |
Vector3f | getFootPoint (Vector3f point) |
Returns the nearest point on the plane from the given point. | |
Vector3f | getIntersectionPoint (Vector3f lineStart, Vector3f lineEnd) |
Returns the intersection point of a line and the plane. | |
bool | isLineIntersecting (Vector3f lineStart, Vector3f lineEnd) |
Checks if a line intersects this plane. | |
std::string | toString (void) |
Prints the plane's data out. | |
Data Fields | |
Vector3f | m_normal |
float | m_d |
|
Standard constructor.
Definition at line 22 of file Plane.cpp. References m_d.
00022 { 00023 m_d = 0.0f; 00024 } |
|
Create a plane out of the three points.
Definition at line 32 of file Plane.cpp. References pge::Vector3f::crossProduct(), pge::Vector3f::dotProduct(), m_d, m_normal, pge::Vector3f::normalize(), and pge::Vector3f::subtract().
|
Here is the call graph for this function:
|
Create a plane out of a startpoint and two vectors.
Definition at line 52 of file Plane.cpp. References pge::Vector3f::crossProduct(), pge::Vector3f::dotProduct(), m_d, m_normal, and pge::Vector3f::normalize().
|
Here is the call graph for this function:
|
Create a plane out of the normal and the d component.
Definition at line 64 of file Plane.cpp. References m_d, m_normal, and pge::Vector3f::normalize().
|
Here is the call graph for this function:
|
Create a plane from a triangle.
Definition at line 76 of file Plane.cpp. References a(), b(), c(), pge::Vector3f::crossProduct(), pge::Vector3f::dotProduct(), m_d, m_normal, pge::Triangle::m_vertices, pge::Vector3f::normalize(), and pge::Vector3f::subtract().
00076 { 00077 Vector3f a; 00078 Vector3f b; 00079 Vector3f c; 00080 Vector3f u; 00081 Vector3f v; 00082 00083 a = triangle->m_vertices[0]; 00084 b = triangle->m_vertices[1]; 00085 c = triangle->m_vertices[2]; 00086 00087 // Get the spanning vectors for the plane. 00088 u = b.subtract(a); 00089 v = c.subtract(a); 00090 00091 m_normal = u.crossProduct(v); 00092 m_normal.normalize(); 00093 00094 m_d = -(a.dotProduct(m_normal)); 00095 } |
Here is the call graph for this function:
|
Destructor.
Definition at line 103 of file Plane.cpp.
00103 { 00104 } |
|
Return A component.
Definition at line 46 of file Plane.h. References m_normal, and pge::Vector3f::m_v. Referenced by Plane().
00046 { 00047 return m_normal.m_v[0]; 00048 } |
|
Return B component.
Definition at line 51 of file Plane.h. References m_normal, and pge::Vector3f::m_v. Referenced by Plane().
00051 { 00052 return m_normal.m_v[1]; 00053 } |
|
Return C component.
Definition at line 56 of file Plane.h. References m_normal, and pge::Vector3f::m_v. Referenced by Plane().
00056 { 00057 return m_normal.m_v[2]; 00058 } |
|
Return D component.
Definition at line 61 of file Plane.h. References m_d. Referenced by isPointOnPlane().
00061 { 00062 return m_d; 00063 } |
|
Returns the distance to the nearest point on the plane. The function uses the nearest footpoint on the plane and returns the distance between the footpoint and the given point. Definition at line 135 of file Plane.cpp. References pge::Vector3f::dotProduct(), m_d, and m_normal. Referenced by isPointOnPlane().
|
Here is the call graph for this function:
|
Returns the nearest point on the plane from the given point.
Definition at line 145 of file Plane.cpp. References pge::Vector3f::dotProduct(), m_d, m_normal, pge::Vector3f::multiply(), and pge::Vector3f::subtract().
|
Here is the call graph for this function:
|
Returns the intersection point of a line and the plane.
Definition at line 160 of file Plane.cpp. References pge::Vector3f::dotProduct(), m_d, m_normal, pge::Vector3f::m_v, pge::Vector3f::normalize(), PLANE_ZERO_TOLERANCE, and pge::Vector3f::subtract(). Referenced by pge::Mesh::getHeightAt().
00160 { 00161 // 00162 // Variables 00163 // 00164 Vector3f lineDirection; 00165 Vector3f result; 00166 float distPoint; 00167 float dotLine; 00168 float distance; 00169 00170 00171 lineDirection = lineEnd.subtract(lineStart); 00172 lineDirection.normalize(); 00173 00174 00175 distPoint = -(m_normal.m_v[0] * lineStart.m_v[0] + 00176 m_normal.m_v[1] * lineStart.m_v[1] + 00177 m_normal.m_v[2] * lineStart.m_v[2] + m_d); 00178 00179 dotLine = m_normal.dotProduct(lineDirection); 00180 00181 /*if(dotLine == 0.0f) { 00182 return lineStart; 00183 }*/ 00184 if(mathutils::isValueInTolerance(dotLine, 0.0f, PLANE_ZERO_TOLERANCE)) { 00185 return lineStart; 00186 } 00187 00188 00189 distance = distPoint / dotLine; 00190 00191 result.m_v[0] = lineStart.m_v[0] + (lineDirection.m_v[0] * distance); 00192 result.m_v[1] = lineStart.m_v[1] + (lineDirection.m_v[1] * distance); 00193 result.m_v[2] = lineStart.m_v[2] + (lineDirection.m_v[2] * distance); 00194 00195 return result; 00196 } |
Here is the call graph for this function:
|
Checks if a line intersects this plane.
Definition at line 204 of file Plane.cpp. References m_d, m_normal, and pge::Vector3f::m_v.
00204 { 00205 // 00206 // Variables 00207 // 00208 float dist1; 00209 float dist2; 00210 00211 00212 dist1 = 0.0f; 00213 dist2 = 0.0f; 00214 00215 dist1 = ((m_normal.m_v[0] * lineStart.m_v[0]) + 00216 (m_normal.m_v[1] * lineStart.m_v[1]) + 00217 (m_normal.m_v[2] * lineStart.m_v[2])) + m_d; 00218 00219 dist2 = ((m_normal.m_v[0] * lineEnd.m_v[0]) + 00220 (m_normal.m_v[1] * lineEnd.m_v[1]) + 00221 (m_normal.m_v[2] * lineEnd.m_v[2])) + m_d; 00222 00223 if(dist1 * dist2 >= 0.0f) { 00224 return false; 00225 } 00226 00227 return true; 00228 } |
|
Returns 1 if the point is on the plane.
Definition at line 112 of file Plane.cpp. References d(), getDistanceToPoint(), and PLANE_ZERO_TOLERANCE.
00112 { 00113 /*float d; 00114 bool ret; 00115 00116 d = getDistanceToPoint(point); 00117 ret = (d == 0.0f); 00118 return ret;*/ 00119 00120 float d; 00121 00122 d = getDistanceToPoint(point); 00123 00124 // This seems to work pretty well. 00125 return mathutils::isValueInTolerance(d, 0.0f, PLANE_ZERO_TOLERANCE); 00126 00127 } |
Here is the call graph for this function:
|
Prints the plane's data out.
Definition at line 236 of file Plane.cpp.
00236 { 00237 //printf("normal: %f %f %f\n", m_normal.m_v[0], m_normal.m_v[1], m_normal.m_v[2]); 00238 //printf(" D: %f\n", m_d); 00239 return std::string("TODO"); 00240 } |
|
Definition at line 92 of file Plane.h. Referenced by d(), getDistanceToPoint(), getFootPoint(), getIntersectionPoint(), isLineIntersecting(), and Plane(). |
|
Definition at line 91 of file Plane.h. Referenced by a(), pge::VBO::addTriangle(), b(), c(), getDistanceToPoint(), getFootPoint(), getIntersectionPoint(), isLineIntersecting(), Plane(), and pge::Mesh::renderImmediate(). |