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 = plane.normal;
00021 
00022 // find edge intersection:
00023 // intersection = p0 + (p1 - p0) * t
00024 // where t = (planeNormal . (pointOnPlane - p0)) / (planeNormal . (p1 - p0))
00025 
00026     //planeNormal . (pointOnPlane - point0)
00027     temp = pointOnPlane - point0;
00028     numerator = DotProduct(planeNormal, temp);
00029 
00030     //planeNormal . (point1 - point0)
00031     temp = point1 - point0;
00032     denominator = DotProduct(planeNormal, temp);
00033 
00034     if (denominator)
00035         t = numerator / denominator;
00036     else
00037         t = 0.0;
00038 
00039     intersection.x = point0.x + temp.x * t;
00040     intersection.y = point0.y + temp.y * t;
00041     intersection.z = point0.z + temp.z * t;
00042 
00043     return intersection;
00044 }
00045 

Generated on Fri Dec 23 05:15:47 2005 for Constructive Solid Geometry by doxygen1.2.15