Al's Programming Resource Homepage  Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

plane.cpp File Reference

#include <windows.h>
#include "plane.h"
#include "locmath.h"
#include "mmgr.h"

Go to the source code of this file.

Functions

VECTOR GetEdgeIntersection (VECTOR point0, VECTOR point1, PLANE plane, VECTOR pointOnPlane)


Function Documentation

VECTOR GetEdgeIntersection VECTOR    point0,
VECTOR    point1,
PLANE    plane,
VECTOR    pointOnPlane
 

Definition at line 15 of file plane.cpp.

References DotProduct(), PLANE::nx, PLANE::ny, PLANE::nz, VECTOR::x, VECTOR::y, and VECTOR::z.

00016 {
00017     VECTOR planeNormal, intersection, temp;
00018     float numerator, denominator, t;
00019 
00020     // get the splitting planes normal
00021     planeNormal.x = plane.nx;
00022     planeNormal.y = plane.ny;
00023     planeNormal.z = plane.nz;
00024 
00025 // find edge intersection:
00026 // intersection = p0 + (p1 - p0) * t
00027 // where t = (planeNormal . (pointOnPlane - p0)) / (planeNormal . (p1 - p0))
00028 
00029     //planeNormal . (pointOnPlane - point0)
00030     temp.x = pointOnPlane.x - point0.x;
00031     temp.y = pointOnPlane.y - point0.y;
00032     temp.z = pointOnPlane.z - point0.z;
00033     numerator = DotProduct(planeNormal, temp);
00034 
00035     //planeNormal . (point1 - point0)
00036     temp.x = point1.x - point0.x;
00037     temp.y = point1.y - point0.y;
00038     temp.z = point1.z - point0.z;
00039     denominator = DotProduct(planeNormal, temp);
00040 
00041     if (denominator)
00042         t = numerator / denominator;
00043     else
00044         t = 0.0;
00045 
00046     intersection.x = point0.x + temp.x * t;
00047     intersection.y = point0.y + temp.y * t;
00048     intersection.z = point0.z + temp.z * t;
00049 
00050     return intersection;
00051 }


Generated on Fri Dec 23 05:20:41 2005 for Potentially Visible Sets by doxygen1.2.15