Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef _GMTL_PLANE_H
00007 #define _GMTL_PLANE_H
00008
00009 #include <gmtl/Vec.h>
00010 #include <gmtl/Point.h>
00011 #include <gmtl/VecOps.h>
00012
00013 namespace gmtl
00014 {
00015
00035 template< class DATA_TYPE>
00036 class Plane
00037 {
00038 public:
00043 Plane()
00044 : mOffset( 0 )
00045 {}
00046
00054 Plane( const Point<DATA_TYPE, 3>& pt1, const Point<DATA_TYPE, 3>& pt2,
00055 const Point<DATA_TYPE, 3>& pt3)
00056 {
00057 Vec<DATA_TYPE, 3> vec12( pt2-pt1 );
00058 Vec<DATA_TYPE, 3> vec13( pt3-pt1 );
00059
00060 cross( mNorm, vec12, vec13 );
00061 normalize( mNorm );
00062
00063 mOffset = dot( static_cast< Vec<DATA_TYPE, 3> >(pt1), mNorm );
00064 }
00065
00072 Plane( const Vec<DATA_TYPE, 3>& norm, const Point<DATA_TYPE, 3>& pt )
00073 : mNorm( norm )
00074 {
00075 mOffset = dot( static_cast< Vec<DATA_TYPE, 3> >(pt), norm );
00076 }
00077
00084 Plane( const Vec<DATA_TYPE, 3>& norm, const DATA_TYPE& dPlaneConst )
00085 : mNorm( norm ), mOffset( dPlaneConst )
00086 {}
00087
00093 Plane( const Plane<DATA_TYPE>& plane )
00094 : mNorm( plane.mNorm ), mOffset( plane.mOffset )
00095 {}
00096
00102 const Vec<DATA_TYPE, 3>& getNormal() const
00103 {
00104 return mNorm;
00105 }
00106
00114 void setNormal( const Vec<DATA_TYPE, 3>& norm )
00115 {
00116 mNorm = norm;
00117 }
00118
00125 const DATA_TYPE& getOffset() const
00126 {
00127 return mOffset;
00128 }
00129
00135 void setOffset( const DATA_TYPE& offset )
00136 {
00137 mOffset = offset;
00138 }
00139
00140 public:
00141
00146 Vec<DATA_TYPE, 3> mNorm;
00147
00153 DATA_TYPE mOffset;
00154 };
00155
00156 typedef Plane<float> Planef;
00157 typedef Plane<double> Planed;
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 }
00226 #endif