Home | nevrax.com |
|
ps_plane_basis.hGo to the documentation of this file.00001 00007 /* Copyright, 2001 Nevrax Ltd. 00008 * 00009 * This file is part of NEVRAX NEL. 00010 * NEVRAX NEL is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2, or (at your option) 00013 * any later version. 00014 00015 * NEVRAX NEL is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * General Public License for more details. 00019 00020 * You should have received a copy of the GNU General Public License 00021 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00022 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00023 * MA 02111-1307, USA. 00024 */ 00025 00026 #ifndef NL_PS_PLANE_BASIS_H 00027 #define NL_PS_PLANE_BASIS_H 00028 00029 #include "nel/misc/types_nl.h" 00030 #include "nel/misc/vector.h" 00031 #include "nel/misc/matrix.h" 00032 #include "3d/ps_util.h" 00033 00034 00035 namespace NL3D { 00036 00037 00038 00039 00040 00045 struct CPlaneBasis 00046 { 00047 NLMISC::CVector X ; 00048 NLMISC::CVector Y ; 00049 00050 00051 // default ctor 00052 CPlaneBasis() {} 00053 00054 00055 // construct this basis by giving a normal to the plane that contains it 00056 CPlaneBasis(const NLMISC::CVector &normal) 00057 { 00058 NLMISC::CMatrix mat; 00059 CPSUtil::buildSchmidtBasis(normal, mat) ; 00060 X = mat.getI() ; 00061 Y = mat.getJ() ; 00062 } 00063 00064 // construct this basis by giving its X and Y vectors 00065 CPlaneBasis(const NLMISC::CVector &x, const NLMISC::CVector &y) : X(x), Y(y) 00066 { 00067 } 00068 00070 NLMISC::CVector getNormal(void) const 00071 { 00072 return X ^ Y ; 00073 } 00074 00075 00076 void serial(NLMISC::IStream &f) throw(NLMISC::EStream) 00077 { 00078 f.serial(X, Y) ; 00079 } 00080 } ; 00081 00082 00083 // for map insertion 00084 00085 inline bool operator<(const CPlaneBasis &p1, const CPlaneBasis &p2) 00086 { 00087 if (p1.X < p2.X) return true ; 00088 else if (p1.X == p2.X) return false ; 00089 else if (p1.Y < p2.Y) return true ; 00090 else if (p1.X == p2.Y) return false ; 00091 else return true ; 00092 } 00093 00094 00095 00096 00097 00098 00099 } // NL3D 00100 00101 00102 #endif // NL_PS_PLANE_BASIS_H 00103 00104 /* End of ps_plane_basis.h */ |