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