-
Notifications
You must be signed in to change notification settings - Fork 0
/
Uponto.cpp
60 lines (48 loc) · 1.21 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
//---------------------------------------------------------------------------
#pragma hdrstop
#include "Uponto.h"
#include <Vcl.ExtCtrls.hpp>
//---------------------------------------------------------------------------
Ponto::Ponto(){
x = y =z = 0;
}
Ponto::Ponto(double nx, double ny){
x = nx;
y = ny;
z = 0;
}
Ponto::Ponto(double nx, double ny, double nz){
x = nx;
y = ny;
z = nz;
}
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.yMax - vp.yMin));
}
AnsiString Ponto::mostraPonto(){
return "(" + FloatToStr(x) + " ; " + FloatToStr(y) + " ; " + FloatToStr(z) + ")";
}
void Ponto::translacao(double dx, double dy){
x += dx;
y += dy;
}
void Ponto::reflexao(double dx, double dy){
x = x * dx;
y = y * dy;
}
void Ponto::escalonamento(double escalonador){
x = x * escalonador;
y = y * escalonador;
}
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;
}