llplane.h

Go to the documentation of this file.
00001 
00031 #ifndef LL_LLPLANE_H
00032 #define LL_LLPLANE_H
00033 
00034 #include "v3math.h"
00035 #include "v4math.h"
00036 
00037 // A simple way to specify a plane is to give its normal,
00038 // and it's nearest approach to the origin.
00039 // 
00040 // Given the equation for a plane : A*x + B*y + C*z + D = 0
00041 // The plane normal = [A, B, C]
00042 // The closest approach = D / sqrt(A*A + B*B + C*C)
00043 
00044 class LLPlane : public LLVector4
00045 {
00046 public:
00047         LLPlane() {}; // no default constructor
00048         LLPlane(const LLVector3 &p0, F32 d) { setVec(p0, d); }
00049         LLPlane(const LLVector3 &p0, const LLVector3 &n) { setVec(p0, n); }
00050         void setVec(const LLVector3 &p0, F32 d) { LLVector4::setVec(p0[0], p0[1], p0[2], d); }
00051         void setVec(const LLVector3 &p0, const LLVector3 &n)
00052         {
00053                 F32 d = -(p0 * n);
00054                 setVec(n, d);
00055         }
00056         void setVec(const LLVector3 &p0, const LLVector3 &p1, const LLVector3 &p2)
00057         {
00058                 LLVector3 u, v, w;
00059                 u = p1 - p0;
00060                 v = p2 - p0;
00061                 w = u % v;
00062                 w.normVec();
00063                 F32 d = -(w * p0);
00064                 setVec(w, d);
00065         }
00066         LLPlane& operator=(const LLVector4& v2) {  LLVector4::setVec(v2[0],v2[1],v2[2],v2[3]); return *this;}
00067         F32 dist(const LLVector3 &v2) const { return mV[0]*v2[0] + mV[1]*v2[1] + mV[2]*v2[2] + mV[3]; }
00068 };
00069 
00070 
00071 
00072 #endif // LL_LLPLANE_H

Generated on Thu Jul 1 06:09:00 2010 for Second Life Viewer by  doxygen 1.4.7