infovis
|
00001 #ifndef TRIANGLE_H 00002 #define TRIANGLE_H 00003 #include <math.h> 00004 #include "Vertex.h" 00005 #include "geoshape.h" 00006 00007 class Triangle : public GeoShape 00008 { 00009 public: 00010 00011 Triangle( float x, float y, float radius ): GeoShape( GeoShape::TRIANGLE,x,y,radius ) // Radius is the distance from the center to one of the vertex 00012 { 00013 mVertices[0] = Vertex(x, radius+y); // Upper vertex 00014 mVertices[1] = Vertex(x+radius*sqrt(3.0)/2, y-radius/2); // Lower right 00015 mVertices[2] = Vertex(x-radius*sqrt(3.0)/2, y-radius/2); // Lower left 00016 00017 GeoShape::mVertices = mVertices; 00018 GeoShape::mNumVertices = 3; 00019 } 00020 00021 Triangle(Vertex v1, Vertex v2, Vertex v3) 00022 { 00023 mVertices[0] = v1; 00024 mVertices[1] = v2; 00025 mVertices[2] = v3; 00026 } 00027 00028 ~Triangle( void ) {} 00029 00030 Vertex mVertices[3]; 00031 }; 00032 00033 #endif