OSDN Git Service

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