00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #include "OgreStableHeaders.h" 00026 #include "OgrePlane.h" 00027 00028 namespace Ogre { 00029 //----------------------------------------------------------------------- 00030 Plane::Plane () 00031 { 00032 normal = Vector3::ZERO; 00033 d = 0.0; 00034 } 00035 //----------------------------------------------------------------------- 00036 Plane::Plane (const Plane& rhs) 00037 { 00038 normal = rhs.normal; 00039 d = rhs.d; 00040 } 00041 //----------------------------------------------------------------------- 00042 Plane::Plane (const Vector3& rkNormal, Real fConstant) 00043 { 00044 normal = rkNormal; 00045 d = -fConstant; 00046 } 00047 //----------------------------------------------------------------------- 00048 Plane::Plane (const Vector3& rkNormal, const Vector3& rkPoint) 00049 { 00050 normal = rkNormal; 00051 d = -rkNormal.dotProduct(rkPoint); 00052 } 00053 //----------------------------------------------------------------------- 00054 Plane::Plane (const Vector3& rkPoint0, const Vector3& rkPoint1, 00055 const Vector3& rkPoint2) 00056 { 00057 Vector3 kEdge1 = rkPoint1 - rkPoint0; 00058 Vector3 kEdge2 = rkPoint2 - rkPoint0; 00059 normal = kEdge1.crossProduct(kEdge2); 00060 normal.normalise(); 00061 d = -normal.dotProduct(rkPoint0); 00062 } 00063 //----------------------------------------------------------------------- 00064 Real Plane::getDistance (const Vector3& rkPoint) const 00065 { 00066 return normal.dotProduct(rkPoint) + d; 00067 } 00068 //----------------------------------------------------------------------- 00069 Plane::Side Plane::getSide (const Vector3& rkPoint) const 00070 { 00071 Real fDistance = getDistance(rkPoint); 00072 00073 if ( fDistance < 0.0 ) 00074 return Plane::NEGATIVE_SIDE; 00075 00076 if ( fDistance > 0.0 ) 00077 return Plane::POSITIVE_SIDE; 00078 00079 return Plane::NO_SIDE; 00080 } 00081 //----------------------------------------------------------------------- 00082 std::ostream& operator<< (std::ostream& o, Plane& p) 00083 { 00084 o << "Plane(normal=" << p.normal << ", d=" << p.d << ")"; 00085 return o; 00086 } 00087 00088 } // namespace Ogre
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:21 2004