OSDN Git Service

オペレーションミス
[mikutoga/TogaGem.git] / src / main / java / jp / sourceforge / mikutoga / pmd / RigidShape.java
1 /*
2  * rigid shape information
3  *
4  * License : The MIT License
5  * Copyright(c) 2010 MikuToga Partners
6  */
7
8 package jp.sourceforge.mikutoga.pmd;
9
10 /**
11  * 剛体形状に関する情報。
12  * 球及びカプセルの半径と箱の幅は同じ値が用いられる。
13  */
14 public class RigidShape {
15
16     private RigidShapeType type = RigidShapeType.BOX;
17     private float width  = 0.1f;
18     private float height = 0.1f;
19     private float depth  = 0.1f;
20
21     /**
22      * コンストラクタ。
23      */
24     public RigidShape(){
25         super();
26         return;
27     }
28
29     /**
30      * 剛体形状種別を返す。
31      * @return 剛体形状種別
32      */
33     public RigidShapeType getShapeType(){
34         return this.type;
35     }
36
37     /**
38      * 剛体形状種別を設定する。
39      * @param typeArg 剛体形状種別
40      * @throws NullPointerException 引数がnull
41      */
42     public void setShapeType(RigidShapeType typeArg)
43             throws NullPointerException{
44         if(typeArg == null) throw new NullPointerException();
45         this.type = typeArg;
46         return;
47     }
48
49     /**
50      * 箱の幅を返す。
51      * @return 箱の幅
52      */
53     public float getWidth(){
54         return this.width;
55     }
56
57     /**
58      * 箱の幅を設定する。
59      * @param width 箱の幅
60      */
61     public void setWidth(float width){
62         this.width = width;
63         return;
64     }
65
66     /**
67      * 箱及びカプセルの高さを返す。
68      * @return 箱及びカプセルの高さ
69      */
70     public float getHeight(){
71         return this.height;
72     }
73
74     /**
75      * 箱及びカプセルの高さを設定する。
76      * @param height 箱及びカプセルの高さ
77      */
78     public void setHeight(float height){
79         this.height = height;
80         return;
81     }
82
83     /**
84      * 箱の奥行きを返す。
85      * @return 箱の奥行き
86      */
87     public float getDepth(){
88         return this.depth;
89     }
90
91     /**
92      * 箱の奥行きを設定する。
93      * @param depth 箱の奥行き
94      */
95     public void setDepth(float depth){
96         this.depth = depth;
97         return;
98     }
99
100     /**
101      * 球及びカプセルの半径を返す。
102      * @return 球及びカプセルの半径
103      */
104     public float getRadius(){
105         return this.width;
106     }
107
108     /**
109      * 球及びカプセルの半径を設定する。
110      * @param radius 球及びカプセルの半径
111      */
112     public void setRadius(float radius){
113         this.width = radius;
114         return;
115     }
116
117     /**
118      * {@inheritDoc}
119      * @return {@inheritDoc}
120      */
121     @Override
122     public String toString(){
123         StringBuilder result = new StringBuilder();
124
125         result.append(this.type).append(' ');
126
127         switch(this.type){
128         case SPHERE:
129             result.append("r=").append(this.width);
130             break;
131         case BOX:
132             result.append("w=").append(this.width).append(", ");
133             result.append("h=").append(this.height).append(", ");
134             result.append("d=").append(this.depth);
135             break;
136         case CAPSULE:
137             result.append("r=").append(this.width).append(", ");
138             result.append("h=").append(this.height);
139             break;
140         default:
141             assert false;
142             throw new AssertionError();
143         }
144
145         return  result.toString();
146     }
147
148 }