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

plane.cpp

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include "plane.h"
00003 #include "locmath.h"
00004 #include "mmgr.h"
00005 
00006 
00007 PLANE::PLANE()
00008 {
00009 }
00010 
00011 PLANE::~PLANE()
00012 {
00013 }
00014 
00015 VECTOR GetEdgeIntersection(VECTOR point0, VECTOR point1, PLANE plane, VECTOR pointOnPlane)
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 }
00052 

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