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
00020 planeNormal = plane.normal;
00021
00022
00023
00024
00025
00026
00027 temp = pointOnPlane - point0;
00028 numerator = DotProduct(planeNormal, temp);
00029
00030
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