OSDN Git Service

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