-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathPoint.cpp
73 lines (57 loc) · 1.93 KB
/
Point.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
// ---------------------------------------------------------------
// Point.cpp
// ---------------------------------------------------------------
#include <cstdlib>
#include <cmath>
#include <Point.H>
Real scale = 1.0;
// ---------------------------------------------------------------
AmrVector::AmrVector(Real X, Real Y, Real Z)
: x(X), y(Y), z(Z)
{
}
// ---------------------------------------------------------------
AmrVector::AmrVector(const AmrSpherePoint &S)
: x(S.x), y(S.y), z(S.z)
{
}
// ---------------------------------------------------------------
AmrSpherePoint::AmrSpherePoint(Real X, Real Y, Real Z) {
Real m(X * X + Y * Y + Z * Z);
if(m == 0.0) {
x = y = z = 0.0;
return;
}
Real oneOverSqrtM(1.0 / sqrt(m));
x = X * oneOverSqrtM;
y = Y * oneOverSqrtM;
z = Z * oneOverSqrtM;
}
// ---------------------------------------------------------------
AmrSpherePoint::AmrSpherePoint(const AmrVector &v) {
Real m(v.x * v.x + v.y * v.y + v.z * v.z);
if(m == 0.0) {
x = y = z = 0.0;
return;
}
Real oneOverSqrtM(1.0 / sqrt(m));
x = v.x * oneOverSqrtM;
y = v.y * oneOverSqrtM;
z = v.z * oneOverSqrtM;
}
// ---------------------------------------------------------------
AmrVector AmrVector::applyMatrix(Real m[4][4]) {
Real X(x * m[0][0] + m[1][0] * y + z * m[2][0]);
Real Y(x * m[0][1] + m[1][1] * y + z * m[2][1]);
Real Z(x * m[0][2] + m[1][2] * y + z * m[2][2]);
return AmrVector(X, Y, Z);
}
// ---------------------------------------------------------------
AmrSpherePoint AmrSpherePoint::applyMatrix(Real m[4][4]) {
Real X(x * m[0][0] + m[1][0] * y + z * m[2][0]);
Real Y(x * m[0][1] + m[1][1] * y + z * m[2][1]);
Real Z(x * m[0][2] + m[1][2] * y + z * m[2][2]);
return AmrSpherePoint(X, Y, Z);
}
// ---------------------------------------------------------------
// ---------------------------------------------------------------