00001 #include "Cone.h"
00002
00003
00004
00005 REGISTER_IMPLICIT(Cone,"Algebraic:Quadric:Cone");
00006
00007 Cone::Cone(gmVector3 d, double r) : Quadric(1.0, 1.0, -r*r, 0.0)
00008 {
00009 gmVector3 zAxis, rotAxis;
00010 gmMatrix4 rotMatrix;
00011 double rotCosine;
00012 double rotAngle;
00013
00014 zAxis.assign(0.0, 0.0, 1.0);
00015 rotAxis = cross(d, zAxis);
00016 rotCosine = dot(d, zAxis);
00017 rotAngle = acos(rotCosine);
00018 rotMatrix = gmMatrix4::rotate(rotAngle, rotAxis);
00019 Transform(rotMatrix);
00020 }
00021
00022 Cone::Cone(gmVector3 x, gmVector3 d, double r) : Quadric(1.0, 1.0, -r*r, 0.0)
00023 {
00024 gmVector3 zAxis, rotAxis;
00025 gmMatrix4 rotMatrix, transMatrix;
00026 double rotCosine;
00027 double rotAngle;
00028
00029 zAxis.assign(0.0, 0.0, 1.0);
00030 rotAxis = cross(d, zAxis);
00031 rotCosine = dot(d, zAxis);
00032 rotAngle = acos(rotCosine);
00033 rotMatrix = gmMatrix4::rotate(rotAngle, rotAxis);
00034 Transform(rotMatrix);
00035
00036 transMatrix = gmMatrix4::translate(x[0],x[1],x[2]);
00037 Transform(transMatrix);
00038 }
00039
00040 const char ** Cone::getPixmapXPM(const int& size) const
00041 {
00042 if (size <= 16)
00043 return (const char **)cone_pixmap16;
00044 else if (size <= 32)
00045 return (const char **)cone_pixmap32;
00046 else
00047 return (const char **)cone_pixmap48;
00048 }
00049