00001 /* 00002 File: Geometry.h 00003 00004 Function: General geometrical definitions for points, vectors, etc. 00005 00006 Author(s): Andrew Willmott 00007 00008 Copyright: (c) 1995-2000, Andrew Willmott 00009 */ 00010 00011 #ifndef __Geometry__ 00012 #define __Geometry__ 00013 00014 #include "gcl/GCLConfig.h" 00015 00016 #include "cl/Array.h" 00017 #include "cl/NArray.h" 00018 00019 00020 // --- Fundamental primitives ------------------------------------------------- 00021 00022 #ifdef GCL_FLOAT 00023 #include "vl/VLfd.h" 00024 typedef Float GCLReal; 00025 typedef Vec3f Point; // We try and make provision here for points and 00026 typedef Vec3f Vector; // vectors being separate types in future... 00027 typedef Vec4f Vector4; 00028 typedef Vec4d Quaternion; 00029 typedef Vec2f Coord; 00030 00031 typedef Vec4f HPoint; 00032 typedef Vec4f HVector; 00033 typedef Vecf GCLVec; 00034 #else 00035 #include "vl/VLd.h" 00036 typedef Double GCLReal; 00037 typedef Vec3d Point; 00038 typedef Vec3d Vector; 00039 typedef Vec4d Vector4; 00040 typedef Vec4d Quaternion; 00041 typedef Vec2d Coord; 00042 00043 typedef Vec4d HPoint; 00044 typedef Vec4d HVector; 00045 typedef Vecd GCLVec; 00046 #endif 00047 00048 typedef Vec3d MVector; 00049 typedef Vec4d MVector4; 00050 typedef Mat4d Transform; 00051 typedef Mat3d VecTrans; 00052 typedef Mat2d CoordTrans; 00053 typedef Matd GCLMat; 00054 00055 typedef Int Index; 00056 00057 inline Transform Rotation(const Vector &axis, GCLReal theta) 00058 { Transform result; result.MakeHRot(axis, theta); return(result); } 00059 inline Transform Rotation(const Quaternion &q) 00060 { Transform result; result.MakeHRot(q); return(result); } 00061 inline Transform Scale(const Vector &s) 00062 { Transform result; result.MakeHScale(MVector(s[0], s[1], s[2])); return(result); } 00063 inline Transform Scalef(GCLReal r) 00064 { Transform result; result.MakeHScale(MVector(r, r, r)); return(result); } 00065 inline Transform Shift(const Vector &t) 00066 { Transform result; result.MakeHTrans(MVector(t[0], t[1], t[2])); return(result); } 00067 00068 inline Transform Scale(GCLReal sx, GCLReal sy, GCLReal sz) 00069 { Transform result; result.MakeHScale(MVector(sx, sy, sz)); return(result); } 00070 inline Transform Scale(GCLReal s) 00071 { Transform result; result.MakeHScale(MVector(s, s, s)); return(result); } 00072 inline Transform Shift(GCLReal tx, GCLReal ty, GCLReal tz) 00073 { Transform result; result.MakeHTrans(MVector(tx, ty, tz)); return(result); } 00074 00075 Transform Align(const Vector &xAxis, const Vector &yAxis, const Vector &zAxis); 00076 Transform AlignToDir(const Vector &dir); 00077 00078 00079 typedef Array<Int> IndexList; 00080 typedef Array<GCLReal> ScalarList; 00081 typedef NArray<Point> PointList; 00082 typedef NArray<Vector> VectorList; 00083 typedef NArray<Coord> CoordList; 00084 typedef VectorList NormalList; 00085 00086 inline GCLReal DegsToRads(GCLReal degrees) 00087 { return(degrees * (vl_pi / 180.0)); } 00088 inline GCLReal RadsToDegs(GCLReal rads) 00089 { return(rads * (180.0 / vl_pi)); } 00090 00091 IndexList Indexes(Int first, ...); 00092 const Index IDX_END = -1; 00093 00094 #endif