5 Linha::Linha(double x1
,double y1
,double x2
, double y2
) {
12 Rect::Rect(double x1
,double y1
,double x2
, double y2
) {
20 void Rect::normaliza() {
21 double xmin
,xmax
,ymin
,ymax
;
22 xmin
= std::min(vertices
[0].x
,vertices
[1].x
);
23 xmax
= std::max(vertices
[0].x
,vertices
[1].x
);
24 ymin
= std::min(vertices
[0].y
,vertices
[1].y
);
25 ymax
= std::max(vertices
[0].y
,vertices
[1].y
);
32 void Linha::desenha() {
35 glVertex3f(vertices
[0].x
, vertices
[0].y
, 0.0f
); // origin of the line
36 glVertex3f(vertices
[1].x
, vertices
[1].y
, 0.0f
); // origin of the line
40 void Polygon::desenha() {
41 int n
= linhas
.size();
42 for (int i
= 0; i
< n
; i
++) {
47 double operator*(const Ponto
&a
, const Ponto
&b
) {
48 return a
.x
* b
.y
- b
.x
* a
.y
;
51 Ponto
operator-(const Ponto
&a
, const Ponto
&b
) {
58 Ponto
operator+(const Ponto
&a
, const Ponto
&b
) {
65 double distance(const Ponto
&a
,const Ponto
&b
) {
66 return sqrt((a
.x
-b
.x
)*(a
.x
-b
.x
)+(a
.y
-b
.y
)*(a
.y
-b
.y
));
69 void drawCircle(double radius
, int lines
)
71 double i2rad
= PI
/(lines
/2.0);
72 glBegin(GL_LINE_LOOP
);
73 for (int i
=0; i
< lines
; i
++) {
74 double degInRad
= i
*i2rad
;
75 glVertex2f(cos(degInRad
)*radius
,sin(degInRad
)*radius
);