OSDN Git Service

2.102.3-SNAPSHOT 開発開始
[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  * <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(0.0, 0.0, 0.0);
27         return;
28     }
29
30     /**
31      * コンストラクタ。
32      * @param xPosArg X軸座標
33      * @param yPosArg Y軸座標
34      * @param zPosArg Z軸座標
35      */
36     public MkPos3D(double xPosArg, double yPosArg, double zPosArg){
37         this.xPos = xPosArg;
38         this.yPos = yPosArg;
39         this.zPos = zPosArg;
40         return;
41     }
42
43     /**
44      * X軸座標を返す。
45      * @return X軸座標
46      */
47     public double getXpos() {
48         return this.xPos;
49     }
50
51     /**
52      * Y軸座標を返す。
53      * @return Y軸座標
54      */
55     public double getYpos() {
56         return this.yPos;
57     }
58
59     /**
60      * Z軸座標を返す。
61      * @return Z軸座標
62      */
63     public double getZpos() {
64         return this.zPos;
65     }
66
67     /**
68      * X軸座標を設定する。
69      * @param xPosArg X軸座標
70      */
71     public void setXpos(double xPosArg){
72         this.xPos = xPosArg;
73         return;
74     }
75
76     /**
77      * Y軸座標を設定する。
78      * @param yPosArg Y軸座標
79      */
80     public void setYpos(double yPosArg){
81         this.yPos = yPosArg;
82         return;
83     }
84
85     /**
86      * Z軸座標を設定する。
87      * @param zPosArg Z軸座標
88      */
89     public void setZpos(double zPosArg){
90         this.zPos = zPosArg;
91         return;
92     }
93
94     /**
95      * 座標を設定する。
96      * @param xPosArg X軸座標
97      * @param yPosArg Y軸座標
98      * @param zPosArg Z軸座標
99      */
100     public void setPosition(double xPosArg, double yPosArg, double zPosArg){
101         this.xPos = xPosArg;
102         this.yPos = yPosArg;
103         this.zPos = zPosArg;
104         return;
105     }
106
107     /**
108      * この点が原点(0,0,0)か否か判定する。
109      * @return 原点ならtrue
110      */
111     public boolean isOriginPoint(){
112         if(this.xPos != 0.0) return false;
113         if(this.yPos != 0.0) return false;
114         if(this.zPos != 0.0) return false;
115         return true;
116     }
117
118     /**
119      * {@inheritDoc}
120      * @return {@inheritDoc}
121      */
122     @Override
123     public String toString(){
124         StringBuilder result = new StringBuilder();
125
126         result.append("x=").append(this.xPos);
127         result.append(" y=").append(this.yPos);
128         result.append(" z=").append(this.zPos);
129
130         return result.toString();
131     }
132
133 }