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
00021 planeNormal.x = plane.nx;
00022 planeNormal.y = plane.ny;
00023 planeNormal.z = plane.nz;
00024
00025
00026
00027
00028
00029
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
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