| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.renderscript; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
@Deprecated |
| 28 |
public class Double2 { |
| 29 |
public double x; |
| 30 |
public double y; |
| 31 |
|
| 32 |
public Double2() { |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
public Double2(Double2 data) { |
| 37 |
this.x = data.x; |
| 38 |
this.y = data.y; |
| 39 |
} |
| 40 |
|
| 41 |
public Double2(double x, double y) { |
| 42 |
this.x = x; |
| 43 |
this.y = y; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public static Double2 add(Double2 a, Double2 b) { |
| 54 |
Double2 res = new Double2(); |
| 55 |
res.x = a.x + b.x; |
| 56 |
res.y = a.y + b.y; |
| 57 |
|
| 58 |
return res; |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
public void add(Double2 value) { |
| 67 |
x += value.x; |
| 68 |
y += value.y; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
public void add(double value) { |
| 77 |
x += value; |
| 78 |
y += value; |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
public static Double2 add(Double2 a, double b) { |
| 89 |
Double2 res = new Double2(); |
| 90 |
res.x = a.x + b; |
| 91 |
res.y = a.y + b; |
| 92 |
|
| 93 |
return res; |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
public void sub(Double2 value) { |
| 102 |
x -= value.x; |
| 103 |
y -= value.y; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
public static Double2 sub(Double2 a, Double2 b) { |
| 114 |
Double2 res = new Double2(); |
| 115 |
res.x = a.x - b.x; |
| 116 |
res.y = a.y - b.y; |
| 117 |
|
| 118 |
return res; |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
public void sub(double value) { |
| 127 |
x -= value; |
| 128 |
y -= value; |
| 129 |
} |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
public static Double2 sub(Double2 a, double b) { |
| 139 |
Double2 res = new Double2(); |
| 140 |
res.x = a.x - b; |
| 141 |
res.y = a.y - b; |
| 142 |
|
| 143 |
return res; |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
public void mul(Double2 value) { |
| 152 |
x *= value.x; |
| 153 |
y *= value.y; |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
public static Double2 mul(Double2 a, Double2 b) { |
| 164 |
Double2 res = new Double2(); |
| 165 |
res.x = a.x * b.x; |
| 166 |
res.y = a.y * b.y; |
| 167 |
|
| 168 |
return res; |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
public void mul(double value) { |
| 177 |
x *= value; |
| 178 |
y *= value; |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
public static Double2 mul(Double2 a, double b) { |
| 189 |
Double2 res = new Double2(); |
| 190 |
res.x = a.x * b; |
| 191 |
res.y = a.y * b; |
| 192 |
|
| 193 |
return res; |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
public void div(Double2 value) { |
| 202 |
x /= value.x; |
| 203 |
y /= value.y; |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
public static Double2 div(Double2 a, Double2 b) { |
| 214 |
Double2 res = new Double2(); |
| 215 |
res.x = a.x / b.x; |
| 216 |
res.y = a.y / b.y; |
| 217 |
|
| 218 |
return res; |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
public void div(double value) { |
| 227 |
x /= value; |
| 228 |
y /= value; |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
public static Double2 div(Double2 a, double b) { |
| 239 |
Double2 res = new Double2(); |
| 240 |
res.x = a.x / b; |
| 241 |
res.y = a.y / b; |
| 242 |
|
| 243 |
return res; |
| 244 |
} |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
public double dotProduct(Double2 a) { |
| 253 |
return (x * a.x) + (y * a.y); |
| 254 |
} |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
public static Double dotProduct(Double2 a, Double2 b) { |
| 264 |
return (b.x * a.x) + (b.y * a.y); |
| 265 |
} |
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
public void addMultiple(Double2 a, double factor) { |
| 274 |
x += a.x * factor; |
| 275 |
y += a.y * factor; |
| 276 |
} |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
public void set(Double2 a) { |
| 284 |
this.x = a.x; |
| 285 |
this.y = a.y; |
| 286 |
} |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
public void negate() { |
| 292 |
x = -x; |
| 293 |
y = -y; |
| 294 |
} |
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
public int length() { |
| 302 |
return 2; |
| 303 |
} |
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
public double elementSum() { |
| 311 |
return x + y; |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
public double get(int i) { |
| 321 |
switch (i) { |
| 322 |
case 0: |
| 323 |
return x; |
| 324 |
case 1: |
| 325 |
return y; |
| 326 |
default: |
| 327 |
throw new IndexOutOfBoundsException("Index: i"); |
| 328 |
} |
| 329 |
} |
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
public void setAt(int i, double value) { |
| 338 |
switch (i) { |
| 339 |
case 0: |
| 340 |
x = value; |
| 341 |
return; |
| 342 |
case 1: |
| 343 |
y = value; |
| 344 |
return; |
| 345 |
default: |
| 346 |
throw new IndexOutOfBoundsException("Index: i"); |
| 347 |
} |
| 348 |
} |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
public void addAt(int i, double value) { |
| 357 |
switch (i) { |
| 358 |
case 0: |
| 359 |
x += value; |
| 360 |
return; |
| 361 |
case 1: |
| 362 |
y += value; |
| 363 |
return; |
| 364 |
default: |
| 365 |
throw new IndexOutOfBoundsException("Index: i"); |
| 366 |
} |
| 367 |
} |
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
public void setValues(double x, double y) { |
| 376 |
this.x = x; |
| 377 |
this.y = y; |
| 378 |
} |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
public void copyTo(double[] data, int offset) { |
| 387 |
data[offset] = x; |
| 388 |
data[offset + 1] = y; |
| 389 |
} |
| 390 |
} |