-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathPoint.cpp
42 lines (33 loc) · 1.09 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
#ifdef BL_USE_NEW_HFILES
#include <cmath>
#else
#include <math.h>
#endif
#include "Point.H"
Real scale = 1.;
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.) { x = y = z = 0.; return; }
m = sqrt(m);
x = X/m; y = Y/m; z = Z/m;
}
AmrSpherePoint::AmrSpherePoint(const AmrVector &v) {
Real m = v.x*v.x + v.y*v.y + v.z*v.z;
if (m==0.) { x = y = z = 0.; return; }
m = sqrt(m);
x = v.x/m; y = v.y/m; z = v.z/m;
}
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);
}