-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEulerAngle.java
More file actions
38 lines (34 loc) · 1.06 KB
/
EulerAngle.java
File metadata and controls
38 lines (34 loc) · 1.06 KB
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
//all rotations using euler angles are intrinsic and applied in order y-x-z.
public class EulerAngle
{
//because there are no non-valid values for the x y and z components
//as well as the fact that these components are primitives and have no need
//for having changing restrictions (like to avoid null pointers), using public
//has no impact on code.
public double y; //yaw
public double x; //pitch
public double z; //roll
//no-arg constructor default 0, 0, 0
public EulerAngle()
{
x = 0;
y = 0;
z = 0;
}
public EulerAngle(double xIn, double yIn, double zIn)
{
x = xIn;
y = yIn;
z = zIn;
}
//formats into string, similar to Vector3s
public String toString()
{
return new String(String.format("[%.2f, %.2f, %.2f]", x, y, z));
}
//pubtracts two euler angles angle1-angle2
public static EulerAngle subtract(EulerAngle angle1, EulerAngle angle2)
{
return new EulerAngle(angle1.x-angle2.x, angle1.y-angle2.y, angle1.z-angle2.z);
}
}