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

plane.h

Go to the documentation of this file.
00001 /*
00002 * $Id: plane.h,v 1.3 2003/09/15 17:15:31 jmk Exp $
00003 */
00004 ///////////////////////////////////////////////////////////////////////////
00005 //              _____________  ______________________    __   __  _____
00006 //             /  ________  |  |   ___   ________   /   |  \ /  \   |
00007 //            |  |       |  |_ |  |_ |  |       /  /    \__  |      |
00008 //            |  |  ___  |  || |  || |  |      /  /        | |      |
00009 //            |  | |   \ |  || |  || |  |     /  /      \__/ \__/ __|__
00010 //            |  | |_@  ||  || |  || |  |    /  /          Institute
00011 //            |  |___/  ||  ||_|  || |  |   /  /_____________________
00012 //             \_______/  \______/ | |__|  /___________________________
00013 //                        |  |__|  |
00014 //                         \______/
00015 //                    University of Utah       
00016 //                           2002
00017 ///////////////////////////////////////////////////////////////////////////
00018 
00019 // plane.h
00020 
00021 #ifndef __GUTZ_PLANE_H
00022 #define __GUTZ_PLANE_H
00023 
00024 #include "vec3.h"
00025 
00026 namespace gutz {
00027 
00028 template<class T>
00029 class plane {
00030 public:
00031    /// default plane pos = (0,0,0), normal = z
00032    plane()
00033       : p(0,0,0), n(0,0,1)
00034    {}
00035    /// construct a plane from a point and normal
00036    plane(const vec3<T> &pos, const vec3<T> &norm)
00037       : p(pos), n(norm) 
00038    {}
00039    /// construct a plane given 3 points on it.
00040    /// pos = p1, normal = (p2 - p1) x (p3 - p1) \n
00041    /// for a correct x,y,z frame, p1 = ll, p2 = lr, p3 = ul
00042    plane(const vec3<T> &p1, const vec3<T> &p2, const vec3<T> &p3)
00043       : p(p1), n((p2-p1).cross(p3-p1))
00044    {}
00045    /// copy
00046    plane(const plane &pl)
00047       : p(pl.p), n(pl.n)
00048    {}
00049    /// assign
00050    plane &operator=(const plane &pl)
00051    {  p = pl.p; n = pl.n; return *this; }
00052 
00053 
00054 public:
00055    vec3<T> p;
00056    vec3<T> n;
00057 
00058 };
00059 
00060 typedef plane<float>  planef;
00061 typedef plane<double> planed;
00062 
00063 
00064 } ///< end namespace gutz
00065 
00066 #endif
00067 

Send questions, comments, and bug reports to:
jmk