summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/Point2.java
blob: 95a622fc65b7ad9cabb28fc810313dce45852d5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*     */ package NET.worlds.scape;
/*     */ 
/*     */ import java.io.IOException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class Point2
/*     */   implements Persister
/*     */ {
/*     */   public float x;
/*     */   public float y;
/*     */   
/*     */   public Point2() {}
/*     */   
/*     */   public Point2(float _x, float _y)
/*     */   {
/*  33 */     set(_x, _y);
/*     */   }
/*     */   
/*     */   public Point2(Point2 p)
/*     */   {
/*  38 */     this.x = p.x;
/*  39 */     this.y = p.y;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Point2 copy(Point2 b)
/*     */   {
/*  46 */     this.x = b.x;
/*  47 */     this.y = b.y;
/*  48 */     return this;
/*     */   }
/*     */   
/*     */   public void set(float _x, float _y) {
/*  52 */     this.x = _x;
/*  53 */     this.y = _y;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public float length()
/*     */   {
/*  61 */     return (float)Math.sqrt(this.x * this.x + this.y * this.y);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public Point2 normalize()
/*     */   {
/*  69 */     float len = length();
/*  70 */     if (len > 0.0F) {
/*  71 */       dividedBy(len);
/*     */     }
/*  73 */     return this;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public Point2 negate()
/*     */   {
/*  81 */     this.x = (-this.x);
/*  82 */     this.y = (-this.y);
/*     */     
/*  84 */     return this;
/*     */   }
/*     */   
/*     */ 
/*     */   public Point2 plus(Point2 p)
/*     */   {
/*  90 */     this.x += p.x;
/*  91 */     this.y += p.y;
/*     */     
/*  93 */     return this;
/*     */   }
/*     */   
/*     */ 
/*     */   public Point2 plus(float v)
/*     */   {
/*  99 */     this.x += v;
/* 100 */     this.y += v;
/*     */     
/* 102 */     return this;
/*     */   }
/*     */   
/*     */ 
/*     */   public Point2 minus(float v)
/*     */   {
/* 108 */     return plus(-v);
/*     */   }
/*     */   
/*     */ 
/*     */   public Point2 minus(Point2 p)
/*     */   {
/* 114 */     this.x -= p.x;
/* 115 */     this.y -= p.y;
/*     */     
/* 117 */     return this;
/*     */   }
/*     */   
/*     */ 
/*     */   public Point2 times(float v)
/*     */   {
/* 123 */     this.x *= v;
/* 124 */     this.y *= v;
/*     */     
/* 126 */     return this;
/*     */   }
/*     */   
/*     */ 
/*     */   public Point2 times(Point2 p)
/*     */   {
/* 132 */     this.x *= p.x;
/* 133 */     this.y *= p.y;
/*     */     
/* 135 */     return this;
/*     */   }
/*     */   
/*     */ 
/*     */   public Point2 dividedBy(float v)
/*     */   {
/* 141 */     this.x /= v;
/* 142 */     this.y /= v;
/*     */     
/* 144 */     return this;
/*     */   }
/*     */   
/*     */ 
/*     */   public Point2 dividedBy(Point2 p)
/*     */   {
/* 150 */     this.x /= p.x;
/* 151 */     this.y /= p.y;
/*     */     
/* 153 */     return this;
/*     */   }
/*     */   
/*     */ 
/*     */   public float dot(Point2 p)
/*     */   {
/* 159 */     return p.x * this.x + p.y * this.y;
/*     */   }
/*     */   
/*     */   public String toString()
/*     */   {
/* 164 */     return this.x + "," + this.y;
/*     */   }
/*     */   
/* 167 */   private static Object classCookie = new Object();
/*     */   
/*     */   public void saveState(Saver s) throws IOException
/*     */   {
/* 171 */     s.saveVersion(0, classCookie);
/* 172 */     s.saveFloat(this.x);
/* 173 */     s.saveFloat(this.y);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r) throws IOException, TooNewException
/*     */   {
/* 178 */     switch (r.restoreVersion(classCookie)) {
/*     */     case 0: 
/* 180 */       this.x = r.restoreFloat();
/* 181 */       this.y = r.restoreFloat();
/* 182 */       break;
/*     */     default: 
/* 184 */       throw new TooNewException();
/*     */     }
/*     */   }
/*     */   
/*     */   public void postRestore(int version) {}
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Point2.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */