| 1 |
$#include "tfunction.h" |
| 2 |
|
| 3 |
typedef enum { |
| 4 |
FIRST = 1, |
| 5 |
SECOND = 2 |
| 6 |
} Order; |
| 7 |
|
| 8 |
class Point |
| 9 |
{ |
| 10 |
enum Error { |
| 11 |
SUCCESS = 0, |
| 12 |
ERROR = 1 |
| 13 |
}; |
| 14 |
|
| 15 |
Point (float x=0, float y=0); |
| 16 |
virtual ~Point (); |
| 17 |
|
| 18 |
void set (float x, float y); |
| 19 |
void set (float v[2]=0); |
| 20 |
void setpointer (Point* p); |
| 21 |
void setref (Point& p); |
| 22 |
void setvalue (Point p); |
| 23 |
void setconst (const Point* p); |
| 24 |
void setname (const char* s); |
| 25 |
|
| 26 |
void get (float* x=0, float* y=0) const; |
| 27 |
void get (float v[2]=0) const; |
| 28 |
Point* getpointer (); |
| 29 |
Point& getref (); |
| 30 |
Point getvalue (); |
| 31 |
const Point* getconst () const; |
| 32 |
const char* getname () const; |
| 33 |
|
| 34 |
Point operator+ (const Point& p) const; |
| 35 |
Point operator- (const Point& p) const; |
| 36 |
Point operator* (const Point& p) const; |
| 37 |
Point operator/ (float n) const; |
| 38 |
bool operator< (const Point& p) const; |
| 39 |
bool operator<= (const Point& p) const; |
| 40 |
bool operator== (const Point& p) const; |
| 41 |
|
| 42 |
float operator[] (int i) const; |
| 43 |
float& operator[] (int i); |
| 44 |
|
| 45 |
static Error echo (Error e); |
| 46 |
}; |
| 47 |
|
| 48 |
module alg |
| 49 |
{ |
| 50 |
Point add (const Point& p1, const Point& p2); |
| 51 |
Point sub (const Point& p1, const Point& p2); |
| 52 |
Point mult (const Point& p1, const Point& p2); |
| 53 |
Point div (const Point& p1, float n); |
| 54 |
} |
| 55 |
|
| 56 |
void getpoint (const Point* p, float* x=0, float* y=0); |
| 57 |
void setpoint (Point* p, float x=0, float y=0); |
| 58 |
inline Point average (int n, Point v[n]); |
| 59 |
inline Point averagepointer (int n, Point* v[n]); |
| 60 |
inline void copyvector (int n, const Point v[n], Point u[n]=(u+i)); |
| 61 |
|
| 62 |
inline Order invert (Order o); |
| 63 |
|
| 64 |
$cfile "tfunction.h" |
| 65 |
|
| 66 |
/* |
| 67 |
class ColorPoint : public Point |
| 68 |
{ |
| 69 |
ColorPoint (float px, float py, float cr=0.0f, float cg=0.0f, float cb=0.0f); |
| 70 |
virtual ~ColorPoint (); |
| 71 |
virtual void getcolor (float* red, float *green, float *blue) const; |
| 72 |
static const Point* MakeRed (float x, float y); |
| 73 |
}; |
| 74 |
*/ |