1 #ifndef _arcs_h
2 #define _arcs_h
3 
4 //
5 // In dem Modul 'arcs.h' sind alle Klassen vereint, die mit B�llen und B�gen
6 // zu tun haben. Dabei gelten die folgenden Ableitungen
7 //
8 //			   StaticArc			: Grundfunktionalit�t
9 //         /         \
10 //		 OuterArc	 InnerArc	: Bogen, der von au�en/innen reflektiert
11 //        |       \   |
12 //		    |       ArcWall	 	: beidseitig reflektierend (Ableitung nur symbolisch)
13 //		StaticBall					: 360 Grad Bogen, nicht beweglich
14 //******* | **************************************************************
15 //		  Ball						: Kugel (gleichzeitig ein DynObj)
16 //    (-->ball.c)
17 //
18 
19 #ifndef _object_h
20 #	include "object.h"		// Oberklasse
21 #endif
22 #ifndef _vec2_h
23 #	include "vec2.h"		// Member-Klasse
24 #endif
25 
26 
27 //
28 // -------------------------------------------------------------------------
29 //   class StaticArc:  Bogen (analog zu Wall)
30 // -------------------------------------------------------------------------
31 //
32 
33 class StaticArc : public Object {
34 	protected:
35 		Vec2	p;			// Mittelpunkt des Bogens, bzw. Position der Kugel
36 		Real		r;			// Radius der Kugel
37 
38 	public:
39 		StaticArc( double x, double y, double r, double start=0.0, double angle=360.0 );
40 		StaticArc( const Vec2 &v, const Real &r, const Real &start, const Real &angle );
41 
42 		virtual ~StaticArc();
43 
44 		virtual void Info();
45 
P()46 		const Vec2 &P() const				{ return p; }
PX()47 		const Real   &PX() const			{ return p.X(); }
PY()48 		const Real   &PY() const			{ return p.Y(); }
R()49 		const	Real   &R() const				{ return r; }
50 
51 	protected:
52 		virtual Real HitFromBall( Ball *b ) = 0;
53 		virtual void CollideWithBall( Ball *b );
54 
55 
56 		int IsOnArc( const Vec2 &d );
57 
58 		Real OuterHitFromBall( Ball *b, const Vec2 &dv );
59 		Real InnerHitFromBall( Ball *b, const Vec2 &dv );
60 		Real		start;
61 		Real		angle;
62 
63 	private:
64 		int HitFromBallTwice( int outer_hit, Ball *b, const Vec2 &dv, Real md,
65 													Real *time );
66 
67 friend class Pocket;
68 friend class Pool;
69 };
70 
71 
72 //
73 // -------------------------------------------------------------------------
74 //   class StaticArc:  Bogen (analog zu Wall)
75 // -------------------------------------------------------------------------
76 //
77 
78 class OuterArc : public StaticArc {
79 	public:
OuterArc(double x,double y,double ri,double st,double ang)80 		OuterArc( double x, double y, double ri, double st, double ang ) :
81 			StaticArc( x, y, ri, st, ang )		{}
OuterArc(const Vec2 & v,const Real & ri,const Real & st,const Real & ang)82 		OuterArc( const Vec2 &v, const Real &ri, const Real &st, const Real &ang ) :
83 			StaticArc( v, ri, st, ang )			{}
84 		virtual ~OuterArc();
85 
86 		virtual void Info();
87 
88 	protected:
89 		virtual Real HitFromBall( Ball *b );
90 
91 	private:
92 };
93 
94 
95 class InnerArc : public StaticArc {
96 	public:
InnerArc(double x,double y,double ri,double st,double ang)97 		InnerArc( double x, double y, double ri, double st, double ang ) :
98 			StaticArc( x, y, ri, st, ang )		{}
InnerArc(const Vec2 & v,const Real & ri,const Real & st,const Real & ang)99 		InnerArc( const Vec2 &v, const Real &ri, const Real &st, const Real &ang ) :
100 			StaticArc( v, ri, st, ang )			{}
101 		virtual ~InnerArc();
102 
103 		virtual void Info();
104 
105 	protected:
106 		virtual Real HitFromBall( Ball *b );
107 
108 	private:
109 };
110 
111 
112 
113 class ArcWall : public StaticArc {
114 	public:
ArcWall(double x,double y,double ri,double st,double ang)115 		ArcWall( double x, double y, double ri, double st, double ang )
116 			:	StaticArc( x,y,ri, st, ang )											{ }
117 		virtual ~ArcWall();
118 
119 		virtual void Info();
120 
121 	protected:
122 		virtual Real HitFromBall( Ball *b );
123 };
124 
125 //
126 // -------------------------------------------------------------------------
127 //   class Static Ball:  Statische Kugel
128 // -------------------------------------------------------------------------
129 //
130 
131 class StaticBall : public OuterArc {
132 	public:
133 		StaticBall( double x, double y, double ri=2. )
134 			: OuterArc( x,y,ri,0.0,360.0 )			{ type=StaticBallObj; }
StaticBall(const Vec2 & v,const Real & ri)135 		StaticBall( const Vec2 &v, const Real &ri )
136 			: OuterArc( v,ri,0.0,360.0 )			{ type=StaticBallObj; }
137 
138 		virtual ~StaticBall();
139 
140 		virtual void Info();
141 
142 	protected:
143 
144 friend class Pocket;
145 friend class Goal;
146 };
147 
148 
149 #endif
150