OSDN Git Service

first
[psychlops/cpp.git] / psychlops / core / graphic / psychlops_g_fundamental.h
1 /*
2  *  psychlops_g_fundamental.h
3  *  Psychlops Standard Library (Universal)
4  *
5  *  Last Modified 2005/10/05 by Kenchi HOSOKAWA
6  *  (C) 2005 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO
7  */
8
9 #ifndef HEADER_PSYCHLOPS_GRAPHIC_FUNDAMENTAL
10 #define HEADER_PSYCHLOPS_GRAPHIC_FUNDAMENTAL
11
12
13
14 namespace Psychlops {
15
16         class Rectangle;
17         class Canvas;
18         class Image;\r
19         class Figure;
20
21
22         class Point {
23                 friend class Figure;
24                 friend class Drawable;
25                 friend class Image;
26
27                 private:
28                 inline void setbypix(const double ix, const double iy, const double iz) { x = ix; y = iy; z = iz; }
29                 public:
30                 double x,y,z;
31                 inline Point() : x(0.0), y(0.0), z(0.0) {}
32                 inline Point(const double ix, const double iy, const double iz = 0) : x(ix), y(iy), z(iz) {}
33                 inline Point& set(const double ix, const double iy, const double iz = 0) { x = ix; y = iy; z = iz; return *this; }
34                 inline Point& shift(const double h, const double v, const double d = 0) { x+=h; y+=v; z+=d; return *this; }
35                 Point& centering();
36                 Point& centering(const Figure& fig);
37                 inline Point& centering(const double h, const double v, const double d = 0) { x=h; y=v; z=d; return *this; }
38                 inline Point& setX(const double val) { x = val; return *this; }
39                 inline Point& setY(const double val) { y = val; return *this; }
40                 inline Point& setZ(const double val) { z = val; return *this; }
41                 inline double getX() const { return x; }
42                 inline double getY() const { return y; }
43                 inline double getZ() const { return z; }
44                 inline Point dup();
45                 inline Point operator+(const Point& rhs) { return Point(x+rhs.x, y+rhs.y, z+rhs.z); }
46                 inline Point operator-(const Point& rhs) { return Point(x-rhs.x, y-rhs.y, z-rhs.z); }\r
47                 double length() const;
48         };
49
50
51 }       /*      <- namespace Psychlops  */
52
53
54
55
56
57
58
59
60
61
62 namespace Psychlops {
63         //  Listings of Classes in this file
64         class Length;
65         class Angle;
66
67         //  Listings of Graphics standard classes
68         class Color;
69         class Point;
70         class Rectangle;
71
72         class Drawable;
73         class Canvas;
74         class Display;
75         class Image;
76         class Stroke;
77
78         class Length {
79                 private:
80                 double px_;
81
82                 public:
83                 Length();
84                 Length(const int val);
85                 Length(const double val);
86                 Length(const Length &val);
87                 operator double() const;
88                 Length & operator =(const double val);
89         };
90         class LENGTH_ARCDEG {
91         };
92         extern LENGTH_ARCDEG arcdeg;
93         Length operator *(double arcdeg, LENGTH_ARCDEG &unit);
94         class LENGTH_PIXEL {
95         };
96         extern LENGTH_PIXEL pixel;
97         Length operator *(double arcdeg, LENGTH_PIXEL &unit);
98
99
100
101         class ANGLE_DEGREE {
102         };
103         extern ANGLE_DEGREE degree;
104         Angle operator *(double degrees, ANGLE_DEGREE &unit);
105         class ANGLE_RADIAN {
106         };
107         extern ANGLE_RADIAN radian;
108         Angle operator *(double radian, ANGLE_RADIAN &unit);
109
110         class Angle {
111                 protected:
112                 static const double PERIOD;
113                 static const double HALF_PERIOD;
114                 static const double SCALE_TO_DEGREE;
115                 double decadegree_;
116                 Angle(double decadegrees, int dummy);
117
118                 public:
119                 Angle();
120                 Angle(int degrees);
121                 Angle(const double degrees);
122                 Angle(const double degrees, ANGLE_DEGREE &unit);
123                 Angle(const double radians, ANGLE_RADIAN &unit);
124                 Angle(const Angle &init);
125                 operator double() const;
126                 Angle operator =(const double val);
127                 Angle operator +(Angle rhs) const;
128                 Angle operator -(Angle rhs) const;
129                 Angle & operator +=(Angle rhs);
130                 Angle & operator -=(Angle rhs);
131                 double clip() const;
132                 double at_degree() const;
133                 double at_radian() const;
134                 double sin() const;
135                 double cos() const;
136                 double tan() const;
137                 void set_as_degree(double degrees);
138                 void set_as_decadegree(double decadegree);
139                 void set_as_radian(double radians);
140         };
141
142
143 }       /*      <- namespace Psycholops         */
144
145
146 #endif