#include <windows.h>
#include "plane.h"
#include "locmath.h"
#include "mmgr.h"
Go to the source code of this file.
Functions | |
VECTOR | GetEdgeIntersection (VECTOR point0, VECTOR point1, PLANE plane, VECTOR pointOnPlane) |
|
Definition at line 14 of file plane.cpp. References DotProduct(), PLANE::normal, VECTOR::x, VECTOR::y, and VECTOR::z.
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 } |