Main Page   Class Hierarchy   Compound List   File List   Compound Members  

gePoint.cpp

00001 //////////////////////////////////////////////////////////////////////
00002 // Copyright (c) 2001-2003 David Pritchard <drpritch@alumni.uwaterloo.ca>
00003 // 
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later
00008 // version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 #include <freecloth/geom/gePoint.h>
00020 #include <freecloth/geom/geVector.h>
00021 #include <freecloth/base/baMath.h>
00022 
00023 ////////////////////////////////////////////////////////////////////////////////
00024 // LOCAL DECLARATIONS
00025 
00026 FREECLOTH_NAMESPACE_START
00027 
00028 ////////////////////////////////////////////////////////////////////////////////
00029 // CLASS GePoint
00030 
00031 const GePoint::CompX GePoint::_compX;
00032 const GePoint::CompY GePoint::_compY;
00033 const GePoint::CompZ GePoint::_compZ;
00034 const GePoint GePoint::NIL( ~0, ~0, ~0 );
00035 const GePoint GePoint::ZERO( 0, 0, 0 );
00036 
00037 //------------------------------------------------------------------------------
00038 
00039 GePoint::GePoint( const GePoint& a, const GePoint& b, Float fracA )
00040     : _x( a._x * fracA + b._x * (1-fracA) ),
00041     _y( a._y * fracA + b._y * (1-fracA) ),
00042     _z( a._z * fracA + b._z * (1-fracA) )
00043 {
00044 }
00045 
00046 //------------------------------------------------------------------------------
00047 
00048 GePoint::GePoint( const GePoint& a, const GePoint& b, const GePoint& c, Float fracA, Float fracB )
00049     : _x( a._x * fracA + b._x * fracB + c._x * (1-fracA-fracB) ),
00050     _y( a._y * fracA + b._y * fracB + c._y * (1-fracA-fracB) ),
00051     _z( a._z * fracA + b._z * fracB + c._z * (1-fracA-fracB) )
00052 {
00053 }
00054 
00055 //------------------------------------------------------------------------------
00056 
00057 GePoint& GePoint::operator+=( const GeVector& rhs )
00058 {
00059     _x += rhs._x;
00060     _y += rhs._y;
00061     _z += rhs._z;
00062     return *this;
00063 }
00064 
00065 //------------------------------------------------------------------------------
00066 
00067 GePoint& GePoint::operator-=( const GeVector& rhs )
00068 {
00069     _x -= rhs._x;
00070     _y -= rhs._y;
00071     _z -= rhs._z;
00072     return *this;
00073 }
00074 
00075 //------------------------------------------------------------------------------
00076 
00077 GePoint GePoint::operator+( const GeVector& rhs ) const
00078 {
00079     GePoint temp( *this );
00080     temp += rhs;
00081     return temp;
00082 }
00083 
00084 //------------------------------------------------------------------------------
00085 
00086 GePoint GePoint::operator-( const GeVector& rhs ) const
00087 {
00088     GePoint temp( *this );
00089     temp -= rhs;
00090     return temp;
00091 }
00092 
00093 //------------------------------------------------------------------------------
00094 
00095 GeVector GePoint::operator-( const GePoint& rhs ) const
00096 {
00097     return GeVector( rhs, *this );
00098 }
00099 
00100 
00101 ////////////////////////////////////////////////////////////////////////////////
00102 // GLOBAL FUNCTIONS
00103 //
00104 
00105 //------------------------------------------------------------------------------
00106 
00107 std::ostream& operator<<( std::ostream& os, const GePoint& p )
00108 {
00109     os << "p(" << p._x << "," << p._y << "," << p._z << ")";
00110     return os;
00111 }
00112 
00113 FREECLOTH_NAMESPACE_END

Generated on Fri May 2 13:04:25 2003 for Freecloth by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002