GeoObjects.h

00001 //derived geometric objects
00002 //Luke Lenhart (2005)
00003 //See /docs/License.txt for details on how this code may be used.
00004 
00005 #pragma once
00006 
00007 #include "Geo.h"
00008 
00009 namespace GEO
00010 {
00011 //3d line
00012 struct Line
00013 {
00014     Vector3 pos; //position of a point on the line
00015     Vector3 dir; //direction of the line
00016 
00017     //
00018     inline Line() {}
00019     inline Line(const Vector3 &inPos, const Vector3 &inDir)
00020         { pos=inPos; dir=inDir; }
00021 };
00022 
00023 //3d plane
00024 struct Plane
00025 {
00026     float c0,c1,c2,c3; //plane coeffecients
00027 
00028     //
00029     inline Plane()
00030         { c0=c1=c2=c3=0.0f; }
00031     //from a position and a normal
00032     inline Plane(const Vector3 &inPos, const Vector3 &inNormal)
00033     {
00034         Normal()=inNormal;
00035         Renormalize();
00036         c3=-VecDot(inPos,Normal());
00037     }
00038     //from the 4 coeffecients
00039     inline Plane(float inC0,float inC1,float inC2,float inC3): c0(inC0), c1(inC1), c2(inC2), c3(inC3)
00040         { Renormalize(); }
00041 
00042     //gets normal of plane
00043     inline Vector3& Normal() const { return *((Vector3*)this); }
00044 
00045     //normalizes normal of plane
00046     inline void Renormalize() { Normal().Normalize(); }
00047 };
00048 
00049 }; //namespace GEO

Generated on Wed Feb 13 20:57:04 2008 for MPMA Framework by  doxygen 1.5.4