125430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams/* 225430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * Copyright (C) 2009 The Android Open Source Project 325430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * 425430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * Licensed under the Apache License, Version 2.0 (the "License"); 525430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * you may not use this file except in compliance with the License. 625430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * You may obtain a copy of the License at 725430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * 825430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * http://www.apache.org/licenses/LICENSE-2.0 925430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * 1025430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * Unless required by applicable law or agreed to in writing, software 1125430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * distributed under the License is distributed on an "AS IS" BASIS, 1225430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1325430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * See the License for the specific language governing permissions and 1425430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * limitations under the License. 1525430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams */ 1625430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams 1725430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Samspackage android.renderscript; 1825430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams 1925430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams 209c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines/** 21c11e25c4e653124def1fb18e203b894f42106cbeTim Murray * Class for exposing the native RenderScript byte4 type back to the Android system. 2225430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * 2325430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams **/ 24a70f416c9cf2fc6cc5e132c1d656ce07441d6b82Jason Samspublic class Byte4 { 256a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public byte x; 266a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public byte y; 276a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public byte z; 286a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public byte w; 296a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 30a70f416c9cf2fc6cc5e132c1d656ce07441d6b82Jason Sams public Byte4() { 3125430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams } 3225430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams 336cc888e77e17ac522f75bf61403307de8ace2ef3Jason Sams public Byte4(byte initX, byte initY, byte initZ, byte initW) { 346cc888e77e17ac522f75bf61403307de8ace2ef3Jason Sams x = initX; 356cc888e77e17ac522f75bf61403307de8ace2ef3Jason Sams y = initY; 366cc888e77e17ac522f75bf61403307de8ace2ef3Jason Sams z = initZ; 376cc888e77e17ac522f75bf61403307de8ace2ef3Jason Sams w = initW; 386cc888e77e17ac522f75bf61403307de8ace2ef3Jason Sams } 396a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide */ 406a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public Byte4(Byte4 source) { 416a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.x = source.x; 426a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.y = source.y; 436a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.z = source.z; 446a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.w = source.w; 456a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 466cc888e77e17ac522f75bf61403307de8ace2ef3Jason Sams 476a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 486a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector add 496a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 506a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 516a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 526a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void add(Byte4 a) { 536a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.x += a.x; 546a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.y += a.y; 556a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.z += a.z; 566a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.w += a.w; 576a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 586a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 596a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 606a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector add 616a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 626a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 636a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param b 646a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 656a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 666a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public static Byte4 add(Byte4 a, Byte4 b) { 676a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye Byte4 result = new Byte4(); 686a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.x = (byte)(a.x + b.x); 696a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.y = (byte)(a.y + b.y); 706a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.z = (byte)(a.z + b.z); 716a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.w = (byte)(a.w + b.w); 726a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 736a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return result; 746a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 756a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 766a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 776a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector add 786a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 796a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param value 806a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 816a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void add(byte value) { 826a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye x += value; 836a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye y += value; 846a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye z += value; 856a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye w += value; 866a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 876a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 886a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 896a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector add 906a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 916a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 926a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param b 936a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 946a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 956a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public static Byte4 add(Byte4 a, byte b) { 966a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye Byte4 result = new Byte4(); 976a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.x = (byte)(a.x + b); 986a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.y = (byte)(a.y + b); 996a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.z = (byte)(a.z + b); 1006a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.w = (byte)(a.w + b); 1016a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1026a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return result; 1036a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 1046a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1056a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 1066a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector subtraction 1076a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 1086a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 1096a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 1106a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void sub(Byte4 a) { 1116a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.x -= a.x; 1126a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.y -= a.y; 1136a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.z -= a.z; 1146a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.w -= a.w; 1156a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 1166a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1176a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 1186a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector subtraction 1196a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 1206a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 1216a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param b 1226a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 1236a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 1246a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public static Byte4 sub(Byte4 a, Byte4 b) { 1256a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye Byte4 result = new Byte4(); 1266a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.x = (byte)(a.x - b.x); 1276a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.y = (byte)(a.y - b.y); 1286a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.z = (byte)(a.z - b.z); 1296a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.w = (byte)(a.w - b.w); 1306a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1316a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return result; 1326a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 1336a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1346a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 1356a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector subtraction 1366a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 1376a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param value 1386a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 1396a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void sub(byte value) { 1406a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye x -= value; 1416a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye y -= value; 1426a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye z -= value; 1436a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye w -= value; 1446a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 1456a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1466a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 1476a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector subtraction 1486a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 1496a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 1506a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param b 1516a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 1526a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 1536a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public static Byte4 sub(Byte4 a, byte b) { 1546a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye Byte4 result = new Byte4(); 1556a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.x = (byte)(a.x - b); 1566a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.y = (byte)(a.y - b); 1576a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.z = (byte)(a.z - b); 1586a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.w = (byte)(a.w - b); 1596a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1606a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return result; 1616a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 1626a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1636a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 1646a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector multiplication 1656a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 1666a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 1676a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 1686a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void mul(Byte4 a) { 1696a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.x *= a.x; 1706a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.y *= a.y; 1716a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.z *= a.z; 1726a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.w *= a.w; 1736a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 1746a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1756a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 1766a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector multiplication 1776a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 1786a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 1796a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param b 1806a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 1816a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 1826a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public static Byte4 mul(Byte4 a, Byte4 b) { 1836a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye Byte4 result = new Byte4(); 1846a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.x = (byte)(a.x * b.x); 1856a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.y = (byte)(a.y * b.y); 1866a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.z = (byte)(a.z * b.z); 1876a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.w = (byte)(a.w * b.w); 1886a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1896a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return result; 1906a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 1916a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 1926a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 1936a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector multiplication 1946a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 1956a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param value 1966a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 1976a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void mul(byte value) { 1986a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye x *= value; 1996a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye y *= value; 2006a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye z *= value; 2016a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye w *= value; 2026a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 2036a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2046a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 2056a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector multiplication 2066a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 2076a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 2086a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param b 2096a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 2106a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 2116a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public static Byte4 mul(Byte4 a, byte b) { 2126a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye Byte4 result = new Byte4(); 2136a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.x = (byte)(a.x * b); 2146a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.y = (byte)(a.y * b); 2156a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.z = (byte)(a.z * b); 2166a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.w = (byte)(a.w * b); 2176a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2186a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return result; 2196a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 2206a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2216a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 2226a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector division 2236a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 2246a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 2256a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 2266a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void div(Byte4 a) { 2276a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.x /= a.x; 2286a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.y /= a.y; 2296a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.z /= a.z; 2306a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.w /= a.w; 2316a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 2326a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2336a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 2346a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector division 2356a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 2366a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 2376a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param b 2386a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 2396a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 2406a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public static Byte4 div(Byte4 a, Byte4 b) { 2416a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye Byte4 result = new Byte4(); 2426a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.x = (byte)(a.x / b.x); 2436a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.y = (byte)(a.y / b.y); 2446a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.z = (byte)(a.z / b.z); 2456a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.w = (byte)(a.w / b.w); 2466a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2476a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return result; 2486a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 2496a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2506a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 2516a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector division 2526a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 2536a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param value 2546a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 2556a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void div(byte value) { 2566a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye x /= value; 2576a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye y /= value; 2586a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye z /= value; 2596a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye w /= value; 2606a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 2616a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2626a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 2636a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector division 2646a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 2656a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 2666a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param b 2676a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 2686a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 2696a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public static Byte4 div(Byte4 a, byte b) { 2706a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye Byte4 result = new Byte4(); 2716a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.x = (byte)(a.x / b); 2726a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.y = (byte)(a.y / b); 2736a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.z = (byte)(a.z / b); 2746a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye result.w = (byte)(a.w / b); 2756a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2766a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return result; 2776a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 2786a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2796a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 2806a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * get vector length 2816a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 2826a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 2836a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 2846a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public byte length() { 2856a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return 4; 2866a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 2876a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2886a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 2896a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * set vector negate 2906a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 2916a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void negate() { 2926a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.x = (byte)(-x); 2936a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.y = (byte)(-y); 2946a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.z = (byte)(-z); 2956a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.w = (byte)(-w); 2966a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 2976a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 2986a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 2996a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector dot Product 3006a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 3016a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 3026a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 3036a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 3046a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public byte dotProduct(Byte4 a) { 3056a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return (byte)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w)); 3066a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 3076a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 3086a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 3096a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector dot Product 3106a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 3116a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 3126a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param b 3136a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 3146a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 3156a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public static byte dotProduct(Byte4 a, Byte4 b) { 3166a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return (byte)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w)); 3176a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 3186a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 3196a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 3206a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector add Multiple 3216a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 3226a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 3236a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param factor 3246a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 3256a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void addMultiple(Byte4 a, byte factor) { 3266a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye x += a.x * factor; 3276a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye y += a.y * factor; 3286a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye z += a.z * factor; 3296a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye w += a.w * factor; 3306a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 3316a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 3326a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 3336a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * set vector value by Byte4 3346a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 3356a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 3366a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 3376a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void set(Byte4 a) { 3386a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.x = a.x; 3396a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.y = a.y; 3406a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.z = a.z; 3416a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.w = a.w; 3426a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 3436a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 3446a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 3456a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * set the vector field values 3466a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 3476a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param a 3486a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param b 3496a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param c 3506a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param d 3516a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 3526a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void setValues(byte a, byte b, byte c, byte d) { 3536a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.x = a; 3546a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.y = b; 3556a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.z = c; 3566a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye this.w = d; 3576a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 3586a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 3596a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 3606a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * return the element sum of vector 3616a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 3626a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 3636a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 3646a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public byte elementSum() { 3656a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return (byte)(x + y + z + w); 3666a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 3676a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 3686a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 3696a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * get the vector field value by index 3706a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 3716a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param i 3726a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @return 3736a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 3746a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public byte get(int i) { 3756a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye switch (i) { 3766a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 0: 3776a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return x; 3786a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 1: 3796a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return y; 3806a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 2: 3816a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return z; 3826a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 3: 3836a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return w; 3846a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye default: 3856a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye throw new IndexOutOfBoundsException("Index: i"); 3866a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 3876a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 3886a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 3896a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 3906a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * set the vector field value by index 3916a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 3926a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param i 3936a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param value 3946a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 3956a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void setAt(int i, byte value) { 3966a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye switch (i) { 3976a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 0: 3986a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye x = value; 3996a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return; 4006a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 1: 4016a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye y = value; 4026a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return; 4036a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 2: 4046a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye z = value; 4056a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return; 4066a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 3: 4076a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye w = value; 4086a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return; 4096a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye default: 4106a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye throw new IndexOutOfBoundsException("Index: i"); 4116a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 4126a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 4136a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 4146a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 4156a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * add the vector field value by index 4166a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 4176a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param i 4186a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param value 4196a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 4206a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void addAt(int i, byte value) { 4216a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye switch (i) { 4226a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 0: 4236a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye x += value; 4246a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return; 4256a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 1: 4266a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye y += value; 4276a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return; 4286a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 2: 4296a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye z += value; 4306a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return; 4316a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye case 3: 4326a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye w += value; 4336a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye return; 4346a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye default: 4356a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye throw new IndexOutOfBoundsException("Index: i"); 4366a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 4376a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 4386a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye 4396a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye /** @hide 4406a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * copy the vector to Char array 4416a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * 4426a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param data 4436a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * @param offset 4446a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */ 4456a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye public void copyTo(byte[] data, int offset) { 4466a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye data[offset] = x; 4476a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye data[offset + 1] = y; 4486a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye data[offset + 2] = z; 4496a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye data[offset + 3] = w; 4506a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye } 45125430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams} 45225430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams 45325430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams 45425430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams 455