-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuPonto.cpp
65 lines (49 loc) · 1.34 KB
/
uPonto.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//---------------------------------------------------------------------------
#pragma hdrstop
#include "uPonto.h"
#include <math.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
Ponto::Ponto(){
x = y = z = 0;
}
Ponto::Ponto(double xN, double yN){
x = xN;
y = yN;
}
Ponto::Ponto(double xN, double yN, double zN){
x = xN;
y = yN;
z = zN;
}
int Ponto::xw2vp(Janela mundo, Janela vp){
return((x - mundo.xMin) / (mundo.xMax - mundo.xMin)) *
(vp.xMax-vp.xMin);
}
int Ponto::yw2vp(Janela mundo,Janela vp){
return (1 - (y - mundo.yMin) / (mundo.yMax-mundo.yMin)) *
(vp.xMax-vp.xMin);
}
AnsiString Ponto::mostra(){
return "(" + FloatToStrF(x, ffFixed, 3, 3) + ", " + FloatToStrF(y, ffFixed, 3, 3) + ", " + FloatToStrF(z, ffFixed, 3, 3) + ")";
}
void Ponto::reflexoX (){
x *= -1;
}
void Ponto::reflexoY (){
y *= -1;
}
void Ponto::reflexoXY (){
reflexoX();
reflexoY();
}
//REGIONCODE CLIPPING
int Ponto::regionCode(Janela clip)
{
int cohen = 0;
cohen += (x < clip.xMin) ? 1 : 0;
cohen += (x > clip.xMax) ? 2 : 0;
cohen += (y < clip.yMin) ? 4 : 0;
cohen += (y > clip.yMax) ? 8 : 0;
return cohen;
}