00001
00002 #ifndef _GK_PN_TRIANGLE_H
00003 #define _GK_PN_TRIANGLE_H
00004
00005 #include "Geometry.h"
00006 #include "Transform.h"
00007 #include "Triangle.h"
00008
00009 namespace gk {
00010
00011
00012 struct PNTriangle
00013 {
00014 Point a, b, c;
00015 Normal na, nb, nc;
00016
00017
00018 PNTriangle( ) {}
00019
00020
00021 PNTriangle(
00022 const Point& _a, const Normal& _na,
00023 const Point& _b, const Normal& _nb,
00024 const Point& _c, const Normal& _nc )
00025 :
00026 a(_a), b(_b), c(_c),
00027 na(_na), nb(_nb), nc(_nc)
00028 {}
00029
00030
00031 ~PNTriangle( ) {}
00032
00033
00034 float getBaseArea( ) const
00035 {
00036 Vector ab(a, b);
00037 Vector ac(a, c);
00038
00039 return .5f * Cross(ab, ac).Length();
00040 }
00041
00042
00043 Normal getBaseNormal( ) const
00044 {
00045 Vector ab(a, b);
00046 Vector ac(a, c);
00047
00048 return Normal( Normalize(Cross(ab, ac)) );
00049 }
00050
00051
00052 BBox getBaseBBox( ) const
00053 {
00054 BBox bbox;
00055 bbox.Union(a);
00056 bbox.Union(b);
00057 bbox.Union(c);
00058
00059 return bbox;
00060 }
00061
00062
00063 PNTriangle transform( const Transform& t )
00064 {
00065 return PNTriangle( t(a), t(na), t(b), t(nb), t(c), t(nc) );
00066 }
00067
00068
00069 Triangle getBaseTriangle( )
00070 {
00071 return Triangle(a, b, c);
00072 }
00073 };
00074
00075 }
00076 #endif