Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

plane.cpp

Go to the documentation of this file.
00001 
00002 
00003 #include "stdafx.h"
00004 #include "plane.h"
00005 
00006 Plane::Plane() {
00007         normal = VECTOR(0,0,0);
00008         point = VECTOR(0,0,0);
00009         dist = 0.0;
00010 }
00011 
00012 Plane::Plane(VECTOR n, VECTOR p) {
00013         normal = n;
00014         point = p;
00015         dist = -normal.dot(point);
00016 }
00017 
00018 float
00019 Plane::Distance(VECTOR x) {
00020         VECTOR help = x - point;
00021         return fabsf(normal.dot(point));
00022 }
00023 
00024 bool
00025 Plane::Intersection(VECTOR ray_point, VECTOR ray_dir, VECTOR *res) {
00026         float dir_norm = ray_dir.dot(normal);
00027         if (fabsf(dir_norm) < 0.001) return false; // parallel
00028         float t = -(ray_point.dot(normal)+dist)/(dir_norm);
00029         *res = ray_point + t*ray_dir;
00030         return true;
00031 }

Generated on Thu Jan 30 21:35:43 2003 for 3DVis by doxygen1.3-rc2