OSDN Git Service

add strict unit test for math class.
[mikutoga/TogaGem.git] / src / main / java / jp / sfjp / mikutoga / math / MkPos3D.java
1 /*
2  * 3D position
3  *
4  * License : The MIT License
5  * Copyright(c) 2011 MikuToga Partners
6  */
7
8 package jp.sfjp.mikutoga.math;
9
10 /**
11  * 三次元位置情報。
12  *
13  * <p>直交座標を三つの倍精度値で表す。
14  *
15  * <p>具体的にはボーン位置やカメラターゲット位置など。
16  */
17 public strictfp class MkPos3D {
18
19     private double xPos;
20     private double yPos;
21     private double zPos;
22
23
24     /**
25      * コンストラクタ。
26      */
27     public MkPos3D(){
28         this(0.0, 0.0, 0.0);
29         return;
30     }
31
32     /**
33      * コンストラクタ。
34      *
35      * @param xPosArg X軸座標
36      * @param yPosArg Y軸座標
37      * @param zPosArg Z軸座標
38      */
39     public MkPos3D(double xPosArg, double yPosArg, double zPosArg){
40         this.xPos = xPosArg;
41         this.yPos = yPosArg;
42         this.zPos = zPosArg;
43         return;
44     }
45
46     /**
47      * X軸座標を返す。
48      *
49      * @return X軸座標
50      */
51     public double getXpos() {
52         return this.xPos;
53     }
54
55     /**
56      * Y軸座標を返す。
57      *
58      * @return Y軸座標
59      */
60     public double getYpos() {
61         return this.yPos;
62     }
63
64     /**
65      * Z軸座標を返す。
66      *
67      * @return Z軸座標
68      */
69     public double getZpos() {
70         return this.zPos;
71     }
72
73     /**
74      * X軸座標を設定する。
75      *
76      * @param xPosArg X軸座標
77      */
78     public void setXpos(double xPosArg){
79         this.xPos = xPosArg;
80         return;
81     }
82
83     /**
84      * Y軸座標を設定する。
85      *
86      * @param yPosArg Y軸座標
87      */
88     public void setYpos(double yPosArg){
89         this.yPos = yPosArg;
90         return;
91     }
92
93     /**
94      * Z軸座標を設定する。
95      *
96      * @param zPosArg Z軸座標
97      */
98     public void setZpos(double zPosArg){
99         this.zPos = zPosArg;
100         return;
101     }
102
103     /**
104      * 座標を設定する。
105      *
106      * @param xPosArg X軸座標
107      * @param yPosArg Y軸座標
108      * @param zPosArg Z軸座標
109      */
110     public void setPosition(double xPosArg, double yPosArg, double zPosArg){
111         this.xPos = xPosArg;
112         this.yPos = yPosArg;
113         this.zPos = zPosArg;
114         return;
115     }
116
117     /**
118      * この点が原点(0,0,0)か否か判定する。
119      *
120      * @return 原点ならtrue
121      */
122     public boolean isOriginPoint(){
123         boolean result =
124                 this.xPos == 0.0 && this.yPos == 0.0 && this.zPos == 0.0;
125         return result;
126     }
127
128     /**
129      * {@inheritDoc}
130      * @return {@inheritDoc}
131      */
132     @Override
133     public String toString(){
134         StringBuilder result = new StringBuilder();
135
136         result.append("x=").append(this.xPos);
137         result.append(" y=").append(this.yPos);
138         result.append(" z=").append(this.zPos);
139
140         return result.toString();
141     }
142
143 }