Circle2D.cpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  Circle2D.cpp
00003  *
00004  *  (C) 2006 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  *******************************************************************************/
00008 
00009 #include "Circle2D.h"
00010 #include "vec2.h"
00011 
00012 #include <math.h>
00013 
00014 #define THIS Circle2D
00015 
00016 using namespace std;
00017 
00018 THIS::THIS() {
00019   m_Radius=0.0;
00020 }
00021 
00022 THIS::THIS(double x, double y, double radius) {
00023   m_Center=Point2D(x,y);
00024   m_Radius=radius;
00025 }
00026 
00027 THIS::THIS( Point2D center, double radius) {
00028   m_Center=center;
00029   m_Radius=radius;
00030 }
00031 
00032 THIS::~THIS() {
00033 }
00034 
00035 double THIS::x() const{
00036   return m_Center.x();
00037 }
00038 
00039 double THIS::y() const{
00040   return m_Center.y();
00041 }
00042 
00043 double THIS::radius() const
00044 {
00045   return m_Radius;
00046 }
00047 
00048 Point2D THIS::center() const
00049 {
00050   return m_Center;
00051 }
00052 
00053 void THIS::setX(double x) {
00054   m_Center.setX(x);
00055 }
00056 
00057 void THIS::setY(double y) {
00058   m_Center.setY(y);
00059 }
00060 
00061 void THIS::setCenter( Point2D center )
00062 {
00063   m_Center=center;
00064 }
00065 
00066 void THIS::setRadius( double radius )
00067 {
00068   m_Radius=radius;
00069 }
00070 
00071 
00072 vector<Point2D> THIS::vertices( int steps )
00073 {
00074   vector<Point2D> myVertices;
00075   myVertices.reserve( steps+1 );
00076   for( float alpha=0.0; alpha<M_PI*2; alpha+=M_PI*2/float(steps) ) {
00077     myVertices.push_back( m_Center + CVec2( sin(alpha)*m_Radius, cos(alpha)*m_Radius ) );
00078   }
00079   myVertices.push_back( m_Center + CVec2( sin(M_PI*2)*m_Radius, cos(M_PI*2)*m_Radius ) );
00080   return myVertices;
00081 }
00082 
00083 
00084 #undef THIS


robbie_architecture
Author(s): Viktor Seib
autogenerated on Mon Oct 6 2014 02:53:09