-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRotation4d.java
51 lines (45 loc) · 1.48 KB
/
Rotation4d.java
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
//‰ñ“]î•ñ
public class Rotation4d {
public static void RotateXY(Point4d p, double angle) {
double r = Math.toRadians(angle);
double tmpX = p.getX()*Math.cos(r)-p.getY()*Math.sin(r);
double tmpY = p.getX()*Math.sin(r)+p.getY()*Math.cos(r);
p.setX(tmpX);
p.setY(tmpY);
}
public static void RotateXZ(Point4d p,double angle) {
double r = Math.toRadians(angle);
double tmpX = p.getX()*Math.cos(r)-p.getZ()*Math.sin(r);
double tmpZ = p.getX()*Math.sin(r)+p.getZ()*Math.cos(r);
p.setX(tmpX);
p.setZ(tmpZ);
}
public static void RotateXU(Point4d p,double angle) {
double r = Math.toRadians(angle);
double tmpX = p.getX()*Math.cos(r)-p.getU()*Math.sin(r);
double tmpU = p.getX()*Math.sin(r)+p.getU()*Math.cos(r);
p.setX(tmpX);
p.setU(tmpU);
}
public static void RotateYZ(Point4d p,double angle) {
double r = Math.toRadians(angle);
double tmpY = p.getY()*Math.cos(r)-p.getZ()*Math.sin(r);
double tmpZ = p.getY()*Math.sin(r)+p.getZ()*Math.cos(r);
p.setY(tmpY);
p.setZ(tmpZ);
}
public static void RotateYU(Point4d p,double angle) {
double r = Math.toRadians(angle);
double tmpY = p.getY()*Math.cos(r)-p.getU()*Math.sin(r);
double tmpU = p.getY()*Math.sin(r)+p.getU()*Math.cos(r);
p.setY(tmpY) ;
p.setU(tmpU);
}
public static void RotateZU(Point4d p,double angle) {
double r = Math.toRadians(angle);
double tmpZ= p.getZ()*Math.cos(r)-p.getU()*Math.sin(r);
double tmpU = p.getZ()*Math.sin(r)+p.getU()*Math.cos(r);
p.setZ(tmpZ);
p.setU(tmpU) ;
}
}