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

Plane.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: Plane.cpp,v 1.5 2002/01/22 19:30:05 tksuoran Exp $
00022 */
00023 
00024 
00025 #include "Teddy/Maths/Plane.h"
00026 #include "Teddy/SysSupport/StdIO.h"
00027 
00028 
00029 namespace Teddy {
00030 namespace Maths {
00031 
00032 
00039 /*
00040 Plane::Plane( const Vector &p1, const Vector &p2, const Vector &p3 ){
00041     *this = (p1-p2) * (p1-p3);
00042     this->Norm();
00043     d = -( r*p1.r + s*p1.s + t*p1.t );
00044 } */
00045 
00046 
00051 double Plane::distance( const Vector &p ) const {
00052     return( v[0]*p.v[0] + v[1]*p.v[1] + v[2]*p.v[2] + v[3] );
00053 }
00054 
00055 
00057 void Plane::neg(){
00058     v[0] = -v[0];
00059     v[1] = -v[1];
00060     v[2] = -v[2];
00061     v[3] = -v[3];
00062 }
00063 
00064 
00065 
00066 Vector Plane::getNormal() const {
00067     return Vector( v[0], v[1], v[2] );
00068 }
00069 
00070 
00071 double Plane::getConstant() const {
00072     return v[3];
00073 }
00074 
00076 Plane &Plane::operator=( const Vector &vec ){
00077     v[0] = vec.v[0];
00078     v[1] = vec.v[1];
00079     v[2] = vec.v[2]; 
00080     return( *this );
00081 }
00082 
00084 Plane &Plane::operator=( const Vector4 &vec ){
00085     v[0] = vec.v[0];
00086     v[1] = vec.v[1];
00087     v[2] = vec.v[2]; 
00088     v[3] = vec.v[3]; 
00089     return( *this );
00090 }
00091 
00092 
00093 };  //  namespace Maths
00094 };  //  namespace Teddy
00095