Circle Class Reference

#include <GeometricalObjects.h>

Inheritance diagram for Circle:

Inheritance graph
[legend]
Collaboration diagram for Circle:

Collaboration graph
[legend]

Public Member Functions

 Circle ()
 Circle (const Vector2D &c, const double r)
 Circle (const Vector2D &c, const double r, const long int col)
 Circle (const Vector2D &c, const double r, const double b_c, const double hardn)
virtual ~Circle ()
double get_distance (const Vector2D &pos, const Vector2D &dir, const double size)
bool within_distance (const Vector2D &pos, const double size)
Vector2D get_normal (const Vector2D &pos)
void draw_shape (bool erase)
double get_radius ()
Vector2D get_center ()

Protected Attributes

Vector2D center
double radius
Vector2D last_drawn_center
double last_drawn_radius

Constructor & Destructor Documentation

Circle::Circle  ) 
 

Definition at line 134 of file GeometricalObjects.cc.

References center, infinity, last_drawn_center, last_drawn_radius, and radius.

00135 {
00136   center = Vector2D(0.0, 0.0);
00137   radius = 0.0;
00138   last_drawn_center = Vector2D(-infinity,-infinity);
00139   last_drawn_radius = 0.0;
00140 }

Circle::Circle const Vector2D c,
const double  r
 

Definition at line 142 of file GeometricalObjects.cc.

References center, last_drawn_center, last_drawn_radius, and radius.

00143 {
00144   last_drawn_center = center = c;
00145   last_drawn_radius = radius = r;
00146 }

Circle::Circle const Vector2D c,
const double  r,
const long int  col
 

Definition at line 148 of file GeometricalObjects.cc.

References center, last_drawn_center, last_drawn_radius, and radius.

00148                                                                     : Shape(col)
00149 {
00150   last_drawn_center = center = c;
00151   last_drawn_radius = radius = r;
00152 }

Circle::Circle const Vector2D c,
const double  r,
const double  b_c,
const double  hardn
 

virtual Circle::~Circle  )  [inline, virtual]
 

Definition at line 72 of file GeometricalObjects.h.

00072 {}


Member Function Documentation

void Circle::draw_shape bool  erase  )  [virtual]
 

Implements Shape.

Definition at line 190 of file GeometricalObjects.cc.

References center, ArenaWindow::draw_circle(), Gui::get_arenawindow_p(), Gui::get_bg_gdk_colour_p(), last_drawn_center, last_drawn_radius, radius, and the_gui.

Referenced by ArenaWindow::draw_moving_objects(), and Extras::Extras().

00191 {
00192   if( erase )
00193     the_gui.get_arenawindow_p()->draw_circle( last_drawn_center,
00194                                               last_drawn_radius,
00195                                               *(the_gui.get_bg_gdk_colour_p()),
00196                                               true );
00197   last_drawn_center = center;
00198   last_drawn_radius = radius;
00199   the_gui.get_arenawindow_p()->draw_circle( center, radius, gdk_colour, true );
00200 }

Here is the call graph for this function:

Vector2D Circle::get_center  )  [inline]
 

Definition at line 83 of file GeometricalObjects.h.

Referenced by Robot::get_messages(), Shot::move(), and Robot::move().

00083 { return center; }

double Circle::get_distance const Vector2D pos,
const Vector2D dir,
const double  size
[inline, virtual]
 

Implements Shape.

Definition at line 164 of file GeometricalObjects.cc.

References center, dot(), lengthsqr(), and max.

00165 {
00166   Vector2D y = center - pos;
00167   double speedsqr = lengthsqr(vel);
00168   double dt = dot(vel, y);
00169   double r = size+radius;
00170   double c = dt*dt + speedsqr * (r*r - lengthsqr(y));
00171   if( c < 0.0 || dt <= 0.0) return infinity;
00172   return max( (dt - sqrt(c))/speedsqr, 0);
00173 }

Here is the call graph for this function:

Vector2D Circle::get_normal const Vector2D pos  )  [virtual]
 

Implements Shape.

Definition at line 182 of file GeometricalObjects.cc.

References center, and unit().

00183 {
00184   return unit(pos - center);
00185 }

Here is the call graph for this function:

double Circle::get_radius  )  [inline]
 

Definition at line 82 of file GeometricalObjects.h.

00082 { return radius; }

bool Circle::within_distance const Vector2D pos,
const double  size
[virtual]
 

Implements Shape.

Definition at line 176 of file GeometricalObjects.cc.

References center, and lengthsqr().

00177 {
00178   return (lengthsqr(center-pos) <= (size+radius)*(size+radius));
00179 }

Here is the call graph for this function:


Field Documentation

Vector2D Circle::center [protected]
 

Definition at line 86 of file GeometricalObjects.h.

Referenced by bounce_on_robot(), Circle(), draw_shape(), get_distance(), get_normal(), shot_collision(), and within_distance().

Vector2D Circle::last_drawn_center [protected]
 

Definition at line 89 of file GeometricalObjects.h.

Referenced by Circle(), and draw_shape().

double Circle::last_drawn_radius [protected]
 

Definition at line 90 of file GeometricalObjects.h.

Referenced by Circle(), and draw_shape().

double Circle::radius [protected]
 

Definition at line 87 of file GeometricalObjects.h.

Referenced by Circle(), and draw_shape().


The documentation for this class was generated from the following files:
Generated on Fri Oct 15 15:49:42 2004 for Real Time Battle by  doxygen 1.3.9.1