OSDN Git Service

2cece8775ca81ca43d0cea18ac3f27c845c02f2b
[mikutoga/TogaGem.git] / src / main / java / jp / sourceforge / mikutoga / math / EulerYXZ.java
1 /*
2  * YXZ Euler rotation
3  *
4  * License : The MIT License
5  * Copyright(c) 2011 MikuToga Partners
6  */
7
8 package jp.sourceforge.mikutoga.math;
9
10 /**
11  * YXZオイラー角。
12  * 三次元空間での方向及び姿勢を定義する。
13  * <p>回転量はラジアンで表される。
14  * <p>※XYZオイラー角ではない。
15  */
16 public strictfp class EulerYXZ {
17
18     private double xRot;
19     private double yRot;
20     private double zRot;
21
22
23     /**
24      * コンストラクタ。
25      * <p>三軸とも回転量0の状態になる。
26      */
27     public EulerYXZ(){
28         this(0.0, 0.0, 0.0);
29         return;
30     }
31
32     /**
33      * コンストラクタ。
34      * @param xRot X軸回転量。(ラジアン)
35      * @param yRot Y軸回転量。(ラジアン)
36      * @param zRot Z軸回転量。(ラジアン)
37      */
38     public EulerYXZ(double xRot, double yRot, double zRot){
39         super();
40         this.xRot = xRot;
41         this.yRot = yRot;
42         this.zRot = zRot;
43         return;
44     }
45
46     /**
47      * X軸回転量を返す。
48      * @return X軸回転量を返す。(ラジアン)
49      */
50     public double getXRot(){
51         return this.xRot;
52     }
53
54     /**
55      * Y軸回転量を返す。
56      * @return Y軸回転量を返す。(ラジアン)
57      */
58     public double getYRot(){
59         return this.yRot;
60     }
61
62     /**
63      * Z軸回転量を返す。
64      * @return Z軸回転量を返す。(ラジアン)
65      */
66     public double getZRot(){
67         return this.zRot;
68     }
69
70     /**
71      * X軸回転量を設定する。
72      * @param xRot X軸回転量。(ラジアン)
73      */
74     public void setXRot(double xRot){
75         this.xRot = xRot;
76         return;
77     }
78
79     /**
80      * Y軸回転量を設定する。
81      * @param yRot Y軸回転量。(ラジアン)
82      */
83     public void setYRot(double yRot){
84         this.yRot = yRot;
85         return;
86     }
87
88     /**
89      * Z軸回転量を設定する。
90      * @param zRot Z軸回転量。(ラジアン)
91      */
92     public void setZRot(double zRot){
93         this.zRot = zRot;
94         return;
95     }
96
97     /**
98      * {@inheritDoc}
99      * @return {@inheritDoc}
100      */
101     @Override
102     public String toString(){
103         StringBuilder result = new StringBuilder();
104
105         result.append("x=") .append(this.xRot);
106         result.append(" y=").append(this.yRot);
107         result.append(" z=").append(this.zRot);
108
109         return result.toString();
110     }
111
112     /**
113      * 度数法による文字列表現を返す。
114      * @return 文字列表現
115      */
116     public String toDegString(){
117         StringBuilder result = new StringBuilder();
118
119         result.append("x=") .append(StrictMath.toDegrees(this.xRot));
120         result.append(" y=").append(StrictMath.toDegrees(this.yRot));
121         result.append(" z=").append(StrictMath.toDegrees(this.zRot));
122
123         return result.toString();
124     }
125
126 }