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

ray3.h

Go to the documentation of this file.
00001 /*
00002 * $Id: ray3.h,v 1.1 2003/09/05 04:20:11 jmk Exp $
00003 */
00004 ///////////////////////////////////////////////////////////////////////////
00005 //              _____________  ______________________    __   __  _____
00006 //             /  ________  |  |   ___   ________   /   |  \ /  \   |
00007 //            |  |       |  |_ |  |_ |  |       /  /    \__  |      |
00008 //            |  |  ___  |  || |  || |  |      /  /        | |      |
00009 //            |  | |   \ |  || |  || |  |     /  /      \__/ \__/ __|__
00010 //            |  | |_@  ||  || |  || |  |    /  /          Institute
00011 //            |  |___/  ||  ||_|  || |  |   /  /_____________________
00012 //             \_______/  \______/ | |__|  /___________________________
00013 //                        |  |__|  |
00014 //                         \______/
00015 //                    University of Utah       
00016 //                           2002
00017 ///////////////////////////////////////////////////////////////////////////
00018 
00019 
00020 #ifndef __GUTZ_RAY_3_H
00021 #define __GUTZ_RAY_3_H
00022 
00023 #include "vec3.h"
00024 #include "plane.h"
00025 #include <limits>
00026 
00027 namespace gutz {
00028 
00029 template< class T >
00030 class ray3 {
00031 public:
00032    ray3() : p(vec3<T>(0,0)), d(vec3<T>(0,1)) {}
00033    ray3(const vec3<T> &pos, const vec3<T> &dir) : p(pos), d(dir) {}
00034    ray3(const ray3 &r) : d(r.d), p(r.p) {}
00035 
00036    inline
00037    ray3 &operator=(const ray3 &r) { d=r.d; p=r.p; return *this; }
00038 
00039    inline
00040    vec3<T> pos(T t)  const 
00041    { return vec3<T>(p.x+d.x*t, p.y+d.y*t, p.z*d.z*t); }
00042 
00043    ~ray3() {}
00044 
00045    inline T intersect(const plane<T> &pl) const
00046    {
00047       return intersectRayPlane<T>( p, d, pl.p, pl.n);
00048    }
00049 
00050    inline vec3<T> intersectPos(const plane<T> &pl)
00051    {
00052       return pos( intersect(pl) );
00053    }
00054 
00055 public:
00056    vec3<T> p;
00057    vec3<T> d;
00058 
00059 };
00060 
00061 typedef ray3<float>  ray3f;
00062 typedef ray3<double> ray3d;
00063 
00064 }/// end namespace gutz
00065 
00066 #endif
00067 

Send questions, comments, and bug reports to:
jmk