#include <GeometricalObjects.h>
Inheritance diagram for Arc:


Public Member Functions | |
| Arc () | |
| Arc (const Vector2D &c, const double r1, const double r2, const double a1, const double a2) | |
| ~Arc () | |
| 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_inner_radius () |
| double | get_outer_radius () |
| Vector2D | get_center () |
| double | get_start_angle () |
| double | get_end_angle () |
Protected Attributes | |
| Vector2D | center |
| double | inner_radius |
| double | outer_radius |
| double | start_angle |
| double | end_angle |
| Vector2D | last_drawn_center |
Private Member Functions | |
| bool | within_angle (const double a) |
Private Attributes | |
| double | mid_radiussqr |
|
|
Definition at line 276 of file GeometricalObjects.cc. References center, end_angle, infinity, inner_radius, last_drawn_center, mid_radiussqr, outer_radius, and start_angle. 00277 {
00278 center = Vector2D(0.0, 0.0);
00279 inner_radius = outer_radius = mid_radiussqr = 0.0;
00280 start_angle = -M_PI; end_angle = M_PI;
00281 last_drawn_center = Vector2D(-infinity,-infinity);
00282 // last_drawn_radius = 0.0;
00283 }
|
|
||||||||||||||||||||||||
|
Definition at line 285 of file GeometricalObjects.cc. References center, end_angle, inner_radius, last_drawn_center, mid_radiussqr, outer_radius, and start_angle. 00287 {
00288 last_drawn_center = center = c;
00289 inner_radius = r1;
00290 outer_radius = r2;
00291 mid_radiussqr = 0.25 * (r1 + r2) * (r1 + r2);
00292 start_angle = a1;
00293 end_angle = a2;
00294 }
|
|
|
Definition at line 137 of file GeometricalObjects.h. 00137 {}
|
|
|
Implements Shape. Definition at line 384 of file GeometricalObjects.cc. References center, ArenaWindow::draw_arc(), end_angle, Gui::get_arenawindow_p(), Gui::get_bg_gdk_colour_p(), inner_radius, last_drawn_center, outer_radius, start_angle, and the_gui. 00385 {
00386
00387 if( erase )
00388 the_gui.get_arenawindow_p()->draw_arc( last_drawn_center,
00389 inner_radius, outer_radius,
00390 start_angle, end_angle,
00391 *(the_gui.get_bg_gdk_colour_p()) );
00392 last_drawn_center = center;
00393
00394
00395 the_gui.get_arenawindow_p()->draw_arc( center,
00396 inner_radius, outer_radius,
00397 start_angle, end_angle,
00398 gdk_colour );
00399 }
|
Here is the call graph for this function:

|
|
Definition at line 149 of file GeometricalObjects.h. 00149 { return center; }
|
|
||||||||||||||||
|
Implements Shape. Definition at line 305 of file GeometricalObjects.cc. References center, dot(), lengthsqr(), max, vec2angle(), and within_angle(). 00306 {
00307 Vector2D d = center - pos;
00308 double speedsqr = lengthsqr(vel);
00309 if( speedsqr == 0.0 ) return infinity;
00310
00311 double c, r, t;
00312 double dt = dot(vel, d);
00313
00314 if( lengthsqr( d ) > mid_radiussqr )
00315 {
00316 // Outside circle
00317
00318 r = size + outer_radius;
00319 c = dt*dt + speedsqr * (r*r - lengthsqr(d));
00320 if( c < 0.0 || dt <= 0.0) return infinity;
00321 t = max( (dt - sqrt(c))/speedsqr, 0);
00322
00323 if( within_angle( vec2angle( vel * t - d ) ) )
00324 return t;
00325
00326 // Did hit the outer circle, but not within the angles.
00327 // Can still hit inner circle.
00328 }
00329
00330
00331
00332 // Test inner circle
00333
00334 r = size - inner_radius;
00335
00336 c = dt*dt + speedsqr*( r*r - lengthsqr(d) );
00337 if( c < 0.0 ) return infinity; // Can happen if object outside circle
00338
00339 t = max( (dt + sqrt(c))/speedsqr, 0 );
00340
00341 if( !within_angle( vec2angle( vel * t - d ) ) )
00342 return infinity;
00343
00344
00345 return t;
00346 }
|
Here is the call graph for this function:

|
|
Definition at line 152 of file GeometricalObjects.h. 00152 { return end_angle; }
|
|
|
Definition at line 147 of file GeometricalObjects.h. 00147 { return inner_radius; }
|
|
|
Implements Shape. Definition at line 371 of file GeometricalObjects.cc. References center, lengthsqr(), and unit(). 00372 {
00373 Vector2D d = center - pos;
00374
00375 if( lengthsqr( d ) < mid_radiussqr )
00376 return unit( d );
00377 else
00378 return unit( -d );
00379 }
|
Here is the call graph for this function:

|
|
Definition at line 148 of file GeometricalObjects.h. 00148 { return outer_radius; }
|
|
|
Definition at line 151 of file GeometricalObjects.h. 00151 { return start_angle; }
|
|
|
Definition at line 362 of file GeometricalObjects.cc. References start_angle. Referenced by get_distance(), and within_distance(). 00363 {
00364 if( start_angle <= end_angle )
00365 return ( a >= start_angle && a <= end_angle );
00366 else
00367 return ( a >= start_angle || a <= end_angle );
00368 }
|
|
||||||||||||
|
Implements Shape. Definition at line 349 of file GeometricalObjects.cc. References lengthsqr(), vec2angle(), and within_angle(). 00350 {
00351 Vector2D d = pos - center;
00352 double l = lengthsqr( d );
00353
00354 return( l <= (size + outer_radius)*(size + outer_radius) &&
00355 ( l >= (size - inner_radius)*(size - inner_radius) || size >= inner_radius ) &&
00356 within_angle( vec2angle( d ) ) );
00357 }
|
Here is the call graph for this function:

|
|
Definition at line 156 of file GeometricalObjects.h. Referenced by Arc(), draw_shape(), get_distance(), and get_normal(). |
|
|
Definition at line 162 of file GeometricalObjects.h. Referenced by Arc(), and draw_shape(). |
|
|
Definition at line 157 of file GeometricalObjects.h. Referenced by Arc(), and draw_shape(). |
|
|
Definition at line 164 of file GeometricalObjects.h. Referenced by Arc(), and draw_shape(). |
|
|
Definition at line 170 of file GeometricalObjects.h. Referenced by Arc(). |
|
|
Definition at line 158 of file GeometricalObjects.h. Referenced by Arc(), and draw_shape(). |
|
|
Definition at line 161 of file GeometricalObjects.h. Referenced by Arc(), draw_shape(), and within_angle(). |
1.3.9.1