OSDN Git Service

パッケージ変更。テスト整備。
[mikutoga/TogaGem.git] / src / main / java / jp / sfjp / 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.sfjp.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 xRotArg X軸回転量。(ラジアン)
73      */
74     public void setXRot(double xRotArg){
75         this.xRot = xRotArg;
76         return;
77     }
78
79     /**
80      * Y軸回転量を設定する。
81      * @param yRotArg Y軸回転量。(ラジアン)
82      */
83     public void setYRot(double yRotArg){
84         this.yRot = yRotArg;
85         return;
86     }
87
88     /**
89      * Z軸回転量を設定する。
90      * @param zRotArg Z軸回転量。(ラジアン)
91      */
92     public void setZRot(double zRotArg){
93         this.zRot = zRotArg;
94         return;
95     }
96
97     /**
98      * 三軸の回転量を設定する。
99      * @param xRotArg X軸回転量。(ラジアン)
100      * @param yRotArg Y軸回転量。(ラジアン)
101      * @param zRotArg Z軸回転量。(ラジアン)
102      */
103     public void setRot(double xRotArg, double yRotArg, double zRotArg){
104         this.xRot = xRotArg;
105         this.yRot = yRotArg;
106         this.zRot = zRotArg;
107         return;
108     }
109
110     /**
111      * パラメータ情報の文字列化。
112      * @param x x値
113      * @param y y値
114      * @param z z値
115      * @return 文字列
116      */
117     private static String toString(double x, double y, double z){
118         StringBuilder result = new StringBuilder();
119
120         result.append("x=") .append(x);
121         result.append(" y=").append(y);
122         result.append(" z=").append(z);
123
124         return result.toString();
125     }
126
127     /**
128      * {@inheritDoc}
129      * @return {@inheritDoc}
130      */
131     @Override
132     public String toString(){
133         String result;
134         result = toString(this.xRot, this.yRot, this.zRot);
135         return result;
136     }
137
138     /**
139      * 度数法による文字列表現を返す。
140      * @return 文字列表現
141      */
142     public String toDegString(){
143         double xDeg = StrictMath.toDegrees(this.xRot);
144         double yDeg = StrictMath.toDegrees(this.yRot);
145         double zDeg = StrictMath.toDegrees(this.zRot);
146
147         String result;
148         result = toString(xDeg, yDeg, zDeg);
149         return result;
150     }
151
152 }