-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewPointRec.cpp
83 lines (75 loc) · 2.17 KB
/
ViewPointRec.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <cmath>
#include "ViewPointRec.h"
#include "Util.h"
/**********************************************************
*
* ViewPointRec
*
* parameters IN:
* int viewPlaneDist
* int rho
* int theta
* int phi
*
* return value : ViewPointRec *
*
*********************************************************/
ViewPointRec::ViewPointRec (int viewPlaneDist, int rho, int theta, int phi) {
this->viewPlaneDist = viewPlaneDist;
this->rho = rho;
this->theta = theta;
this->phi = phi;
}
/**********************************************************
*
* operator =
*
* parameters IN :
* const ViewPointRec & value
*
*********************************************************/
void ViewPointRec::operator = (const ViewPointRec & value)
{
this->viewPlaneDist = value.viewPlaneDist;
this->rho = value.rho;
this->theta = value.theta;
this->phi = value.phi;
}
/**********************************************************
*
* SetViewVariables
*
* parameters IN :
* MyMatrix & viewTransformation
*
*********************************************************/
void ViewPointRec::SetViewVariables (MyMatrix & viewTransformation) {
sinTheta = sin ( Util::InRadians (theta) );
cosTheta = cos ( Util::InRadians (theta) );
sinPhi = sin ( Util::InRadians (phi) );
cosPhi = cos ( Util::InRadians (phi) );
xView = rho * cosTheta * sinPhi;
yView = rho * sinTheta * sinPhi;
zView = rho * cosPhi;
SetViewTransformation (viewTransformation);
}
/**********************************************************
*
* SetViewTransformation
*
* parameters IN :
* MyMatrix & viewTransformation
*
*********************************************************/
void ViewPointRec::SetViewTransformation (MyMatrix & viewTransformation) {
viewTransformation.Identity();
viewTransformation[0][0] = -sinTheta;
viewTransformation[0][1] = -cosTheta * cosPhi;
viewTransformation[0][2] = -cosTheta * sinPhi;
viewTransformation[1][0] = cosTheta;
viewTransformation[1][1] = -sinTheta * cosPhi;
viewTransformation[1][2] = -sinTheta * sinPhi;
viewTransformation[2][1] = sinPhi;
viewTransformation[2][2] = -cosPhi;
viewTransformation[3][2] = rho;
}