www.pudn.com > simpleraytracer_v1_0.zip > rayplane.cpp
/*===================================================================
digital liberation front 2002
_______ ______ _______
/______/\ |______| /\______\
| \ \ | | / / |
| \| | | |/ |
|_____ \ | |_ / ______|
____| | | |_|| |_____
|____| |________||____|
Code by Nicholas Chapman[/ Ono-Sendai]
nickamy@paradise.net.nz
You may use this code for any non-commercial project,
as long as you do not remove this description.
You may not use this code for any commercial project.
====================================================================*/
#include "rayplane.h"
#include "ray.h"
RayPlane::RayPlane(const Plane&amt; plane_)
: plane(plane_)
{
}
float RayPlane::getDistanceUntilHit(const Ray&amt; ray) const
{
//NOTE: deal with div by 0?
return (ray.startpos.dot(plane.getNormal()) - plane.getDist()) /
-dot(plane.getNormal(), ray.unitdir);
}