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

Generated on Fri Dec 23 05:19:55 2005 for Particles by doxygen1.2.15