00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __NEPLANE_H
00028 #define __NEPLANE_H
00029
00030
00031 #include "base.h"
00032 #include "nemath.h"
00033
00034
00041 namespace NeoEngine
00042 {
00043
00044
00051 class NEOENGINE_API Plane
00052 {
00053 public:
00054
00056 Vector3d m_kNormal;
00057
00059 float m_fDistance;
00060
00061
00062
00066 Plane() : m_kNormal( 0.0f, 0.0f, 0.0f ), m_fDistance( 0.0f ) {}
00067
00072 Plane( const Plane &rkPlane ) : m_kNormal( rkPlane.m_kNormal ), m_fDistance( rkPlane.m_fDistance ) {}
00073
00079 Plane( const Vector3d &rkNormal, float fDistance ) : m_kNormal( rkNormal ), m_fDistance( fDistance ) {}
00080
00087 Plane( const Vector3d &rkPointOne, const Vector3d &rkPointTwo, const Vector3d &rkPointThree ) : m_kNormal(), m_fDistance( 0.0f ) { m_kNormal = ( rkPointTwo - rkPointOne ) % ( rkPointThree - rkPointOne ); m_kNormal.Normalize(); m_fDistance = -( rkPointOne * m_kNormal ); }
00088
00094 Plane( const Vector3d &rkNormal, const Vector3d &rkPoint ) : m_kNormal( rkNormal ), m_fDistance( -( rkPoint * m_kNormal ) ) {}
00095
00101 inline void Set( const Vector3d &rkNormal, float fDistance ) { m_kNormal = rkNormal, m_fDistance = fDistance; }
00102
00109 inline void Set( const Vector3d &rkPointOne, const Vector3d &rkPointTwo, const Vector3d &rkPointThree ) { m_kNormal = ( rkPointTwo - rkPointOne ) % ( rkPointThree - rkPointOne ); m_kNormal.Normalize(); m_fDistance = -( rkPointOne * m_kNormal ); }
00110
00116 inline void Set( const Vector3d &rkNormal, const Vector3d &rkPoint ) { m_kNormal = rkNormal; m_fDistance = -( rkPoint * m_kNormal ); }
00117
00122 inline float Distance( const Vector3d &rkPoint ) const { return( m_kNormal * rkPoint + m_fDistance ); }
00123
00127 inline Vector3d GetPointOnPlane() const { return( m_kNormal * -m_fDistance ); }
00128
00133 inline bool operator == ( const Plane &rkPlane ) const { return( ( m_kNormal == rkPlane.m_kNormal ) && ( m_fDistance == rkPlane.m_fDistance ) ); }
00134 };
00135
00136
00137 };
00138
00139
00140
00141 #endif // __NEPLANE_H