├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── README.md ├── pom.xml └── src ├── main └── java │ ├── benchmark │ └── Test.java │ ├── dev │ ├── FloatArray.java │ ├── Vec2i8.java │ └── Vec4u8.java │ ├── glf │ ├── Vertex_v2fc4d.java │ ├── Vertex_v2fc4f.java │ ├── Vertex_v2fc4ub.java │ ├── Vertex_v2fv2f.java │ ├── Vertex_v3fn3f.java │ ├── Vertex_v3fn3fc4f.java │ ├── Vertex_v3fv4u8.java │ ├── Vertex_v4fc4f.java │ └── Vertex_v4fv4fv4f.java │ ├── glm │ ├── BasicOperators.java │ ├── BasicOperatorsScalarFirst.java │ ├── BooleansOperators.java │ ├── FuncCommon.java │ ├── FuncRelational.java │ ├── Glm.java │ ├── SpecialOperators.java │ ├── UMath.java │ ├── funcExponential.java │ ├── funcGeometric.java │ ├── funcMatrix.java │ ├── main.java │ ├── mat │ │ ├── _3 │ │ │ ├── Mat3.java │ │ │ ├── funcMatrix.java │ │ │ ├── matrixQuery.java │ │ │ └── matrixTransform.java │ │ └── _4 │ │ │ ├── Mat4.java │ │ │ ├── d │ │ │ └── Mat4d.java │ │ │ ├── funcMatrix.java │ │ │ ├── matrixQuery.java │ │ │ └── matrixTransform.java │ ├── matrixTransform.java │ ├── noise.java │ ├── packing.java │ ├── quat │ │ ├── Quat.java │ │ ├── funcCommon.java │ │ └── funcGeometric.java │ └── vec │ │ ├── _2 │ │ ├── BasicOperators.java │ │ ├── BooleanOperators.java │ │ ├── FuncRelational.java │ │ ├── Vec2.java │ │ ├── b │ │ │ ├── BasicOperators.java │ │ │ ├── BooleanOperators.java │ │ │ ├── FuncCommon.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec2b.java │ │ ├── bool │ │ │ ├── BooleanOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec2bool.java │ │ ├── d │ │ │ ├── ArithmeticOperators.java │ │ │ ├── BooleanOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec2d.java │ │ ├── funcCommon.java │ │ ├── funcExponential.java │ │ ├── funcGeometric.java │ │ ├── i │ │ │ ├── ArithmeticOperators.java │ │ │ ├── BooleanOperators.java │ │ │ ├── FuncCommon.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec2i.java │ │ ├── l │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec2l.java │ │ ├── s │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec2s.java │ │ ├── t │ │ │ └── Vec2t.java │ │ ├── ub │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec2ub.java │ │ ├── ui │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncCommon.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec2ui.java │ │ ├── ul │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec2ul.java │ │ └── us │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec2us.java │ │ ├── _3 │ │ ├── ArithmeticOperators.java │ │ ├── Vec3.java │ │ ├── b │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncCommon.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec3b.java │ │ ├── bool │ │ │ ├── FuncRelational.java │ │ │ └── Vec3bool.java │ │ ├── d │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec3d.java │ │ ├── funcCommon.java │ │ ├── funcGeometric.java │ │ ├── funcRelational.java │ │ ├── i │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ ├── Vec3i.java │ │ │ └── funcCommon.java │ │ ├── l │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec3l.java │ │ ├── s │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec3s.java │ │ ├── t │ │ │ └── Vec3t.java │ │ ├── ub │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec3ub.java │ │ ├── ui │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec3ui.java │ │ ├── ul │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec3ul.java │ │ └── us │ │ │ ├── ArithmeticOperators.java │ │ │ ├── FuncRelational.java │ │ │ └── Vec3us.java │ │ └── _4 │ │ ├── ArithmeticOperators.java │ │ ├── FuncRelational.java │ │ ├── Vec4.java │ │ ├── b │ │ ├── ArithmeticOperators.java │ │ ├── FuncRelational.java │ │ └── Vec4b.java │ │ ├── bool │ │ ├── FuncRelational.java │ │ └── Vec4bool.java │ │ ├── colorSpace.java │ │ ├── d │ │ ├── ArithmeticOperators.java │ │ ├── FuncRelational.java │ │ └── Vec4d.java │ │ ├── funcCommon.java │ │ ├── funcGeometric.java │ │ ├── i │ │ ├── ArithmeticOperators.java │ │ ├── FuncRelational.java │ │ ├── Vec4i.java │ │ └── funcCommon.java │ │ ├── l │ │ ├── ArithmeticOperators.java │ │ ├── FuncRelational.java │ │ └── Vec4l.java │ │ ├── noise.java │ │ ├── s │ │ ├── ArithmeticOperators.java │ │ ├── FuncRelational.java │ │ └── Vec4s.java │ │ ├── t │ │ └── Vec4t.java │ │ ├── ub │ │ ├── ArithmeticOperators.java │ │ ├── FuncRelational.java │ │ └── Vec4ub.java │ │ ├── ui │ │ ├── ArithmeticOperators.java │ │ ├── FuncRelational.java │ │ └── Vec4ui.java │ │ ├── ul │ │ ├── ArithmeticOperators.java │ │ ├── FuncRelational.java │ │ └── Vec4ul.java │ │ └── us │ │ ├── ArithmeticOperators.java │ │ ├── FuncRelational.java │ │ └── Vec4us.java │ ├── jglm │ ├── Jglm.java │ ├── Mat.java │ ├── Mat3.java │ ├── Mat4.java │ ├── Quat.java │ ├── Vec.java │ ├── Vec2.java │ ├── Vec2i.java │ ├── Vec3.java │ ├── Vec3i.java │ ├── Vec4.java │ ├── Vec4i.java │ └── Veci.java │ └── joou │ ├── UByte.java │ ├── UInt.java │ ├── ULong.java │ ├── UMath.java │ ├── UNumber.java │ └── UShort.java └── test └── java ├── dev ├── Mat3Test.java ├── Mat4Test.java └── glmTest.java └── glm ├── GlmTest.java ├── _ArithmeticOperators.java ├── _FuncRelational.java └── _Operators.java /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk8 4 | script: mvn clean install -DskipTests 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016, Java Graphics Society 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This project isn't being worked anymore, use [this](https://github.com/kotlin-graphics/glm) instead. 2 | 3 | If you would like to continue it, let me know 4 | 5 | glm 6 | ==== 7 | 8 | Glm is the java port of the [OpenGL Mathematics (GLM)](http://glm.g-truc.net/0.9.7/index.html) a mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications. 9 | 10 | Glm provides classes and functions designed and implemented with the same naming conventions (within reasonable terms) and functionalities than GLSL so that anyone, who knows GLSL or GLM, can use the java glm as well. 11 | 12 | This project isn't limited to GLSL features. An extension system, based on the GLSL extension conventions, provides extended capabilities: matrix transformations, quaternions, data packing, random numbers, noise, etc... 13 | 14 | 15 | http://glm.g-truc.net/0.9.4/api/modules.html 16 | 17 | 18 | Code sample: 19 | 20 | ```java 21 | import glm.glm; 22 | import glm.mat._4.Mat4; 23 | import glm.vec._2.Vec2; 24 | import glm.vec._3.Vec3; 25 | 26 | public class Class { 27 | 28 | Mat4 camera(float translate, Vec2 rotate) { 29 | 30 | Mat4 projection = glm.perspective_(45.0f, 4.0f/3.0f, 0.1f, 100.0f); 31 | Mat4 view = new Mat4(1.0f).translate(new Vec3(0.0f, 0.0f, -translate)); 32 | view.rotate(rotate.y, new Vec3(-1.0f, 0.0f, 0.0f)); 33 | view.rotate(rotate.x, new Vec3(0.0f, 1.0f, 0.0f)); 34 | Mat4 model = new Mat4(1.0f).scale(new Vec3(0.5f)); 35 | 36 | return projection.mul(view).mul(model); 37 | } 38 | } 39 | ``` 40 | 41 | About the porting. 42 | 43 | ###Naming 44 | 45 | Since `i32vec2` would have been `I32vec2` because java requires always first letter capital, it has been decided to move the type part at the right and changing the bit lenght directly with the primitive data type (`Vec2i32` would have been confusing), so we simply have `Vec2i`. 46 | 47 | |c++|java| 48 | |---|---| 49 | |`bvec*`|`Vec*bool`| 50 | |`dvec*`|`Vec*d`| 51 | |`vec*`|`Vec*`| 52 | |`i8vec*`|`Vec*b`| 53 | |`i16vec*`|`Vec*s`| 54 | |`i32vec*`|`Vec*i`| 55 | |`i64vec*`|`Vec*l`| 56 | |`u8vec*`|`Vec*ub`| 57 | |`u16vec*`|`Vec*us`| 58 | |`u32vec*`|`Vec*ui`| 59 | |`u64vec*`|`Vec*ul`| 60 | |`dmat*`|`Mat*d`| 61 | |`mat*`|`Mat*`| 62 | 63 | `*` means 1, 2, 3 or 4 for c++, but on java only 2, 3 and 4 because we didn't port any `*vec1` for the moment since there is no apparent reason. 64 | 65 | ###Instantiation 66 | 67 | All functions with any underscore `_` at the end involve implicitly an internal instantiation. They are useful for case scenario when you want the most readable and compact code. 68 | 69 | This means `Glm.add_(Vec2 a, float b)` does not modify `a` because it instantiates a new `Vec2` internally. On contrary, `Glm.add(Vec2 a, float b)` saves the result on `a`, while `Glm.add(Vec2 res, Vec2 a, float b)` saves the result on `res`. 70 | 71 | All of them return the result object (`Vec2` in this case) in order to give you the possibility to concatenate multiple operations in cascade. 72 | 73 | The `Glm` class contains all the possible calls. However to improve usability, each vec/mat class have in its own some additional functions (they will refer always to the `Glm` ones though). 74 | 75 | Therefore, similarly, if we have a `Vec2 v` and if we want to add `2`, we simply call `v.add(2)`. If we want the result to be saved on v, like `v+= 2`, otherwise `Vec2 a = v.add_(2)` and we save the result in `a`. 76 | 77 | However, binary operations involving a scalar in the first place can, off course, only be called by `Glm`, so if you want do `1.0f - v`, you shall call `Glm.sub(1.0f, v)`. 78 | 79 | Since java transforms `byte` and `short` value to `int` before doing any operation, we provide the same for classes involving those type, signed or unsigned. 80 | 81 | 82 | Steps: 83 | 84 | - add jars under `\lib` 85 | 86 | Enhances: 87 | 88 | - support for [openvr](https://github.com/java-graphics-society/openvr) matrices, helpful to avoid all the problems regarding colum or row major order. 89 | 90 | 91 | Credits: 92 | - [JOML](https://github.com/JOML-CI/JOML), by [Kai Burjack](https://github.com/httpdigest) for `Mat4/d.inverse()`, `Mat4/d.invTransp/3()`, `Mat4.det3()`, `Mat4.scale()` 93 | - [jOOU](https://github.com/jOOQ/jOOU), for the unsigned version for the four Java integer types (`byte`, `short`, `int` and `long`). 94 | -------------------------------------------------------------------------------- /src/main/java/dev/FloatArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package dev; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class FloatArray { 13 | 14 | public static final int M00 = 0, M10 = 4, M20 = 8, M30 = 12; 15 | public static final int M01 = 1, M11 = 5, M21 = 9, M31 = 13; 16 | public static final int M02 = 2, M12 = 6, M22 = 10, M32 = 14; 17 | public static final int M03 = 3, M13 = 7, M23 = 11, M33 = 15; 18 | public static final int COUNT = 16; 19 | 20 | public static float[] perspective_(float fovy, float aspect, float zNear, float zFar) { 21 | return perspective(fovy, aspect, zNear, zFar, new float[COUNT]); 22 | } 23 | 24 | public static float[] perspective(float fovy, float aspect, float zNear, float zFar, float[] res) { 25 | float h = (float) Math.tan(fovy * 0.5f) * zNear; 26 | float w = h * aspect; 27 | res[M00] = zNear / w; 28 | res[M01] = 0.0f; 29 | res[M02] = 0.0f; 30 | res[M03] = 0.0f; 31 | res[M10] = 0.0f; 32 | res[M11] = zNear / h; 33 | res[M12] = 0.0f; 34 | res[M13] = 0.0f; 35 | res[M20] = 0.0f; 36 | res[M21] = 0.0f; 37 | res[M22] = -(zFar + zNear) / (zFar - zNear); 38 | res[M23] = -1.0f; 39 | res[M30] = 0.0f; 40 | res[M31] = 0.0f; 41 | res[M32] = -2.0f * zFar * zNear / (zFar - zNear); 42 | res[M33] = 0.0f; 43 | return res; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/dev/Vec2i8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package dev; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec2i8 { 13 | 14 | public static final int SIZE = 2 * Byte.BYTES; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/dev/Vec4u8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package dev; 7 | 8 | import glm.vec._4.Vec4; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | public class Vec4u8 { 15 | 16 | public static final int SIZE = 4 * Byte.BYTES; 17 | 18 | public byte x, y, z, w; 19 | 20 | public Vec4u8() { 21 | x = 0; 22 | y = 0; 23 | z = 0; 24 | w = 0; 25 | } 26 | 27 | public Vec4u8(Vec4 v) { 28 | x = (byte) v.x; 29 | y = (byte) v.y; 30 | z = (byte) v.z; 31 | w = (byte) v.w; 32 | } 33 | 34 | public Vec4u8(byte x, byte y, byte z, byte w) { 35 | this.x = x; 36 | this.y = y; 37 | this.z = z; 38 | this.w = w; 39 | } 40 | 41 | public Vec4u8(float x, float y, float z, float w) { 42 | this.x = (byte) x; 43 | this.y = (byte) y; 44 | this.z = (byte) z; 45 | this.w = (byte) w; 46 | } 47 | 48 | public byte[] toBa_() { 49 | return toBa(new byte[4]); 50 | } 51 | 52 | public byte[] toBa(byte[] byteArray) { 53 | byteArray[0] = x; 54 | byteArray[1] = y; 55 | byteArray[2] = z; 56 | byteArray[3] = w; 57 | return byteArray; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/glf/Vertex_v2fc4d.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glf; 7 | 8 | import glm.vec._2.Vec2; 9 | import glm.vec._4.d.Vec4d; 10 | import java.nio.ByteBuffer; 11 | 12 | /** 13 | * 14 | * @author elect 15 | */ 16 | public class Vertex_v2fc4d { 17 | 18 | public static final int SIZE = Vec2.SIZE + Vec4d.SIZE; 19 | 20 | public Vec2 position; 21 | public Vec4d color; 22 | 23 | public Vertex_v2fc4d(Vec2 position, Vec4d color) { 24 | this.position = position; 25 | this.color = color; 26 | } 27 | 28 | public ByteBuffer toBB(ByteBuffer bb, int index) { 29 | return bb 30 | .putFloat(index * SIZE + 0 * Float.BYTES, position.x) 31 | .putFloat(index * SIZE + 1 * Float.BYTES, position.y) 32 | .putDouble(index * SIZE + 2 * Float.BYTES + 0 * Double.BYTES, color.x) 33 | .putDouble(index * SIZE + 2 * Float.BYTES + 1 * Double.BYTES, color.y) 34 | .putDouble(index * SIZE + 2 * Float.BYTES + 2 * Double.BYTES, color.z) 35 | .putDouble(index * SIZE + 2 * Float.BYTES + 3 * Double.BYTES, color.w); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/glf/Vertex_v2fc4f.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glf; 7 | 8 | import glm.vec._2.Vec2; 9 | import glm.vec._4.Vec4; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | public class Vertex_v2fc4f { 16 | 17 | public static final int SIZE = Vec4.SIZE + Vec2.SIZE; 18 | 19 | public Vec4 position; 20 | public Vec2 texCoord; 21 | 22 | public Vertex_v2fc4f() { 23 | } 24 | 25 | public Vertex_v2fc4f(Vec4 position, Vec2 texCoord) { 26 | this.position = position; 27 | this.texCoord = texCoord; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/glf/Vertex_v2fc4ub.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glf; 7 | 8 | import dev.Vec4u8; 9 | import glm.vec._2.Vec2; 10 | import java.nio.ByteBuffer; 11 | 12 | /** 13 | * 14 | * @author GBarbieri 15 | */ 16 | public class Vertex_v2fc4ub { 17 | 18 | public static final int SIZE = Vec2.SIZE + Vec4u8.SIZE; 19 | 20 | public Vec2 position; 21 | public Vec4u8 color; 22 | 23 | public Vertex_v2fc4ub(Vec2 position, Vec4u8 color) { 24 | this.position = position; 25 | this.color = color; 26 | } 27 | 28 | public void toBb(ByteBuffer bb, int index) { 29 | bb 30 | .putFloat(index * SIZE + 0 * Float.BYTES, position.x) 31 | .putFloat(index * SIZE + 1 * Float.BYTES, position.y) 32 | .put(index * SIZE + 2 * Float.BYTES + 0 * Byte.BYTES, color.x) 33 | .put(index * SIZE + 2 * Float.BYTES + 1 * Byte.BYTES, color.y) 34 | .put(index * SIZE + 2 * Float.BYTES + 2 * Byte.BYTES, color.z) 35 | .put(index * SIZE + 2 * Float.BYTES + 3 * Byte.BYTES, color.w); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/glf/Vertex_v2fv2f.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glf; 7 | 8 | import glm.vec._2.Vec2; 9 | import java.nio.ByteBuffer; 10 | import java.nio.FloatBuffer; 11 | 12 | /** 13 | * 14 | * @author GBarbieri 15 | */ 16 | public class Vertex_v2fv2f { 17 | 18 | public static final int SIZE = 2 * Vec2.SIZE; 19 | 20 | public Vec2 position; 21 | public Vec2 texCoord; 22 | 23 | public Vertex_v2fv2f(Vec2 position, Vec2 texCoord) { 24 | this.position = position; 25 | this.texCoord = texCoord; 26 | } 27 | 28 | public void toBb(ByteBuffer bb, int index) { 29 | bb 30 | .putFloat(index * SIZE + 0 * Float.BYTES, position.x) 31 | .putFloat(index * SIZE + 1 * Float.BYTES, position.y) 32 | .putFloat(index * SIZE + 2 * Float.BYTES, texCoord.x) 33 | .putFloat(index * SIZE + 3 * Float.BYTES, texCoord.y); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/glf/Vertex_v3fn3f.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glf; 7 | 8 | import glm.vec._3.Vec3; 9 | import glm.vec._4.Vec4; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | public class Vertex_v3fn3f { 16 | 17 | public Vec3 position; 18 | public Vec3 normal; 19 | 20 | public Vertex_v3fn3f(Vec3 position, Vec3 normal) { 21 | this.position = position; 22 | this.normal = normal; 23 | } 24 | 25 | public static final int SIZE = 2 * Vec3.SIZE; 26 | public static final int OFFSET_POSITION = 0; 27 | public static final int OFFSET_NORMAL = Vec3.SIZE; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/glf/Vertex_v3fn3fc4f.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glf; 7 | 8 | import glm.vec._3.Vec3; 9 | import glm.vec._4.Vec4; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | public class Vertex_v3fn3fc4f { 16 | 17 | public Vec3 position; 18 | public Vec3 texCoord; 19 | public Vec4 color; 20 | 21 | public Vertex_v3fn3fc4f(Vec3 position, Vec3 texCoord, Vec4 color) { 22 | this.position = position; 23 | this.texCoord = texCoord; 24 | this.color = color; 25 | } 26 | 27 | public static final int SIZE = 2 * Vec3.SIZE + Vec4.SIZE; 28 | public static final int OFFSET_POSITION = 0; 29 | public static final int OFFSET_NORMAL = Vec3.SIZE; 30 | public static final int OFFSET_COLOR = 2 * Vec3.SIZE; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/glf/Vertex_v3fv4u8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glf; 7 | 8 | import dev.Vec4u8; 9 | import glm.vec._3.Vec3; 10 | import java.nio.ByteBuffer; 11 | import java.nio.ByteOrder; 12 | 13 | /** 14 | * 15 | * @author GBarbieri 16 | */ 17 | public class Vertex_v3fv4u8 { 18 | 19 | public static final int SIZE = Vec3.SIZE + Vec4u8.SIZE; 20 | 21 | public Vec3 position; 22 | public Vec4u8 color; 23 | 24 | public Vertex_v3fv4u8(Vec3 position, Vec4u8 color) { 25 | this.position = position; 26 | this.color = color; 27 | } 28 | 29 | public void toBb(ByteBuffer bb, int index) { 30 | bb 31 | .putFloat(index * SIZE + 0 * Float.BYTES, position.x) 32 | .putFloat(index * SIZE + 1 * Float.BYTES, position.y) 33 | .putFloat(index * SIZE + 2 * Float.BYTES, position.z) 34 | .put(index * SIZE + 3 * Float.BYTES + 0 * Byte.BYTES, color.x) 35 | .put(index * SIZE + 3 * Float.BYTES + 1 * Byte.BYTES, color.y) 36 | .put(index * SIZE + 3 * Float.BYTES + 2 * Byte.BYTES, color.z) 37 | .put(index * SIZE + 3 * Float.BYTES + 3 * Byte.BYTES, color.w); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/glf/Vertex_v4fc4f.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glf; 7 | 8 | import glm.vec._4.Vec4; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | public class Vertex_v4fc4f { 15 | 16 | public Vec4 position; 17 | public Vec4 color; 18 | 19 | public static final int SIZE = 2 * Vec4.SIZE; 20 | 21 | public Vertex_v4fc4f() { 22 | } 23 | 24 | public Vertex_v4fc4f(Vec4 position, Vec4 color) { 25 | this.position = position; 26 | this.color = color; 27 | } 28 | 29 | public float[] toFa_() { 30 | return new float[]{ 31 | position.x, position.y, position.z, position.w, 32 | color.x, color.y, color.z, color.w}; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/glf/Vertex_v4fv4fv4f.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glf; 7 | 8 | import glm.vec._4.Vec4; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | public class Vertex_v4fv4fv4f { 15 | 16 | public static final int SIZE = 3 * Vec4.SIZE; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/glm/Glm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm; 7 | 8 | import glm.mat._4.Mat4; 9 | import glm.vec._3.Vec3; 10 | import glm.vec._4.Vec4; 11 | 12 | /** 13 | * 14 | * @author GBarbieri 15 | */ 16 | public class Glm extends noise { 17 | 18 | public static int ceilMultiple(int source, int multiple) { 19 | if (source > 0) { 20 | float tmp = source - 1; 21 | return (int) (tmp + (multiple - (tmp % multiple))); 22 | } else { 23 | return source + (-source % multiple); 24 | } 25 | } 26 | 27 | // http://stackoverflow.com/a/18946610/1047713 28 | public static double linearRand() { 29 | return linearRand(0, 1); 30 | } 31 | 32 | public static double linearRand(double min, double max) { 33 | return Math.random() * (max + Double.MIN_VALUE) + min; 34 | } 35 | 36 | public static int linearRand(int min, int max) { 37 | return (int) (Math.random() * (max + Integer.MIN_VALUE) + min); 38 | } 39 | 40 | public static Vec3 linearRand(Vec3 min, Vec3 max, Vec3 res) { 41 | return Vec3.linearRand(min, max, res); 42 | } 43 | 44 | public static Vec3 linearRand_(Vec3 min, Vec3 max) { 45 | return Vec3.linearRand_(min, max); 46 | } 47 | 48 | public static Vec3 project_(Vec3 obj, Mat4 model, Mat4 proj, Vec4 viewport) { 49 | return project(obj, model, proj, viewport, new Vec3()); 50 | } 51 | 52 | public static Vec3 project(Vec3 obj, Mat4 model, Mat4 proj, Vec4 viewport, Vec3 res) { 53 | // tvec4 tmp = tvec4(obj, T(1)); tmp = model * tmp; 54 | float tX = model.m00 * obj.x + model.m10 * obj.y + model.m20 * obj.z + model.m30 * 1f; 55 | float tY = model.m01 * obj.x + model.m11 * obj.y + model.m21 * obj.z + model.m31 * 1f; 56 | float tZ = model.m02 * obj.x + model.m12 * obj.y + model.m22 * obj.z + model.m32 * 1f; 57 | float tW = model.m03 * obj.x + model.m13 * obj.y + model.m23 * obj.z + model.m33 * 1f; 58 | // tmp = proj * tmp; 59 | float tmpX = proj.m00 * tX + proj.m10 * tY + proj.m20 * tZ + proj.m30 * tW; 60 | float tmpY = proj.m01 * tX + proj.m11 * tY + proj.m21 * tZ + proj.m31 * tW; 61 | float tmpZ = proj.m02 * tX + proj.m12 * tY + proj.m22 * tZ + proj.m32 * tW; 62 | float tmpW = proj.m03 * tX + proj.m13 * tY + proj.m23 * tZ + proj.m33 * tW; 63 | // tmp /= tmp.w; 64 | tmpX /= tmpW; 65 | tmpY /= tmpW; 66 | tmpZ /= tmpW; 67 | // tmpW = 1f; 68 | // tmp = tmp * T(0.5) + T(0.5); 69 | tmpX = tmpX * 0.5f + 0.5f; 70 | tmpY = tmpY * 0.5f + 0.5f; 71 | tmpZ = tmpZ * 0.5f + 0.5f; 72 | // tmpW = tmpW * 0.5f + 0.5f; 73 | // tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]); 74 | tmpX = tmpX * viewport.z + viewport.x; 75 | tmpY = tmpY * viewport.w + viewport.y; 76 | return res.set(tmpX, tmpY, tmpZ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/glm/UMath.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm; 7 | 8 | import joou.UByte; 9 | import joou.UInt; 10 | import joou.ULong; 11 | import joou.UShort; 12 | 13 | /** 14 | * 15 | * @author GBarbieri 16 | */ 17 | public class UMath { 18 | 19 | public static UByte max(UByte a, UByte b) { 20 | return a.compareTo(b) > 0 ? a : b; 21 | } 22 | 23 | public static UInt max(UInt a, UInt b) { 24 | return a.compareTo(b) > 0 ? a : b; 25 | } 26 | 27 | public static ULong max(ULong a, ULong b) { 28 | return a.compareTo(b) > 0 ? a : b; 29 | } 30 | 31 | public static UShort max(UShort a, UShort b) { 32 | return a.compareTo(b) > 0 ? a : b; 33 | } 34 | 35 | public static UByte min(UByte a, UByte b) { 36 | return a.compareTo(b) < 0 ? a : b; 37 | } 38 | 39 | public static UInt min(UInt a, UInt b) { 40 | return a.compareTo(b) < 0 ? a : b; 41 | } 42 | 43 | public static ULong min(ULong a, ULong b) { 44 | return a.compareTo(b) < 0 ? a : b; 45 | } 46 | 47 | public static UShort min(UShort a, UShort b) { 48 | return a.compareTo(b) < 0 ? a : b; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/glm/funcExponential.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | abstract class funcExponential extends FuncCommon { 13 | 14 | public static float exp(float x) { 15 | return (float) Math.exp(x); 16 | } 17 | 18 | public static float exp2(float x) { 19 | return (float) Math.pow(2, x); 20 | } 21 | 22 | public static float inverseSqrt(float x) { 23 | float xhalf = 0.5f * x; 24 | int i = Float.floatToIntBits(x); 25 | i = 0x5f3759df - (i >> 1); 26 | x = Float.intBitsToFloat(i); 27 | x = x * (1.5f - xhalf * x * x); 28 | return x; 29 | } 30 | 31 | public static float log(float x) { 32 | return (float) Math.log(x); 33 | } 34 | 35 | public static int log2(int value) { 36 | return (int) (Math.log(value) / Math.log(2)); 37 | } 38 | 39 | public static float pow(float x, float y) { 40 | return (float) Math.pow(x, y); 41 | } 42 | 43 | public static float sqrt(float x) { 44 | return (float) Math.sqrt(x); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/glm/funcGeometric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm; 7 | 8 | import glm.quat.Quat; 9 | import glm.vec._3.Vec3; 10 | import glm.vec._4.Vec4; 11 | 12 | /** 13 | * 14 | * @author GBarbieri 15 | */ 16 | abstract class funcGeometric extends funcExponential { 17 | 18 | public static Quat angleAxis_(float degAngle, Vec3 v) { 19 | return Quat.angleAxis_(degAngle, v); 20 | } 21 | 22 | public static Quat angleAxis(float degAngle, Vec3 v, Quat res) { 23 | return Quat.angleAxis(degAngle, v, res); 24 | } 25 | 26 | public static float length(float x) { 27 | return (float)Math.abs(x); 28 | } 29 | 30 | public static float dot(Vec4 v0, Vec4 v1) { 31 | return Vec4.dot(v0, v1); 32 | } 33 | 34 | public static float dot(Quat v0, Quat v1) { 35 | return Quat.dot(v0, v1); 36 | } 37 | 38 | public static Vec3 cross(Vec3 v0, Vec3 v1) { 39 | return v0.cross(v1); 40 | } 41 | 42 | public static Vec3 cross_(Vec3 v0, Vec3 v1) { 43 | return v0.cross_(v1); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/glm/funcMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm; 7 | 8 | import glm.mat._4.Mat4; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | abstract class funcMatrix extends packing { 15 | 16 | public static Mat4 transpose_(Mat4 mat) { 17 | return Mat4.transpose(mat, new Mat4()); 18 | } 19 | 20 | public static Mat4 transpose(Mat4 mat, Mat4 dest) { 21 | return Mat4.transpose(mat, dest); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/glm/main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm; 7 | 8 | import glm.mat._4.Mat4; 9 | import glm.vec._2.Vec2; 10 | import glm.vec._2.i.Vec2i; 11 | import glm.vec._3.Vec3; 12 | import glm.vec._3.i.Vec3i; 13 | import glm.vec._4.Vec4; 14 | 15 | /** 16 | * 17 | * @author fschaefers 18 | */ 19 | public class main { 20 | 21 | public static void main(String[] args) { 22 | Vec2 vec2F_1 = new Vec2(5, 2); 23 | Vec2 vec2F_2 = new Vec2(5, 8); 24 | Vec2i vec2I_1 = new Vec2i(5, 8); 25 | Vec2i vec2I_12 = new Vec2i(6, 8); 26 | Vec4 vec4_1 = new Vec4(0, 0, 0, 0); 27 | Vec3 vec3f_1 = new Vec3(3, 5, 7); 28 | Vec3 vec3f_2 = new Vec3(10, 10, 10); 29 | Vec3i vec3i_1 = new Vec3i(3, 5, 7); 30 | Vec3i vec3i_2 = new Vec3i(10, 10, 10); 31 | Vec2i x = vec2I_1.lessThan(vec2I_12); 32 | Vec3 modVec = vec3f_2.mod_(vec3f_1); 33 | Vec3i modVeci = vec3i_2.mod_(vec3i_1); 34 | modVec.print("modVec"); 35 | modVeci.print("modVec"); 36 | 37 | Vec4 v = new Vec4(0,1,3,4); 38 | v.mul(new Mat4()); 39 | // vec2F_2. 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/glm/mat/_3/funcMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.mat._3; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | abstract class funcMatrix { 13 | 14 | public float m00, m10, m20; 15 | public float m01, m11, m21; 16 | public float m02, m12, m22; 17 | 18 | public static final int SIZE = 3 * 3 * Float.BYTES; 19 | 20 | public float det() { 21 | return (m00 * m11 - m01 * m10) * m22 + (m02 * m10 - m00 * m12) * m21 + (m01 * m12 - m02 * m11) * m20; 22 | } 23 | 24 | public Mat3 inverse() { 25 | return inverse((Mat3) this); 26 | } 27 | 28 | public Mat3 inverse_() { 29 | return inverse(new Mat3()); 30 | } 31 | 32 | /** 33 | * Matrix is supposed to be invertible 34 | * 35 | * @param res 36 | * @return 37 | */ 38 | public Mat3 inverse(Mat3 res) { 39 | float s = 1.0f / det(); 40 | res.set((m11 * m22 - m21 * m12) * s, 41 | (m21 * m02 - m01 * m22) * s, 42 | (m01 * m12 - m11 * m02) * s, 43 | (m20 * m12 - m10 * m22) * s, 44 | (m00 * m22 - m20 * m02) * s, 45 | (m10 * m02 - m00 * m12) * s, 46 | (m10 * m21 - m20 * m11) * s, 47 | (m20 * m01 - m00 * m21) * s, 48 | (m00 * m11 - m10 * m01) * s); 49 | return res; 50 | } 51 | 52 | public Mat3 invTransp() { 53 | return invTransp((Mat3) this); 54 | } 55 | 56 | public Mat3 invTransp_() { 57 | return invTransp(new Mat3()); 58 | } 59 | 60 | public Mat3 invTransp(Mat3 res) { 61 | float s = 1.0f / det(); 62 | /* Invert and transpose in one go */ 63 | res.set( 64 | (m11 * m22 - m21 * m12) * s, 65 | (m20 * m12 - m10 * m22) * s, 66 | (m10 * m21 - m20 * m11) * s, 67 | (m21 * m02 - m01 * m22) * s, 68 | (m00 * m22 - m20 * m02) * s, 69 | (m20 * m01 - m00 * m21) * s, 70 | (m01 * m12 - m11 * m02) * s, 71 | (m10 * m02 - m00 * m12) * s, 72 | (m00 * m11 - m10 * m01) * s); 73 | return res; 74 | } 75 | 76 | public Mat3 transpose_() { 77 | return transpose(new Mat3()); 78 | } 79 | 80 | public Mat3 transpose() { 81 | return transpose((Mat3) this); 82 | } 83 | 84 | public Mat3 transpose(Mat3 dest) { 85 | return transpose((Mat3) this, dest); 86 | } 87 | 88 | public static Mat3 transpose(Mat3 mat, Mat3 dest) { 89 | dest.set( 90 | mat.m00, mat.m10, mat.m20, 91 | mat.m01, mat.m11, mat.m21, 92 | mat.m02, mat.m12, mat.m22); 93 | return dest; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/glm/mat/_3/matrixQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.mat._3; 7 | 8 | /** 9 | * 10 | * @author fschaefers 11 | */ 12 | abstract class matrixQuery extends matrixTransform { 13 | 14 | public boolean isIdentity() { 15 | return isIdentity(0.0f); 16 | } 17 | 18 | public boolean isIdentity(float epsilon) { 19 | return Math.abs(m00 - 1) <= epsilon 20 | && Math.abs(m01) <= epsilon 21 | && Math.abs(m02) <= epsilon 22 | && Math.abs(m10) <= epsilon 23 | && Math.abs(m11 - 1) <= epsilon 24 | && Math.abs(m12) <= epsilon 25 | && Math.abs(m20) <= epsilon 26 | && Math.abs(m21) <= epsilon 27 | && Math.abs(m22 - 1) <= epsilon; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/glm/mat/_4/funcMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.mat._4; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | abstract class funcMatrix { 13 | 14 | public float m00, m10, m20, m30; 15 | public float m01, m11, m21, m31; 16 | public float m02, m12, m22, m32; 17 | public float m03, m13, m23, m33; 18 | 19 | public static final int SIZE = 4 * 4 * Float.BYTES; 20 | 21 | // TODO invert? 22 | public Mat4 inverse() { 23 | return inverse((Mat4) this); 24 | } 25 | 26 | public Mat4 inverse_() { 27 | return inverse(new Mat4()); 28 | } 29 | 30 | public Mat4 inverse(Mat4 dest) { 31 | float a = m00 * m11 - m01 * m10; 32 | float b = m00 * m12 - m02 * m10; 33 | float c = m00 * m13 - m03 * m10; 34 | float d = m01 * m12 - m02 * m11; 35 | float e = m01 * m13 - m03 * m11; 36 | float f = m02 * m13 - m03 * m12; 37 | float g = m20 * m31 - m21 * m30; 38 | float h = m20 * m32 - m22 * m30; 39 | float i = m20 * m33 - m23 * m30; 40 | float j = m21 * m32 - m22 * m31; 41 | float k = m21 * m33 - m23 * m31; 42 | float l = m22 * m33 - m23 * m32; 43 | float det = a * l - b * k + c * j + d * i - e * h + f * g; 44 | det = 1.0f / det; 45 | dest.set( 46 | (+m11 * l - m12 * k + m13 * j) * det, 47 | (-m01 * l + m02 * k - m03 * j) * det, 48 | (+m31 * f - m32 * e + m33 * d) * det, 49 | (-m21 * f + m22 * e - m23 * d) * det, 50 | (-m10 * l + m12 * i - m13 * h) * det, 51 | (+m00 * l - m02 * i + m03 * h) * det, 52 | (-m30 * f + m32 * c - m33 * b) * det, 53 | (+m20 * f - m22 * c + m23 * b) * det, 54 | (+m10 * k - m11 * i + m13 * g) * det, 55 | (-m00 * k + m01 * i - m03 * g) * det, 56 | (+m30 * e - m31 * c + m33 * a) * det, 57 | (-m20 * e + m21 * c - m23 * a) * det, 58 | (-m10 * j + m11 * h - m12 * g) * det, 59 | (+m00 * j - m01 * h + m02 * g) * det, 60 | (-m30 * d + m31 * b - m32 * a) * det, 61 | (+m20 * d - m21 * b + m22 * a) * det); 62 | return dest; 63 | } 64 | 65 | public Mat4 invTransp() { 66 | return invTransp3((Mat4) this); 67 | } 68 | 69 | public Mat4 invTransp3_() { 70 | return invTransp3(new Mat4()); 71 | } 72 | 73 | public Mat4 invTransp3(Mat4 dest) { 74 | float det = det3(); 75 | float s = 1.0f / det; 76 | /* Invert and transpose in one go */ 77 | dest.set((m11 * m22 - m21 * m12) * s, 78 | (m20 * m12 - m10 * m22) * s, 79 | (m10 * m21 - m20 * m11) * s, 80 | 0.0f, 81 | (m21 * m02 - m01 * m22) * s, 82 | (m00 * m22 - m20 * m02) * s, 83 | (m20 * m01 - m00 * m21) * s, 84 | 0.0f, 85 | (m01 * m12 - m11 * m02) * s, 86 | (m10 * m02 - m00 * m12) * s, 87 | (m00 * m11 - m10 * m01) * s, 88 | 0.0f, 89 | 0.0f, 0.0f, 0.0f, 1.0f); 90 | return dest; 91 | } 92 | 93 | public Mat4 transpose_() { 94 | return transpose(new Mat4()); 95 | } 96 | 97 | public Mat4 transpose() { 98 | return transpose((Mat4) this); 99 | } 100 | 101 | public Mat4 transpose(Mat4 dest) { 102 | return transpose((Mat4) this, dest); 103 | } 104 | 105 | public static Mat4 transpose(Mat4 mat, Mat4 dest) { 106 | dest.set(mat.m00, mat.m10, mat.m20, mat.m30, 107 | mat.m01, mat.m11, mat.m21, mat.m31, 108 | mat.m02, mat.m12, mat.m22, mat.m32, 109 | mat.m03, mat.m13, mat.m23, mat.m33); 110 | return dest; 111 | } 112 | 113 | public float det() { 114 | return (m00 * m11 - m01 * m10) * (m22 * m33 - m23 * m32) 115 | + (m02 * m10 - m00 * m12) * (m21 * m33 - m23 * m31) 116 | + (m00 * m13 - m03 * m10) * (m21 * m32 - m22 * m31) 117 | + (m01 * m12 - m02 * m11) * (m20 * m33 - m23 * m30) 118 | + (m03 * m11 - m01 * m13) * (m20 * m32 - m22 * m30) 119 | + (m02 * m13 - m03 * m12) * (m20 * m31 - m21 * m30); 120 | } 121 | 122 | public float det3() { 123 | return (m00 * m11 - m01 * m10) * m22 124 | + (m02 * m10 - m00 * m12) * m21 125 | + (m01 * m12 - m02 * m11) * m20; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/main/java/glm/mat/_4/matrixQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.mat._4; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | abstract class matrixQuery extends matrixTransform { 13 | 14 | public boolean isIdentity() { 15 | return isIdentity(0.0f); 16 | } 17 | 18 | public boolean isIdentity(float epsilon) { 19 | return Math.abs(m00 - 1) <= epsilon 20 | && Math.abs(m01) <= epsilon 21 | && Math.abs(m02) <= epsilon 22 | && Math.abs(m03) <= epsilon 23 | && Math.abs(m10) <= epsilon 24 | && Math.abs(m11 - 1) <= epsilon 25 | && Math.abs(m12) <= epsilon 26 | && Math.abs(m13) <= epsilon 27 | && Math.abs(m20) <= epsilon 28 | && Math.abs(m21) <= epsilon 29 | && Math.abs(m22 - 1) <= epsilon 30 | && Math.abs(m23) <= epsilon 31 | && Math.abs(m30) <= epsilon 32 | && Math.abs(m31) <= epsilon 33 | && Math.abs(m32) <= epsilon 34 | && Math.abs(m33 - 1) <= epsilon; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/glm/noise.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | abstract class noise extends matrixTransform { 13 | 14 | public static float taylorInvSqrt_(float r) { 15 | return 1.79284291400159f - r * 0.85373472095314f; 16 | } 17 | 18 | private static float permute(float x) { 19 | return mod289((x * 34 + 1) * x); 20 | } 21 | 22 | // TODO check floor return type 23 | private static float mod289(float x) { 24 | return (float) (x - floor(x * 1 / 289) * 289); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/glm/quat/funcCommon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.quat; 7 | 8 | import glm.vec._3.Vec3; 9 | 10 | /** 11 | * 12 | * @author elect 13 | */ 14 | abstract class funcCommon { 15 | 16 | public static final int SIZE = 4 * Float.BYTES; 17 | 18 | public float w, x, y, z; 19 | 20 | public Quat add(Quat y) { 21 | return add(y, (Quat) this); 22 | } 23 | 24 | public Quat add_(Quat y) { 25 | return add(y, new Quat()); 26 | } 27 | 28 | public Quat add(Quat y, Quat res) { 29 | return add((Quat) this, y, res); 30 | } 31 | 32 | public static Quat add(Quat x, Quat y, Quat res) { 33 | res.w = x.w + y.w; 34 | res.x = x.x + y.x; 35 | res.y = x.y + y.y; 36 | res.z = x.z + y.z; 37 | return res; 38 | } 39 | 40 | public Quat mul_(Quat q) { 41 | return mul(q, new Quat()); 42 | } 43 | 44 | public Quat mul(Quat q) { 45 | return mul(q, (Quat) this); 46 | } 47 | 48 | public Quat mul(Quat q, Quat res) { 49 | return Quat.mul((Quat) this, q, res); 50 | } 51 | 52 | public static Quat mul(Quat x, Quat y, Quat res) { 53 | return res.set( 54 | x.w * y.w - x.x * y.x - x.y * y.y - x.z * y.z, 55 | x.w * y.x + x.x * y.w + x.y * y.z - x.z * y.y, 56 | x.w * y.y + x.y * y.w + x.z * y.x - x.x * y.z, 57 | x.w * y.z + x.z * y.w + x.x * y.y - x.y * y.x); 58 | } 59 | 60 | public Vec3 mul(Vec3 v) { 61 | return Quat.mul((Quat) this, v, v); 62 | } 63 | 64 | public Vec3 mul_(Vec3 v) { 65 | return Quat.mul((Quat) this, v, new Vec3()); 66 | } 67 | 68 | public Vec3 mul(Vec3 v, Vec3 res) { 69 | return Quat.mul((Quat) this, v, res); 70 | } 71 | 72 | public static Vec3 mul(Quat q, Vec3 v, Vec3 res) { 73 | float n0 = q.x + q.x; 74 | float n1 = q.y + q.y; 75 | float n2 = q.z + q.z; 76 | float n3 = q.x * n0; 77 | float n4 = q.y * n1; 78 | float n5 = q.z * n2; 79 | float n6 = q.x * n1; 80 | float n7 = q.x * n2; 81 | float n8 = q.y * n2; 82 | float n9 = q.w * n0; 83 | float n10 = q.w * n1; 84 | float n11 = q.w * n2; 85 | res.set((1.0f - (n4 + n5)) * v.x + (n6 - n11) * v.y + (n7 + n10) * v.z, 86 | (n6 + n11) * v.x + (1.0f - (n3 + n5)) * v.y + (n8 - n9) * v.z, 87 | (n7 - n10) * v.x + (n8 + n9) * v.y + (1.0f - (n3 + n4)) * v.z); 88 | return res; 89 | } 90 | 91 | public Quat mul(double d) { 92 | return mul((float) d, (Quat) this); 93 | } 94 | 95 | public Quat mul_(double d) { 96 | return mul((float) d, new Quat()); 97 | } 98 | 99 | public Quat mul(float f) { 100 | return mul(f, (Quat) this); 101 | } 102 | 103 | public Quat mul_(float f) { 104 | return mul(f, new Quat()); 105 | } 106 | 107 | public Quat mul(float f, Quat res) { 108 | return Quat.mul((Quat) this, f, res); 109 | } 110 | 111 | public static Quat mul(Quat x, float y, Quat res) { 112 | return res.set( 113 | x.w * y, 114 | x.x * y, 115 | x.y * y, 116 | x.z * y); 117 | } 118 | 119 | public Quat sub(Quat y) { 120 | return sub(y, (Quat) this); 121 | } 122 | 123 | public Quat sub_(Quat y) { 124 | return sub(y, new Quat()); 125 | } 126 | 127 | public Quat sub(Quat y, Quat res) { 128 | return sub((Quat) this, y, res); 129 | } 130 | 131 | public static Quat sub(Quat x, Quat y, Quat res) { 132 | res.w = x.w - y.w; 133 | res.x = x.x - y.x; 134 | res.y = x.y - y.y; 135 | res.z = x.z - y.z; 136 | return res; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/glm/quat/funcGeometric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.quat; 7 | 8 | import glm.vec._3.Vec3; 9 | 10 | /** 11 | * 12 | * @author elect 13 | */ 14 | abstract class funcGeometric extends funcCommon { 15 | 16 | public Quat angleAxis(float angle, Vec3 v) { 17 | return Quat.angleAxis(angle, v, (Quat) this); 18 | } 19 | 20 | public static Quat angleAxis_(float degAngle, Vec3 v) { 21 | return Quat.angleAxis(degAngle, v, new Quat()); 22 | } 23 | 24 | public static Quat angleAxis(float degAngle, Vec3 v, Quat res) { 25 | 26 | float a = degAngle; 27 | float s = (float) Math.sin(Math.toRadians(a) * 0.5f); 28 | 29 | res.w = (float) Math.cos(Math.toRadians(a) * 0.5f); 30 | res.x = v.x * s; 31 | res.y = v.y * s; 32 | res.z = v.z * s; 33 | 34 | return res; 35 | } 36 | 37 | public float dot(Quat q) { 38 | return w * q.w + x * q.x + y * q.y + z * q.z; 39 | } 40 | 41 | public static float dot(Quat q1, Quat q2) { 42 | return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; 43 | } 44 | 45 | public float length() { 46 | return length((Quat) this); 47 | } 48 | 49 | public static float length(Quat q) { 50 | return (float) Math.sqrt(dot(q, q)); 51 | } 52 | 53 | public Quat normalize() { 54 | return Quat.normalize((Quat) this, (Quat) this); 55 | } 56 | 57 | public Quat normalize_() { 58 | return Quat.normalize((Quat) this, new Quat()); 59 | } 60 | 61 | public Quat normalize(Quat res) { 62 | return Quat.normalize((Quat) this, res); 63 | } 64 | 65 | public static Quat normalize(Quat q, Quat res) { 66 | float len = length(q); 67 | if (len <= 0) { // Problem 68 | return new Quat(1, 0, 0, 0); 69 | } 70 | float oneOverLen = 1 / len; 71 | return res.set(q.w * oneOverLen, q.x * oneOverLen, q.y * oneOverLen, q.z * oneOverLen); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/BooleanOperators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | abstract class BooleanOperators extends BasicOperators { 13 | 14 | public boolean equals(Vec2 b) { 15 | return glm.Glm.equals((Vec2) this, b); 16 | } 17 | 18 | public boolean notEquals(Vec2 b) { 19 | return glm.Glm.notEquals((Vec2) this, b); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2; 7 | 8 | import glm.Glm; 9 | import glm.vec._2.bool.Vec2bool; 10 | 11 | /** 12 | * 13 | * @author elect 14 | */ 15 | abstract class FuncRelational extends funcGeometric { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec2) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec2) this); 23 | } 24 | 25 | public Vec2 not_() { 26 | return Glm.not((Vec2) this, new Vec2()); 27 | } 28 | 29 | public Vec2 not() { 30 | return Glm.not((Vec2) this, (Vec2) this); 31 | } 32 | 33 | public Vec2bool lessThan__(Vec2 b) { 34 | return Glm.lessThan((Vec2) this, b, new Vec2bool()); 35 | } 36 | 37 | public Vec2bool lessThan(Vec2 b, Vec2bool res) { 38 | return Glm.lessThan((Vec2) this, b, res); 39 | } 40 | 41 | public Vec2bool lessThanEqual__(Vec2 b) { 42 | return Glm.lessThanEqual((Vec2) this, b, new Vec2bool()); 43 | } 44 | 45 | public Vec2bool lessThanEqual(Vec2 b, Vec2bool res) { 46 | return Glm.lessThanEqual((Vec2) this, b, res); 47 | } 48 | 49 | public Vec2bool greaterThan__(Vec2 b) { 50 | return Glm.greaterThan((Vec2) this, b, new Vec2bool()); 51 | } 52 | 53 | public Vec2bool greaterThan(Vec2 b, Vec2bool res) { 54 | return Glm.greaterThan((Vec2) this, b, res); 55 | } 56 | 57 | public Vec2bool greaterThanEqual__(Vec2 b) { 58 | return Glm.greaterThanEqual((Vec2) this, b, new Vec2bool()); 59 | } 60 | 61 | public Vec2bool greaterThanEqual(Vec2 b, Vec2bool res) { 62 | return Glm.greaterThanEqual((Vec2) this, b, res); 63 | } 64 | 65 | public Vec2bool equal__(Vec2 b) { 66 | return Glm.equal((Vec2) this, b, new Vec2bool()); 67 | } 68 | 69 | public Vec2bool equal(Vec2 b, Vec2bool res) { 70 | return Glm.equal((Vec2) this, b, res); 71 | } 72 | 73 | public Vec2bool notEqual__(Vec2 b) { 74 | return Glm.notEqual((Vec2) this, b, new Vec2bool()); 75 | } 76 | 77 | public Vec2bool notEqual(Vec2 b, Vec2bool res) { 78 | return Glm.notEqual((Vec2) this, b, res); 79 | } 80 | 81 | public Vec2 lessThan(Vec2 b) { 82 | return Glm.lessThan((Vec2) this, b, (Vec2) this); 83 | } 84 | 85 | public Vec2 lessThan_(Vec2 b) { 86 | return Glm.lessThan((Vec2) this, b, new Vec2()); 87 | } 88 | 89 | public Vec2 lessThan(Vec2 b, Vec2 res) { 90 | return Glm.lessThan((Vec2) this, b, res); 91 | } 92 | 93 | public Vec2 lessThanEqual(Vec2 b) { 94 | return Glm.lessThanEqual((Vec2) this, b, (Vec2) this); 95 | } 96 | 97 | public Vec2 lessThanEqual_(Vec2 b) { 98 | return Glm.lessThanEqual((Vec2) this, b, new Vec2()); 99 | } 100 | 101 | public Vec2 lessThanEqual(Vec2 b, Vec2 res) { 102 | return Glm.lessThanEqual((Vec2) this, b, res); 103 | } 104 | 105 | public Vec2 greaterThan(Vec2 b) { 106 | return Glm.greaterThan((Vec2) this, b, (Vec2) this); 107 | } 108 | 109 | public Vec2 greaterThan_(Vec2 b) { 110 | return Glm.greaterThan((Vec2) this, b, new Vec2()); 111 | } 112 | 113 | public Vec2 greaterThan(Vec2 b, Vec2 res) { 114 | return Glm.greaterThan((Vec2) this, b, res); 115 | } 116 | 117 | public Vec2 greaterThanEqual(Vec2 b) { 118 | return Glm.greaterThanEqual((Vec2) this, b, (Vec2) this); 119 | } 120 | 121 | public Vec2 greaterThanEqual_(Vec2 b) { 122 | return Glm.greaterThanEqual((Vec2) this, b, new Vec2()); 123 | } 124 | 125 | public Vec2 greaterThanEqual(Vec2 b, Vec2 res) { 126 | return Glm.greaterThanEqual((Vec2) this, b, res); 127 | } 128 | 129 | public Vec2 equal(Vec2 b) { 130 | return Glm.equal((Vec2) this, b, (Vec2) this); 131 | } 132 | 133 | public Vec2 equal_(Vec2 b) { 134 | return Glm.equal((Vec2) this, b, new Vec2()); 135 | } 136 | 137 | public Vec2 equal(Vec2 b, Vec2 res) { 138 | return Glm.equal((Vec2) this, b, res); 139 | } 140 | 141 | public Vec2 notEqual(Vec2 b) { 142 | return Glm.notEqual((Vec2) this, b, (Vec2) this); 143 | } 144 | 145 | public Vec2 notEqual_(Vec2 b) { 146 | return Glm.notEqual((Vec2) this, b, new Vec2()); 147 | } 148 | 149 | public Vec2 notEqual(Vec2 b, Vec2 res) { 150 | return Glm.notEqual((Vec2) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/Vec2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2; 7 | 8 | import glm.vec._2.i.Vec2i; 9 | import glm.vec._3.Vec3; 10 | import glm.vec._4.Vec4; 11 | import java.nio.ByteBuffer; 12 | import java.nio.ByteOrder; 13 | import java.nio.FloatBuffer; 14 | 15 | /** 16 | * 17 | * @author GBarbieri 18 | */ 19 | public class Vec2 extends FuncRelational { 20 | 21 | public Vec2() { 22 | x = 0f; 23 | y = 0f; 24 | } 25 | 26 | public Vec2(float f) { 27 | x = f; 28 | y = f; 29 | } 30 | 31 | public Vec2(float x, float y) { 32 | this.x = x; 33 | this.y = y; 34 | } 35 | 36 | public Vec2(double f) { 37 | x = (float) f; 38 | y = (float) f; 39 | } 40 | 41 | public Vec2(double x, double y) { 42 | this.x = (float) x; 43 | this.y = (float) y; 44 | } 45 | 46 | public Vec2(Vec2 v) { 47 | x = v.x; 48 | y = v.y; 49 | } 50 | 51 | public Vec2(Vec2i v) { 52 | x = v.x; 53 | y = v.y; 54 | } 55 | 56 | public Vec2(Vec3 v) { 57 | x = v.x; 58 | y = v.y; 59 | } 60 | 61 | public Vec2(Vec4 v) { 62 | x = v.x; 63 | y = v.y; 64 | } 65 | 66 | public Vec2 set(float f) { 67 | x = f; 68 | y = f; 69 | return this; 70 | } 71 | 72 | public Vec2 set(double x, double y) { 73 | return set((float) x, (float) y); 74 | } 75 | 76 | public Vec2 set(float x, float y) { 77 | this.x = x; 78 | this.y = y; 79 | return this; 80 | } 81 | 82 | public Vec2 set(int[] ia) { 83 | x = ia[0]; 84 | y = ia[1]; 85 | return this; 86 | } 87 | 88 | public Vec2 set(float[] fa) { 89 | x = fa[0]; 90 | y = fa[1]; 91 | return this; 92 | } 93 | 94 | public float[] toFA_() { 95 | return toFA(new float[2]); 96 | } 97 | 98 | public float[] toFA(float[] fa) { 99 | fa[0] = x; 100 | fa[1] = y; 101 | return fa; 102 | } 103 | 104 | public FloatBuffer toDfb_() { 105 | return toDfb(ByteBuffer.allocateDirect(SIZE).order(ByteOrder.nativeOrder()).asFloatBuffer()); 106 | } 107 | 108 | public FloatBuffer toDfb(FloatBuffer fb) { 109 | return toDfb(fb, 0); 110 | } 111 | 112 | public FloatBuffer toDfb(FloatBuffer fb, int index) { 113 | return fb 114 | .put(index + 0, x) 115 | .put(index + 1, y); 116 | } 117 | 118 | public ByteBuffer toDbb_() { 119 | return toDbb(ByteBuffer.allocateDirect(SIZE).order(ByteOrder.nativeOrder())); 120 | } 121 | 122 | public ByteBuffer toDbb(ByteBuffer bb) { 123 | return toDbb(bb, 0); 124 | } 125 | 126 | public ByteBuffer toDbb(ByteBuffer bb, int index) { 127 | return bb 128 | .putFloat(index + 0 * Float.BYTES, x) 129 | .putFloat(index + 1 * Float.BYTES, y); 130 | } 131 | 132 | /** 133 | * Return the length of this vector. 134 | * 135 | * @return the length 136 | */ 137 | public float length() { 138 | return (float) Math.sqrt((x * x) + (y * y)); 139 | } 140 | 141 | /** 142 | * Normalize this vector. 143 | * 144 | * @return this 145 | */ 146 | public Vec2 normalize() { 147 | return normalize(this); 148 | } 149 | 150 | /** 151 | * Normalize this vector and store the result in dest. 152 | * 153 | * @param dest will hold the result 154 | * @return dest 155 | */ 156 | public Vec2 normalize(Vec2 dest) { 157 | float invLength = (float) (1.0 / Math.sqrt(x * x + y * y)); 158 | dest.x = x * invLength; 159 | dest.y = y * invLength; 160 | return dest; 161 | } 162 | 163 | @Override 164 | public String toString() { 165 | return "(" + x + ", " + y + ")"; 166 | } 167 | 168 | public void print() { 169 | print("", true); 170 | } 171 | 172 | public void print(String title) { 173 | print(title, true); 174 | } 175 | 176 | public void print(boolean outStream) { 177 | print("", outStream); 178 | } 179 | 180 | public void print(String title, boolean outStream) { 181 | String res = title + "\n(" + x + ", " + y + ")"; 182 | if (outStream) { 183 | System.out.print(res); 184 | } else { 185 | System.err.print(res); 186 | } 187 | } 188 | 189 | } 190 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/b/BooleanOperators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.b; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | abstract class BooleanOperators extends BasicOperators { 13 | 14 | public boolean equals(Vec2b b) { 15 | return glm.Glm.equals((Vec2b) this, b); 16 | } 17 | 18 | public boolean notEquals(Vec2b b) { 19 | return glm.Glm.notEquals((Vec2b) this, b); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/b/FuncCommon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.b; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | abstract class FuncCommon { 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/b/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.b; 7 | 8 | import glm.Glm; 9 | import glm.vec._2.bool.Vec2bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends BooleanOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec2b) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec2b) this); 23 | } 24 | 25 | public Vec2b not_() { 26 | return Glm.not((Vec2b) this, new Vec2b()); 27 | } 28 | 29 | public Vec2b not() { 30 | return Glm.not((Vec2b) this, (Vec2b) this); 31 | } 32 | 33 | public Vec2bool lessThan__(Vec2b b) { 34 | return Glm.lessThan((Vec2b) this, b, new Vec2bool()); 35 | } 36 | 37 | public Vec2bool lessThan(Vec2b b, Vec2bool res) { 38 | return Glm.lessThan((Vec2b) this, b, res); 39 | } 40 | 41 | public Vec2bool lessThanEqual__(Vec2b b) { 42 | return Glm.lessThanEqual((Vec2b) this, b, new Vec2bool()); 43 | } 44 | 45 | public Vec2bool lessThanEqual(Vec2b b, Vec2bool res) { 46 | return Glm.lessThanEqual((Vec2b) this, b, res); 47 | } 48 | 49 | public Vec2bool greaterThan__(Vec2b b) { 50 | return Glm.greaterThan((Vec2b) this, b, new Vec2bool()); 51 | } 52 | 53 | public Vec2bool greaterThan(Vec2b b, Vec2bool res) { 54 | return Glm.greaterThan((Vec2b) this, b, res); 55 | } 56 | 57 | public Vec2bool greaterThanEqual__(Vec2b b) { 58 | return Glm.greaterThanEqual((Vec2b) this, b, new Vec2bool()); 59 | } 60 | 61 | public Vec2bool greaterThanEqual(Vec2b b, Vec2bool res) { 62 | return Glm.greaterThanEqual((Vec2b) this, b, res); 63 | } 64 | 65 | public Vec2bool equal__(Vec2b b) { 66 | return Glm.equal((Vec2b) this, b, new Vec2bool()); 67 | } 68 | 69 | public Vec2bool equal(Vec2b b, Vec2bool res) { 70 | return Glm.equal((Vec2b) this, b, res); 71 | } 72 | 73 | public Vec2bool notEqual__(Vec2b b) { 74 | return Glm.notEqual((Vec2b) this, b, new Vec2bool()); 75 | } 76 | 77 | public Vec2bool notEqual(Vec2b b, Vec2bool res) { 78 | return Glm.notEqual((Vec2b) this, b, res); 79 | } 80 | 81 | public Vec2b lessThan(Vec2b b) { 82 | return Glm.lessThan((Vec2b) this, b, (Vec2b) this); 83 | } 84 | 85 | public Vec2b lessThan_(Vec2b b) { 86 | return Glm.lessThan((Vec2b) this, b, new Vec2b()); 87 | } 88 | 89 | public Vec2b lessThan(Vec2b b, Vec2b res) { 90 | return Glm.lessThan((Vec2b) this, b, res); 91 | } 92 | 93 | public Vec2b lessThanEqual(Vec2b b) { 94 | return Glm.lessThanEqual((Vec2b) this, b, (Vec2b) this); 95 | } 96 | 97 | public Vec2b lessThanEqual_(Vec2b b) { 98 | return Glm.lessThanEqual((Vec2b) this, b, new Vec2b()); 99 | } 100 | 101 | public Vec2b lessThanEqual(Vec2b b, Vec2b res) { 102 | return Glm.lessThanEqual((Vec2b) this, b, res); 103 | } 104 | 105 | public Vec2b greaterThan(Vec2b b) { 106 | return Glm.greaterThan((Vec2b) this, b, (Vec2b) this); 107 | } 108 | 109 | public Vec2b greaterThan_(Vec2b b) { 110 | return Glm.greaterThan((Vec2b) this, b, new Vec2b()); 111 | } 112 | 113 | public Vec2b greaterThan(Vec2b b, Vec2b res) { 114 | return Glm.greaterThan((Vec2b) this, b, res); 115 | } 116 | 117 | public Vec2b greaterThanEqual(Vec2b b) { 118 | return Glm.greaterThanEqual((Vec2b) this, b, (Vec2b) this); 119 | } 120 | 121 | public Vec2b greaterThanEqual_(Vec2b b) { 122 | return Glm.greaterThanEqual((Vec2b) this, b, new Vec2b()); 123 | } 124 | 125 | public Vec2b greaterThanEqual(Vec2b b, Vec2b res) { 126 | return Glm.greaterThanEqual((Vec2b) this, b, res); 127 | } 128 | 129 | public Vec2b equal(Vec2b b) { 130 | return Glm.equal((Vec2b) this, b, (Vec2b) this); 131 | } 132 | 133 | public Vec2b equal_(Vec2b b) { 134 | return Glm.equal((Vec2b) this, b, new Vec2b()); 135 | } 136 | 137 | public Vec2b equal(Vec2b b, Vec2b res) { 138 | return Glm.equal((Vec2b) this, b, res); 139 | } 140 | 141 | public Vec2b notEqual(Vec2b b) { 142 | return Glm.notEqual((Vec2b) this, b, (Vec2b) this); 143 | } 144 | 145 | public Vec2b notEqual_(Vec2b b) { 146 | return Glm.notEqual((Vec2b) this, b, new Vec2b()); 147 | } 148 | 149 | public Vec2b notEqual(Vec2b b, Vec2b res) { 150 | return Glm.notEqual((Vec2b) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/b/Vec2b.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.b; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | public class Vec2b extends FuncRelational { 13 | 14 | public Vec2b() { 15 | x = 0; 16 | y = 0; 17 | } 18 | 19 | public Vec2b(int s) { 20 | this((byte) s, (byte) s); 21 | } 22 | 23 | public Vec2b(int x, int y) { 24 | this((byte) x, (byte) y); 25 | } 26 | 27 | public Vec2b(byte x, byte y) { 28 | this.x = x; 29 | this.y = y; 30 | } 31 | 32 | public Vec2b set(int x, int y) { 33 | return set((byte) x, (byte) y); 34 | } 35 | 36 | public Vec2b set(byte x, byte y) { 37 | this.x = x; 38 | this.y = y; 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/bool/BooleanOperators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.bool; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | abstract class BooleanOperators { 13 | 14 | public static final int SIZE = 2 * Byte.BYTES; 15 | 16 | public boolean x, y; 17 | 18 | public boolean equals(Vec2bool b) { 19 | return x == b.x & y == b.y; 20 | } 21 | 22 | public boolean notEquals(Vec2bool b) { 23 | return x != b.x | y != b.y; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/bool/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.bool; 7 | 8 | import glm.Glm; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | abstract class FuncRelational extends BooleanOperators { 15 | 16 | public boolean any() { 17 | return Glm.any((Vec2bool) this); 18 | } 19 | 20 | public boolean all() { 21 | return Glm.all((Vec2bool) this); 22 | } 23 | 24 | public Vec2bool not_() { 25 | return Glm.not((Vec2bool) this, new Vec2bool()); 26 | } 27 | 28 | public Vec2bool not() { 29 | return Glm.not((Vec2bool) this, (Vec2bool) this); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/bool/Vec2bool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.bool; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec2bool extends FuncRelational { 13 | 14 | public Vec2bool() { 15 | } 16 | 17 | public Vec2bool(boolean x, boolean y) { 18 | this.x = x; 19 | this.y = y; 20 | } 21 | 22 | public Vec2bool set(boolean x, boolean y) { 23 | this.x = x; 24 | this.y = y; 25 | return this; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/d/BooleanOperators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.d; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | abstract class BooleanOperators extends ArithmeticOperators { 13 | 14 | public boolean equals(Vec2d b) { 15 | return x == b.x & y == b.y; 16 | } 17 | 18 | public boolean notEquals(Vec2d b) { 19 | return x != b.x | y != b.y; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/d/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.d; 7 | 8 | import glm.Glm; 9 | import glm.vec._2.bool.Vec2bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends BooleanOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec2d) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec2d) this); 23 | } 24 | 25 | public Vec2d not_() { 26 | return Glm.not((Vec2d) this, new Vec2d()); 27 | } 28 | 29 | public Vec2d not() { 30 | return Glm.not((Vec2d) this, (Vec2d) this); 31 | } 32 | 33 | public Vec2bool lessThan__(Vec2d b) { 34 | return Glm.lessThan((Vec2d) this, b, new Vec2bool()); 35 | } 36 | 37 | public Vec2bool lessThan(Vec2d b, Vec2bool res) { 38 | return Glm.lessThan((Vec2d) this, b, res); 39 | } 40 | 41 | public Vec2bool lessThanEqual__(Vec2d b) { 42 | return Glm.lessThanEqual((Vec2d) this, b, new Vec2bool()); 43 | } 44 | 45 | public Vec2bool lessThanEqual(Vec2d b, Vec2bool res) { 46 | return Glm.lessThanEqual((Vec2d) this, b, res); 47 | } 48 | 49 | public Vec2bool greaterThan__(Vec2d b) { 50 | return Glm.greaterThan((Vec2d) this, b, new Vec2bool()); 51 | } 52 | 53 | public Vec2bool greaterThan(Vec2d b, Vec2bool res) { 54 | return Glm.greaterThan((Vec2d) this, b, res); 55 | } 56 | 57 | public Vec2bool greaterThanEqual__(Vec2d b) { 58 | return Glm.greaterThanEqual((Vec2d) this, b, new Vec2bool()); 59 | } 60 | 61 | public Vec2bool greaterThanEqual(Vec2d b, Vec2bool res) { 62 | return Glm.greaterThanEqual((Vec2d) this, b, res); 63 | } 64 | 65 | public Vec2bool equal__(Vec2d b) { 66 | return Glm.equal((Vec2d) this, b, new Vec2bool()); 67 | } 68 | 69 | public Vec2bool equal(Vec2d b, Vec2bool res) { 70 | return Glm.equal((Vec2d) this, b, res); 71 | } 72 | 73 | public Vec2bool notEqual__(Vec2d b) { 74 | return Glm.notEqual((Vec2d) this, b, new Vec2bool()); 75 | } 76 | 77 | public Vec2bool notEqual(Vec2d b, Vec2bool res) { 78 | return Glm.notEqual((Vec2d) this, b, res); 79 | } 80 | 81 | public Vec2d lessThan(Vec2d b) { 82 | return Glm.lessThan((Vec2d) this, b, (Vec2d) this); 83 | } 84 | 85 | public Vec2d lessThan_(Vec2d b) { 86 | return Glm.lessThan((Vec2d) this, b, new Vec2d()); 87 | } 88 | 89 | public Vec2d lessThan(Vec2d b, Vec2d res) { 90 | return Glm.lessThan((Vec2d) this, b, res); 91 | } 92 | 93 | public Vec2d lessThanEqual(Vec2d b) { 94 | return Glm.lessThanEqual((Vec2d) this, b, (Vec2d) this); 95 | } 96 | 97 | public Vec2d lessThanEqual_(Vec2d b) { 98 | return Glm.lessThanEqual((Vec2d) this, b, new Vec2d()); 99 | } 100 | 101 | public Vec2d lessThanEqual(Vec2d b, Vec2d res) { 102 | return Glm.lessThanEqual((Vec2d) this, b, res); 103 | } 104 | 105 | public Vec2d greaterThan(Vec2d b) { 106 | return Glm.greaterThan((Vec2d) this, b, (Vec2d) this); 107 | } 108 | 109 | public Vec2d greaterThan_(Vec2d b) { 110 | return Glm.greaterThan((Vec2d) this, b, new Vec2d()); 111 | } 112 | 113 | public Vec2d greaterThan(Vec2d b, Vec2d res) { 114 | return Glm.greaterThan((Vec2d) this, b, res); 115 | } 116 | 117 | public Vec2d greaterThanEqual(Vec2d b) { 118 | return Glm.greaterThanEqual((Vec2d) this, b, (Vec2d) this); 119 | } 120 | 121 | public Vec2d greaterThanEqual_(Vec2d b) { 122 | return Glm.greaterThanEqual((Vec2d) this, b, new Vec2d()); 123 | } 124 | 125 | public Vec2d greaterThanEqual(Vec2d b, Vec2d res) { 126 | return Glm.greaterThanEqual((Vec2d) this, b, res); 127 | } 128 | 129 | public Vec2d equal(Vec2d b) { 130 | return Glm.equal((Vec2d) this, b, (Vec2d) this); 131 | } 132 | 133 | public Vec2d equal_(Vec2d b) { 134 | return Glm.equal((Vec2d) this, b, new Vec2d()); 135 | } 136 | 137 | public Vec2d equal(Vec2d b, Vec2d res) { 138 | return Glm.equal((Vec2d) this, b, res); 139 | } 140 | 141 | public Vec2d notEqual(Vec2d b) { 142 | return Glm.notEqual((Vec2d) this, b, (Vec2d) this); 143 | } 144 | 145 | public Vec2d notEqual_(Vec2d b) { 146 | return Glm.notEqual((Vec2d) this, b, new Vec2d()); 147 | } 148 | 149 | public Vec2d notEqual(Vec2d b, Vec2d res) { 150 | return Glm.notEqual((Vec2d) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/d/Vec2d.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.d; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | public class Vec2d extends FuncRelational { 13 | 14 | public Vec2d() { 15 | x = 0; 16 | y = 0; 17 | } 18 | 19 | public Vec2d(int x, int y) { 20 | this((double) x, (double) y); 21 | } 22 | 23 | public Vec2d(double x, double y) { 24 | this.x = x; 25 | this.y = y; 26 | } 27 | 28 | public Vec2d set(double x, double y) { 29 | this.x = x; 30 | this.y = y; 31 | return this; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/funcExponential.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2; 7 | 8 | import glm.Glm; 9 | 10 | /** 11 | * 12 | * @author elect 13 | */ 14 | abstract class funcExponential extends funcCommon { 15 | 16 | public Vec2 exp() { 17 | return exp((Vec2) this, (Vec2) this); 18 | } 19 | 20 | public Vec2 exp_() { 21 | return exp((Vec2) this); 22 | } 23 | 24 | public Vec2 exp(Vec2 result) { 25 | return exp((Vec2) this, result); 26 | } 27 | 28 | public static Vec2 exp(Vec2 x, Vec2 result) { 29 | result.x = (float) Math.exp(x.x); 30 | result.y = (float) Math.exp(x.y); 31 | return result; 32 | } 33 | 34 | public Vec2 exp2() { 35 | return exp2((Vec2) this, (Vec2) this); 36 | } 37 | 38 | public Vec2 exp2_() { 39 | return exp2((Vec2) this); 40 | } 41 | 42 | public Vec2 exp2(Vec2 result) { 43 | return exp2((Vec2) this, result); 44 | } 45 | 46 | public static Vec2 exp2(Vec2 x, Vec2 result) { 47 | result.x = (float) Math.pow(2, x.x); 48 | result.y = (float) Math.pow(2, x.y); 49 | return result; 50 | } 51 | 52 | public Vec2 inverseSqrt() { 53 | return inverseSqrt((Vec2) this); 54 | } 55 | 56 | public Vec2 inverseSqrt_() { 57 | return inverseSqrt(new Vec2()); 58 | } 59 | 60 | public Vec2 inverseSqrt(Vec2 result) { 61 | return inverseSqrt((Vec2) this, result); 62 | } 63 | 64 | public static Vec2 inverseSqrt(Vec2 x, Vec2 result) { 65 | result.x = Glm.inverseSqrt(x.x); 66 | result.y = Glm.inverseSqrt(x.y); 67 | return result; 68 | } 69 | 70 | public Vec2 log() { 71 | return log((Vec2) this); 72 | } 73 | 74 | public Vec2 log_() { 75 | return log(new Vec2()); 76 | } 77 | 78 | public Vec2 log(Vec2 result) { 79 | return log((Vec2) this, result); 80 | } 81 | 82 | public static Vec2 log(Vec2 x, Vec2 result) { 83 | result.x = (float) Math.log(x.x); 84 | result.y = (float) Math.log(x.y); 85 | return result; 86 | } 87 | 88 | public Vec2 log2() { 89 | return log2((Vec2) this); 90 | } 91 | 92 | public Vec2 log2_() { 93 | return log2(new Vec2()); 94 | } 95 | 96 | public Vec2 log2(Vec2 result) { 97 | return log2((Vec2) this, result); 98 | } 99 | 100 | public static Vec2 log2(Vec2 x, Vec2 result) { 101 | result.x = (float) (Math.log(x.x) / Math.log(2)); 102 | result.y = (float) (Math.log(x.y) / Math.log(2)); 103 | return result; 104 | } 105 | 106 | public Vec2 pow(Vec2 y) { 107 | return pow(y, (Vec2) this); 108 | } 109 | 110 | public Vec2 pow_(Vec2 y) { 111 | return pow(y, new Vec2()); 112 | } 113 | 114 | public Vec2 pow(Vec2 y, Vec2 result) { 115 | return pow((Vec2) this, y, result); 116 | } 117 | 118 | public static Vec2 pow(Vec2 x, Vec2 y, Vec2 result) { 119 | result.x = (float) Math.pow(x.x, y.x); 120 | result.y = (float) Math.pow(x.y, y.y); 121 | return result; 122 | } 123 | 124 | public Vec2 sqrt() { 125 | return sqrt((Vec2) this); 126 | } 127 | 128 | public Vec2 sqrt_() { 129 | return sqrt(new Vec2()); 130 | } 131 | 132 | public Vec2 sqrt(Vec2 result) { 133 | return sqrt((Vec2) this, result); 134 | } 135 | 136 | public static Vec2 sqrt(Vec2 x, Vec2 result) { 137 | result.x = (float) Math.sqrt(x.x); 138 | result.y = (float) Math.sqrt(x.y); 139 | return result; 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/funcGeometric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | abstract class funcGeometric extends funcExponential { 13 | 14 | public Vec2 cross(Vec2 y) { 15 | return cross(y, (Vec2) this); 16 | } 17 | 18 | public Vec2 cross_(Vec2 y) { 19 | return cross(y, new Vec2()); 20 | } 21 | 22 | public Vec2 cross(Vec2 y, Vec2 result) { 23 | return cross((Vec2) this, y, result); 24 | } 25 | 26 | public static Vec2 cross(Vec2 x, Vec2 y, Vec2 result) { 27 | result.y = x.x * y.y - y.x * x.y; 28 | result.x = 0f; 29 | return result; 30 | } 31 | 32 | public float distance(Vec2 p0, Vec2 p1) { 33 | float t0x = p0.x - p1.x; 34 | float t0y = p0.y - p1.y; 35 | float dot = t0x * t0y + t0x * t0y; 36 | return (float) Math.sqrt(dot); 37 | } 38 | 39 | public float dot(Vec2 y) { 40 | return dot((Vec2) this, y); 41 | } 42 | 43 | public static float dot(Vec2 x, Vec2 y) { 44 | float tX = x.x * y.x; 45 | float tY = x.y * y.y; 46 | return tX + tY; 47 | } 48 | 49 | public static float length(Vec2 x, Vec2 result) { 50 | return (float) Math.sqrt(dot(x, x)); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/i/BooleanOperators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.i; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | abstract class BooleanOperators extends ArithmeticOperators { 13 | 14 | public boolean equals(Vec2i b) { 15 | return x == b.x & y == b.y; 16 | } 17 | 18 | public boolean notEquals(Vec2i b) { 19 | return x != b.x | y != b.y; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/i/FuncCommon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.i; 7 | 8 | /** 9 | * 10 | * @author fschaefers 11 | */ 12 | abstract class FuncCommon extends FuncRelational { 13 | 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/i/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.i; 7 | 8 | import glm.Glm; 9 | import glm.vec._2.bool.Vec2bool; 10 | 11 | /** 12 | * 13 | * @author fschaefers 14 | */ 15 | abstract class FuncRelational extends BooleanOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec2i) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec2i) this); 23 | } 24 | 25 | public Vec2i not_() { 26 | return Glm.not((Vec2i) this, new Vec2i()); 27 | } 28 | 29 | public Vec2i not() { 30 | return Glm.not((Vec2i) this, (Vec2i) this); 31 | } 32 | 33 | public Vec2bool lessThan__(Vec2i b) { 34 | return Glm.lessThan((Vec2i) this, b, new Vec2bool()); 35 | } 36 | 37 | public Vec2bool lessThan(Vec2i b, Vec2bool res) { 38 | return Glm.lessThan((Vec2i) this, b, res); 39 | } 40 | 41 | public Vec2bool lessThanEqual__(Vec2i b) { 42 | return Glm.lessThanEqual((Vec2i) this, b, new Vec2bool()); 43 | } 44 | 45 | public Vec2bool lessThanEqual(Vec2i b, Vec2bool res) { 46 | return Glm.lessThanEqual((Vec2i) this, b, res); 47 | } 48 | 49 | public Vec2bool greaterThan__(Vec2i b) { 50 | return Glm.greaterThan((Vec2i) this, b, new Vec2bool()); 51 | } 52 | 53 | public Vec2bool greaterThan(Vec2i b, Vec2bool res) { 54 | return Glm.greaterThan((Vec2i) this, b, res); 55 | } 56 | 57 | public Vec2bool greaterThanEqual__(Vec2i b) { 58 | return Glm.greaterThanEqual((Vec2i) this, b, new Vec2bool()); 59 | } 60 | 61 | public Vec2bool greaterThanEqual(Vec2i b, Vec2bool res) { 62 | return Glm.greaterThanEqual((Vec2i) this, b, res); 63 | } 64 | 65 | public Vec2bool equal__(Vec2i b) { 66 | return Glm.equal((Vec2i) this, b, new Vec2bool()); 67 | } 68 | 69 | public Vec2bool equal(Vec2i b, Vec2bool res) { 70 | return Glm.equal((Vec2i) this, b, res); 71 | } 72 | 73 | public Vec2bool notEqual__(Vec2i b) { 74 | return Glm.notEqual((Vec2i) this, b, new Vec2bool()); 75 | } 76 | 77 | public Vec2bool notEqual(Vec2i b, Vec2bool res) { 78 | return Glm.notEqual((Vec2i) this, b, res); 79 | } 80 | 81 | public Vec2i lessThan(Vec2i b) { 82 | return Glm.lessThan((Vec2i) this, b, (Vec2i) this); 83 | } 84 | 85 | public Vec2i lessThan_(Vec2i b) { 86 | return Glm.lessThan((Vec2i) this, b, new Vec2i()); 87 | } 88 | 89 | public Vec2i lessThan(Vec2i b, Vec2i res) { 90 | return Glm.lessThan((Vec2i) this, b, res); 91 | } 92 | 93 | public Vec2i lessThanEqual(Vec2i b) { 94 | return Glm.lessThanEqual((Vec2i) this, b, (Vec2i) this); 95 | } 96 | 97 | public Vec2i lessThanEqual_(Vec2i b) { 98 | return Glm.lessThanEqual((Vec2i) this, b, new Vec2i()); 99 | } 100 | 101 | public Vec2i lessThanEqual(Vec2i b, Vec2i res) { 102 | return Glm.lessThanEqual((Vec2i) this, b, res); 103 | } 104 | 105 | public Vec2i greaterThan(Vec2i b) { 106 | return Glm.greaterThan((Vec2i) this, b, (Vec2i) this); 107 | } 108 | 109 | public Vec2i greaterThan_(Vec2i b) { 110 | return Glm.greaterThan((Vec2i) this, b, new Vec2i()); 111 | } 112 | 113 | public Vec2i greaterThan(Vec2i b, Vec2i res) { 114 | return Glm.greaterThan((Vec2i) this, b, res); 115 | } 116 | 117 | public Vec2i greaterThanEqual(Vec2i b) { 118 | return Glm.greaterThanEqual((Vec2i) this, b, (Vec2i) this); 119 | } 120 | 121 | public Vec2i greaterThanEqual_(Vec2i b) { 122 | return Glm.greaterThanEqual((Vec2i) this, b, new Vec2i()); 123 | } 124 | 125 | public Vec2i greaterThanEqual(Vec2i b, Vec2i res) { 126 | return Glm.greaterThanEqual((Vec2i) this, b, res); 127 | } 128 | 129 | public Vec2i equal(Vec2i b) { 130 | return Glm.equal((Vec2i) this, b, (Vec2i) this); 131 | } 132 | 133 | public Vec2i equal_(Vec2i b) { 134 | return Glm.equal((Vec2i) this, b, new Vec2i()); 135 | } 136 | 137 | public Vec2i equal(Vec2i b, Vec2i res) { 138 | return Glm.equal((Vec2i) this, b, res); 139 | } 140 | 141 | public Vec2i notEqual(Vec2i b) { 142 | return Glm.notEqual((Vec2i) this, b, (Vec2i) this); 143 | } 144 | 145 | public Vec2i notEqual_(Vec2i b) { 146 | return Glm.notEqual((Vec2i) this, b, new Vec2i()); 147 | } 148 | 149 | public Vec2i notEqual(Vec2i b, Vec2i res) { 150 | return Glm.notEqual((Vec2i) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/i/Vec2i.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.i; 7 | 8 | import java.nio.ByteBuffer; 9 | import java.nio.ByteOrder; 10 | import java.nio.IntBuffer; 11 | 12 | /** 13 | * 14 | * @author GBarbieri 15 | */ 16 | public class Vec2i extends FuncRelational { 17 | 18 | public Vec2i() { 19 | x = 0; 20 | y = 0; 21 | } 22 | 23 | public Vec2i(int i) { 24 | x = i; 25 | y = i; 26 | } 27 | 28 | public Vec2i(Vec2i v) { 29 | x = v.x; 30 | y = v.y; 31 | } 32 | 33 | public Vec2i(int x, int y) { 34 | this.x = x; 35 | this.y = y; 36 | } 37 | 38 | public Vec2i set(Vec2i v) { 39 | x = v.x; 40 | y = v.y; 41 | return this; 42 | } 43 | 44 | public Vec2i set(int x, int y) { 45 | this.x = x; 46 | this.y = y; 47 | return this; 48 | } 49 | 50 | public int[] toIA_() { 51 | return toIA_(new int[2]); 52 | } 53 | 54 | public int[] toIA_(int[] ia) { 55 | ia[0] = x; 56 | ia[1] = y; 57 | return ia; 58 | } 59 | 60 | public IntBuffer toDib_() { 61 | return toDib(ByteBuffer.allocateDirect(SIZE).order(ByteOrder.nativeOrder()).asIntBuffer()); 62 | } 63 | 64 | public IntBuffer toDib(IntBuffer ib) { 65 | return toDib(ib, 0); 66 | } 67 | 68 | public IntBuffer toDib(IntBuffer ib, int index) { 69 | return ib 70 | .put(index + 0, x) 71 | .put(index + 1, y); 72 | } 73 | 74 | public ByteBuffer toDbb_() { 75 | return toDbb(ByteBuffer.allocateDirect(SIZE).order(ByteOrder.nativeOrder())); 76 | } 77 | 78 | public ByteBuffer toDbb(ByteBuffer bb) { 79 | return toDbb(bb, 0); 80 | } 81 | 82 | public ByteBuffer toDbb(ByteBuffer bb, int index) { 83 | return bb 84 | .putInt(index + 0 * Integer.BYTES, x) 85 | .putInt(index + 1 * Integer.BYTES, y); 86 | } 87 | 88 | @Override 89 | public String toString() { 90 | return "(" + x + ", " + y + ")"; 91 | } 92 | 93 | public void print() { 94 | print("", true); 95 | } 96 | 97 | public void print(String title) { 98 | print(title, true); 99 | } 100 | 101 | public void print(boolean outStream) { 102 | print("", outStream); 103 | } 104 | 105 | public void print(String title, boolean outStream) { 106 | String res = title + "\n(" + x + ", " + y + ")"; 107 | if (outStream) { 108 | System.out.print(res); 109 | } else { 110 | System.err.print(res); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/l/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.l; 7 | 8 | import glm.Glm; 9 | import glm.vec._2.bool.Vec2bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec2l) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec2l) this); 23 | } 24 | 25 | public Vec2l not_() { 26 | return Glm.not((Vec2l) this, new Vec2l()); 27 | } 28 | 29 | public Vec2l not() { 30 | return Glm.not((Vec2l) this, (Vec2l) this); 31 | } 32 | 33 | public Vec2bool lessThan__(Vec2l b) { 34 | return Glm.lessThan((Vec2l) this, b, new Vec2bool()); 35 | } 36 | 37 | public Vec2bool lessThan(Vec2l a, Vec2l b, Vec2bool res) { 38 | return Glm.lessThan((Vec2l) this, b, res); 39 | } 40 | 41 | public Vec2bool lessThanEqual__(Vec2l b) { 42 | return Glm.lessThanEqual((Vec2l) this, b, new Vec2bool()); 43 | } 44 | 45 | public Vec2bool lessThanEqual(Vec2l b, Vec2bool res) { 46 | return Glm.lessThanEqual((Vec2l) this, b, res); 47 | } 48 | 49 | public Vec2bool greaterThan__(Vec2l b) { 50 | return Glm.greaterThan((Vec2l) this, b, new Vec2bool()); 51 | } 52 | 53 | public Vec2bool greaterThan(Vec2l b, Vec2bool res) { 54 | return Glm.greaterThan((Vec2l) this, b, res); 55 | } 56 | 57 | public Vec2bool greaterThanEqual__(Vec2l b) { 58 | return Glm.greaterThanEqual((Vec2l) this, b, new Vec2bool()); 59 | } 60 | 61 | public Vec2bool greaterThanEqual(Vec2l b, Vec2bool res) { 62 | return Glm.greaterThanEqual((Vec2l) this, b, res); 63 | } 64 | 65 | public Vec2bool equal__(Vec2l b) { 66 | return Glm.equal((Vec2l) this, b, new Vec2bool()); 67 | } 68 | 69 | public Vec2bool equal(Vec2l b, Vec2bool res) { 70 | return Glm.equal((Vec2l) this, b, res); 71 | } 72 | 73 | public Vec2bool notEqual__(Vec2l b) { 74 | return Glm.notEqual((Vec2l) this, b, new Vec2bool()); 75 | } 76 | 77 | public Vec2bool notEqual(Vec2l b, Vec2bool res) { 78 | return Glm.notEqual((Vec2l) this, b, res); 79 | } 80 | 81 | public Vec2l lessThan(Vec2l b) { 82 | return Glm.lessThan((Vec2l) this, b, (Vec2l) this); 83 | } 84 | 85 | public Vec2l lessThan_(Vec2l b) { 86 | return Glm.lessThan((Vec2l) this, b, new Vec2l()); 87 | } 88 | 89 | public Vec2l lessThan(Vec2l a, Vec2l b, Vec2l res) { 90 | return Glm.lessThan((Vec2l) this, b, res); 91 | } 92 | 93 | public Vec2l lessThanEqual(Vec2l b) { 94 | return Glm.lessThanEqual((Vec2l) this, b, (Vec2l) this); 95 | } 96 | 97 | public Vec2l lessThanEqual_(Vec2l b) { 98 | return Glm.lessThanEqual((Vec2l) this, b, new Vec2l()); 99 | } 100 | 101 | public Vec2l lessThanEqual(Vec2l b, Vec2l res) { 102 | return Glm.lessThanEqual((Vec2l) this, b, res); 103 | } 104 | 105 | public Vec2l greaterThan(Vec2l b) { 106 | return Glm.greaterThan((Vec2l) this, b, (Vec2l) this); 107 | } 108 | 109 | public Vec2l greaterThan_(Vec2l b) { 110 | return Glm.greaterThan((Vec2l) this, b, new Vec2l()); 111 | } 112 | 113 | public Vec2l greaterThan(Vec2l b, Vec2l res) { 114 | return Glm.greaterThan((Vec2l) this, b, res); 115 | } 116 | 117 | public Vec2l greaterThanEqual(Vec2l b) { 118 | return Glm.greaterThanEqual((Vec2l) this, b, (Vec2l) this); 119 | } 120 | 121 | public Vec2l greaterThanEqual_(Vec2l b) { 122 | return Glm.greaterThanEqual((Vec2l) this, b, new Vec2l()); 123 | } 124 | 125 | public Vec2l greaterThanEqual(Vec2l b, Vec2l res) { 126 | return Glm.greaterThanEqual((Vec2l) this, b, res); 127 | } 128 | 129 | public Vec2l equal(Vec2l b) { 130 | return Glm.equal((Vec2l) this, b, (Vec2l) this); 131 | } 132 | 133 | public Vec2l equal_(Vec2l b) { 134 | return Glm.equal((Vec2l) this, b, new Vec2l()); 135 | } 136 | 137 | public Vec2l equal(Vec2l b, Vec2l res) { 138 | return Glm.equal((Vec2l) this, b, res); 139 | } 140 | 141 | public Vec2l notEqual(Vec2l b) { 142 | return Glm.notEqual((Vec2l) this, b, (Vec2l) this); 143 | } 144 | 145 | public Vec2l notEqual_(Vec2l b) { 146 | return Glm.notEqual((Vec2l) this, b, new Vec2l()); 147 | } 148 | 149 | public Vec2l notEqual(Vec2l b, Vec2l res) { 150 | return Glm.notEqual((Vec2l) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/l/Vec2l.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.l; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec2l extends FuncRelational { 13 | 14 | public Vec2l() { 15 | x = 0; 16 | y = 0; 17 | } 18 | 19 | public Vec2l(int x, int y) { 20 | this((long) x, y); 21 | } 22 | 23 | public Vec2l(long x, long y) { 24 | this.x = x; 25 | this.y = y; 26 | } 27 | 28 | public Vec2l set(long x, long y) { 29 | this.x = x; 30 | this.y = y; 31 | return this; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/s/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.s; 7 | 8 | import glm.Glm; 9 | import glm.vec._2.bool.Vec2bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec2s) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec2s) this); 23 | } 24 | 25 | public Vec2s not_() { 26 | return Glm.not((Vec2s) this, new Vec2s()); 27 | } 28 | 29 | public Vec2s not() { 30 | return Glm.not((Vec2s) this, (Vec2s) this); 31 | } 32 | 33 | public Vec2bool lessThan__(Vec2s b) { 34 | return Glm.lessThan((Vec2s) this, b, new Vec2bool()); 35 | } 36 | 37 | public Vec2bool lessThan(Vec2s b, Vec2bool res) { 38 | return Glm.lessThan((Vec2s) this, b, res); 39 | } 40 | 41 | public Vec2bool lessThanEqual__(Vec2s b) { 42 | return Glm.lessThanEqual((Vec2s) this, b, new Vec2bool()); 43 | } 44 | 45 | public Vec2bool lessThanEqual(Vec2s b, Vec2bool res) { 46 | return Glm.lessThanEqual((Vec2s) this, b, res); 47 | } 48 | 49 | public Vec2bool greaterThan__(Vec2s b) { 50 | return Glm.greaterThan((Vec2s) this, b, new Vec2bool()); 51 | } 52 | 53 | public Vec2bool greaterThan(Vec2s b, Vec2bool res) { 54 | return Glm.greaterThan((Vec2s) this, b, res); 55 | } 56 | 57 | public Vec2bool greaterThanEqual__(Vec2s b) { 58 | return Glm.greaterThanEqual((Vec2s) this, b, new Vec2bool()); 59 | } 60 | 61 | public Vec2bool greaterThanEqual(Vec2s b, Vec2bool res) { 62 | return Glm.greaterThanEqual((Vec2s) this, b, res); 63 | } 64 | 65 | public Vec2bool equal__(Vec2s b) { 66 | return Glm.equal((Vec2s) this, b, new Vec2bool()); 67 | } 68 | 69 | public Vec2bool equal(Vec2s a, Vec2s b, Vec2bool res) { 70 | return Glm.equal((Vec2s) this, b, res); 71 | } 72 | 73 | public Vec2bool notEqual__(Vec2s b) { 74 | return Glm.notEqual((Vec2s) this, b, new Vec2bool()); 75 | } 76 | 77 | public Vec2bool notEqual(Vec2s b, Vec2bool res) { 78 | return Glm.notEqual((Vec2s) this, b, res); 79 | } 80 | 81 | public Vec2s lessThan(Vec2s b) { 82 | return Glm.lessThan((Vec2s) this, b, (Vec2s) this); 83 | } 84 | 85 | public Vec2s lessThan_(Vec2s b) { 86 | return Glm.lessThan((Vec2s) this, b, new Vec2s()); 87 | } 88 | 89 | public Vec2s lessThan(Vec2s b, Vec2s res) { 90 | return Glm.lessThan((Vec2s) this, b, res); 91 | } 92 | 93 | public Vec2s lessThanEqual(Vec2s b) { 94 | return Glm.lessThanEqual((Vec2s) this, b, (Vec2s) this); 95 | } 96 | 97 | public Vec2s lessThanEqual_(Vec2s b) { 98 | return Glm.lessThanEqual((Vec2s) this, b, new Vec2s()); 99 | } 100 | 101 | public Vec2s lessThanEqual(Vec2s b, Vec2s res) { 102 | return Glm.lessThanEqual((Vec2s) this, b, res); 103 | } 104 | 105 | public Vec2s greaterThan(Vec2s b) { 106 | return Glm.greaterThan((Vec2s) this, b, (Vec2s) this); 107 | } 108 | 109 | public Vec2s greaterThan_(Vec2s b) { 110 | return Glm.greaterThan((Vec2s) this, b, new Vec2s()); 111 | } 112 | 113 | public Vec2s greaterThan(Vec2s b, Vec2s res) { 114 | return Glm.greaterThan((Vec2s) this, b, res); 115 | } 116 | 117 | public Vec2s greaterThanEqual(Vec2s b) { 118 | return Glm.greaterThanEqual((Vec2s) this, b, (Vec2s) this); 119 | } 120 | 121 | public Vec2s greaterThanEqual_(Vec2s b) { 122 | return Glm.greaterThanEqual((Vec2s) this, b, new Vec2s()); 123 | } 124 | 125 | public Vec2s greaterThanEqual(Vec2s b, Vec2s res) { 126 | return Glm.greaterThanEqual((Vec2s) this, b, res); 127 | } 128 | 129 | public Vec2s equal(Vec2s b) { 130 | return Glm.equal((Vec2s) this, b, (Vec2s) this); 131 | } 132 | 133 | public Vec2s equal_(Vec2s b) { 134 | return Glm.equal((Vec2s) this, b, new Vec2s()); 135 | } 136 | 137 | public Vec2s equal(Vec2s a, Vec2s b, Vec2s res) { 138 | return Glm.equal((Vec2s) this, b, res); 139 | } 140 | 141 | public Vec2s notEqual(Vec2s b) { 142 | return Glm.notEqual((Vec2s) this, b, (Vec2s) this); 143 | } 144 | 145 | public Vec2s notEqual_(Vec2s b) { 146 | return Glm.notEqual((Vec2s) this, b, new Vec2s()); 147 | } 148 | 149 | public Vec2s notEqual(Vec2s b, Vec2s res) { 150 | return Glm.notEqual((Vec2s) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/s/Vec2s.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.s; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec2s extends FuncRelational { 13 | 14 | public Vec2s() { 15 | x = 0; 16 | y = 0; 17 | } 18 | 19 | public Vec2s(int x, int y) { 20 | this((short) x, (short) y); 21 | } 22 | 23 | public Vec2s(short x, short y) { 24 | this.x = x; 25 | this.y = y; 26 | } 27 | 28 | public Vec2s set(int x, int y) { 29 | return set((short) x, (short) y); 30 | } 31 | 32 | public Vec2s set(short x, short y) { 33 | this.x = x; 34 | this.y = y; 35 | return this; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/t/Vec2t.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.t; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | public class Vec2t { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/ub/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.ub; 7 | 8 | import glm.Glm; 9 | import glm.vec._2.bool.Vec2bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec2ub) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec2ub) this); 23 | } 24 | 25 | public Vec2ub not_() { 26 | return Glm.not((Vec2ub) this, new Vec2ub()); 27 | } 28 | 29 | public Vec2ub not() { 30 | return Glm.not((Vec2ub) this, (Vec2ub) this); 31 | } 32 | 33 | public Vec2bool lessThan__(Vec2ub b) { 34 | return Glm.lessThan((Vec2ub) this, b, new Vec2bool()); 35 | } 36 | 37 | public Vec2bool lessThan(Vec2ub b, Vec2bool res) { 38 | return Glm.lessThan((Vec2ub) this, b, res); 39 | } 40 | 41 | public Vec2bool lessThanEqual__(Vec2ub b) { 42 | return Glm.lessThanEqual((Vec2ub) this, b, new Vec2bool()); 43 | } 44 | 45 | public Vec2bool lessThanEqual(Vec2ub b, Vec2bool res) { 46 | return Glm.lessThanEqual((Vec2ub) this, b, res); 47 | } 48 | 49 | public Vec2bool greaterThan__(Vec2ub b) { 50 | return Glm.greaterThan((Vec2ub) this, b, new Vec2bool()); 51 | } 52 | 53 | public Vec2bool greaterThan(Vec2ub b, Vec2bool res) { 54 | return Glm.greaterThan((Vec2ub) this, b, res); 55 | } 56 | 57 | public Vec2bool greaterThanEqual__(Vec2ub b) { 58 | return Glm.greaterThanEqual((Vec2ub) this, b, new Vec2bool()); 59 | } 60 | 61 | public Vec2bool greaterThanEqual(Vec2ub b, Vec2bool res) { 62 | return Glm.greaterThanEqual((Vec2ub) this, b, res); 63 | } 64 | 65 | public Vec2bool equal__(Vec2ub b) { 66 | return Glm.equal((Vec2ub) this, b, new Vec2bool()); 67 | } 68 | 69 | public Vec2bool equal(Vec2ub b, Vec2bool res) { 70 | return Glm.equal((Vec2ub) this, b, res); 71 | } 72 | 73 | public Vec2bool notEqual__(Vec2ub b) { 74 | return Glm.notEqual((Vec2ub) this, b, new Vec2bool()); 75 | } 76 | 77 | public Vec2bool notEqual(Vec2ub b, Vec2bool res) { 78 | return Glm.notEqual((Vec2ub) this, b, res); 79 | } 80 | 81 | public Vec2ub lessThan(Vec2ub b) { 82 | return Glm.lessThan((Vec2ub) this, b, (Vec2ub) this); 83 | } 84 | 85 | public Vec2ub lessThan_(Vec2ub b) { 86 | return Glm.lessThan((Vec2ub) this, b, new Vec2ub()); 87 | } 88 | 89 | public Vec2ub lessThan(Vec2ub b, Vec2ub res) { 90 | return Glm.lessThan((Vec2ub) this, b, res); 91 | } 92 | 93 | public Vec2ub lessThanEqual(Vec2ub b) { 94 | return Glm.lessThanEqual((Vec2ub) this, b, (Vec2ub) this); 95 | } 96 | 97 | public Vec2ub lessThanEqual_(Vec2ub b) { 98 | return Glm.lessThanEqual((Vec2ub) this, b, new Vec2ub()); 99 | } 100 | 101 | public Vec2ub lessThanEqual(Vec2ub b, Vec2ub res) { 102 | return Glm.lessThanEqual((Vec2ub) this, b, res); 103 | } 104 | 105 | public Vec2ub greaterThan(Vec2ub b) { 106 | return Glm.greaterThan((Vec2ub) this, b, (Vec2ub) this); 107 | } 108 | 109 | public Vec2ub greaterThan_(Vec2ub b) { 110 | return Glm.greaterThan((Vec2ub) this, b, new Vec2ub()); 111 | } 112 | 113 | public Vec2ub greaterThan(Vec2ub b, Vec2ub res) { 114 | return Glm.greaterThan((Vec2ub) this, b, res); 115 | } 116 | 117 | public Vec2ub greaterThanEqual(Vec2ub b) { 118 | return Glm.greaterThanEqual((Vec2ub) this, b, (Vec2ub) this); 119 | } 120 | 121 | public Vec2ub greaterThanEqual_(Vec2ub b) { 122 | return Glm.greaterThanEqual((Vec2ub) this, b, new Vec2ub()); 123 | } 124 | 125 | public Vec2ub greaterThanEqual(Vec2ub b, Vec2ub res) { 126 | return Glm.greaterThanEqual((Vec2ub) this, b, res); 127 | } 128 | 129 | public Vec2ub equal(Vec2ub b) { 130 | return Glm.equal((Vec2ub) this, b, (Vec2ub) this); 131 | } 132 | 133 | public Vec2ub equal_(Vec2ub b) { 134 | return Glm.equal((Vec2ub) this, b, new Vec2ub()); 135 | } 136 | 137 | public Vec2ub equal(Vec2ub b, Vec2ub res) { 138 | return Glm.equal((Vec2ub) this, b, res); 139 | } 140 | 141 | public Vec2ub notEqual(Vec2ub b) { 142 | return Glm.notEqual((Vec2ub) this, b, (Vec2ub) this); 143 | } 144 | 145 | public Vec2ub notEqual_(Vec2ub b) { 146 | return Glm.notEqual((Vec2ub) this, b, new Vec2ub()); 147 | } 148 | 149 | public Vec2ub notEqual(Vec2ub b, Vec2ub res) { 150 | return Glm.notEqual((Vec2ub) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/ub/Vec2ub.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.ub; 7 | 8 | import joou.UByte; 9 | 10 | /** 11 | * 12 | * @author elect 13 | */ 14 | public class Vec2ub extends FuncRelational { 15 | 16 | public Vec2ub() { 17 | x.value = 0; 18 | y.value = 0; 19 | } 20 | 21 | public Vec2ub(int x, int y) { 22 | this((byte) x, (byte) y); 23 | } 24 | 25 | public Vec2ub(byte x, byte y) { 26 | this.x.value = x; 27 | this.y.value = y; 28 | } 29 | 30 | public Vec2ub set(UByte x, UByte y) { 31 | this.x = x; 32 | this.y = y; 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/ui/FuncCommon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.ui; 7 | 8 | import glm.Glm; 9 | import joou.UInt; 10 | 11 | /** 12 | * 13 | * @author fschaefers 14 | */ 15 | abstract class FuncCommon extends FuncRelational{ 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/ui/Vec2ui.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.ui; 7 | 8 | import glm.vec._2.i.Vec2i; 9 | import glm.vec._3.Vec3; 10 | import glm.vec._4.Vec4; 11 | import java.nio.ByteBuffer; 12 | import java.nio.ByteOrder; 13 | import java.nio.IntBuffer; 14 | import joou.UInt; 15 | 16 | /** 17 | * 18 | * @author GBarbieri 19 | */ 20 | public class Vec2ui extends FuncRelational { 21 | 22 | public Vec2ui() { 23 | x.value = 0; 24 | y.value = 0; 25 | } 26 | 27 | public Vec2ui(int i) { 28 | x.value = i; 29 | y.value = i; 30 | } 31 | 32 | public Vec2ui(int x, int y) { 33 | this.x.value = x; 34 | this.y.value = y; 35 | } 36 | 37 | public Vec2ui(Vec2ui v) { 38 | x = v.x; 39 | y = v.y; 40 | } 41 | 42 | public Vec2ui(Vec2i v) { 43 | x.value = v.x; 44 | y.value = v.y; 45 | } 46 | 47 | public Vec2ui(Vec3 v) { 48 | x.value = (int) v.x; 49 | y.value = (int) v.y; 50 | } 51 | 52 | public Vec2ui(Vec4 v) { 53 | x.value = (int) v.x; 54 | y.value = (int) v.y;; 55 | } 56 | 57 | public Vec2ui set(int i) { 58 | x.value = i; 59 | y.value = i; 60 | return this; 61 | } 62 | 63 | public Vec2ui set(UInt x, UInt y) { 64 | this.x = x; 65 | this.y = y; 66 | return this; 67 | } 68 | 69 | public Vec2ui set(float x, float y) { 70 | this.x.value = (int) x; 71 | this.y.value = (int) y; 72 | return this; 73 | } 74 | 75 | public Vec2ui set(int[] ia) { 76 | x.value = ia[0]; 77 | y.value = ia[1]; 78 | return this; 79 | } 80 | 81 | public float[] toIa_() { 82 | return toIa(new float[2]); 83 | } 84 | 85 | public float[] toIa(float[] fa) { 86 | fa[0] = x.value; 87 | fa[1] = y.value; 88 | return fa; 89 | } 90 | 91 | public IntBuffer toDib_() { 92 | return toDib(ByteBuffer.allocateDirect(SIZE).order(ByteOrder.nativeOrder()).asIntBuffer()); 93 | } 94 | 95 | public IntBuffer toDib(IntBuffer ib) { 96 | return toDib(ib, 0); 97 | } 98 | 99 | public IntBuffer toDib(IntBuffer ib, int index) { 100 | return ib 101 | .put(index + 0, (int) x.value) 102 | .put(index + 1, (int) y.value); 103 | } 104 | 105 | public ByteBuffer toDbb_() { 106 | return toDbb(ByteBuffer.allocateDirect(SIZE).order(ByteOrder.nativeOrder())); 107 | } 108 | 109 | public ByteBuffer toDbb(ByteBuffer bb) { 110 | return toDbb(bb, 0); 111 | } 112 | 113 | public ByteBuffer toDbb(ByteBuffer bb, int index) { 114 | return bb 115 | .putInt(index + 0 * Integer.BYTES, (int) x.value) 116 | .putInt(index + 1 * Integer.BYTES, (int) y.value); 117 | } 118 | 119 | @Override 120 | public String toString() { 121 | return "(" + x + ", " + y + ")"; 122 | } 123 | 124 | public void print() { 125 | print("", true); 126 | } 127 | 128 | public void print(String title) { 129 | print(title, true); 130 | } 131 | 132 | public void print(boolean outStream) { 133 | print("", outStream); 134 | } 135 | 136 | public void print(String title, boolean outStream) { 137 | String res = title + "\n(" + x + ", " + y + ")"; 138 | if (outStream) { 139 | System.out.print(res); 140 | } else { 141 | System.err.print(res); 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/ul/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.ul; 7 | 8 | import glm.Glm; 9 | import glm.vec._2.bool.Vec2bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec2ul) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec2ul) this); 23 | } 24 | 25 | public Vec2ul not_() { 26 | return Glm.not((Vec2ul) this, new Vec2ul()); 27 | } 28 | 29 | public Vec2ul not() { 30 | return Glm.not((Vec2ul) this, (Vec2ul) this); 31 | } 32 | 33 | public Vec2bool lessThan__(Vec2ul b) { 34 | return Glm.lessThan((Vec2ul) this, b, new Vec2bool()); 35 | } 36 | 37 | public Vec2bool lessThan(Vec2ul b, Vec2bool res) { 38 | return Glm.lessThan((Vec2ul) this, b, res); 39 | } 40 | 41 | public Vec2bool lessThanEqual__(Vec2ul b) { 42 | return Glm.lessThanEqual((Vec2ul) this, b, new Vec2bool()); 43 | } 44 | 45 | public Vec2bool lessThanEqual(Vec2ul b, Vec2bool res) { 46 | return Glm.lessThanEqual((Vec2ul) this, b, res); 47 | } 48 | 49 | public Vec2bool greaterThan__(Vec2ul b) { 50 | return Glm.greaterThan((Vec2ul) this, b, new Vec2bool()); 51 | } 52 | 53 | public Vec2bool greaterThan(Vec2ul b, Vec2bool res) { 54 | return Glm.greaterThan((Vec2ul) this, b, res); 55 | } 56 | 57 | public Vec2bool greaterThanEqual__(Vec2ul b) { 58 | return Glm.greaterThanEqual((Vec2ul) this, b, new Vec2bool()); 59 | } 60 | 61 | public Vec2bool greaterThanEqual(Vec2ul b, Vec2bool res) { 62 | return Glm.greaterThanEqual((Vec2ul) this, b, res); 63 | } 64 | 65 | public Vec2bool equal__(Vec2ul b) { 66 | return Glm.equal((Vec2ul) this, b, new Vec2bool()); 67 | } 68 | 69 | public Vec2bool equal(Vec2ul b, Vec2bool res) { 70 | return Glm.equal((Vec2ul) this, b, res); 71 | } 72 | 73 | public Vec2bool notEqual__(Vec2ul b) { 74 | return Glm.notEqual((Vec2ul) this, b, new Vec2bool()); 75 | } 76 | 77 | public Vec2bool notEqual(Vec2ul b, Vec2bool res) { 78 | return Glm.notEqual((Vec2ul) this, b, res); 79 | } 80 | 81 | public Vec2ul lessThan(Vec2ul b) { 82 | return Glm.lessThan((Vec2ul) this, b, (Vec2ul) this); 83 | } 84 | 85 | public Vec2ul lessThan_(Vec2ul b) { 86 | return Glm.lessThan((Vec2ul) this, b, new Vec2ul()); 87 | } 88 | 89 | public Vec2ul lessThan(Vec2ul b, Vec2ul res) { 90 | return Glm.lessThan((Vec2ul) this, b, res); 91 | } 92 | 93 | public Vec2ul lessThanEqual(Vec2ul b) { 94 | return Glm.lessThanEqual((Vec2ul) this, b, (Vec2ul) this); 95 | } 96 | 97 | public Vec2ul lessThanEqual_(Vec2ul b) { 98 | return Glm.lessThanEqual((Vec2ul) this, b, new Vec2ul()); 99 | } 100 | 101 | public Vec2ul lessThanEqual(Vec2ul b, Vec2ul res) { 102 | return Glm.lessThanEqual((Vec2ul) this, b, res); 103 | } 104 | 105 | public Vec2ul greaterThan(Vec2ul b) { 106 | return Glm.greaterThan((Vec2ul) this, b, (Vec2ul) this); 107 | } 108 | 109 | public Vec2ul greaterThan_(Vec2ul b) { 110 | return Glm.greaterThan((Vec2ul) this, b, new Vec2ul()); 111 | } 112 | 113 | public Vec2ul greaterThan(Vec2ul b, Vec2ul res) { 114 | return Glm.greaterThan((Vec2ul) this, b, res); 115 | } 116 | 117 | public Vec2ul greaterThanEqual(Vec2ul b) { 118 | return Glm.greaterThanEqual((Vec2ul) this, b, (Vec2ul) this); 119 | } 120 | 121 | public Vec2ul greaterThanEqual_(Vec2ul b) { 122 | return Glm.greaterThanEqual((Vec2ul) this, b, new Vec2ul()); 123 | } 124 | 125 | public Vec2ul greaterThanEqual(Vec2ul b, Vec2ul res) { 126 | return Glm.greaterThanEqual((Vec2ul) this, b, res); 127 | } 128 | 129 | public Vec2ul equal(Vec2ul b) { 130 | return Glm.equal((Vec2ul) this, b, (Vec2ul) this); 131 | } 132 | 133 | public Vec2ul equal_(Vec2ul b) { 134 | return Glm.equal((Vec2ul) this, b, new Vec2ul()); 135 | } 136 | 137 | public Vec2ul equal(Vec2ul b, Vec2ul res) { 138 | return Glm.equal((Vec2ul) this, b, res); 139 | } 140 | 141 | public Vec2ul notEqual(Vec2ul b) { 142 | return Glm.notEqual((Vec2ul) this, b, (Vec2ul) this); 143 | } 144 | 145 | public Vec2ul notEqual_(Vec2ul b) { 146 | return Glm.notEqual((Vec2ul) this, b, new Vec2ul()); 147 | } 148 | 149 | public Vec2ul notEqual(Vec2ul b, Vec2ul res) { 150 | return Glm.notEqual((Vec2ul) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/ul/Vec2ul.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.ul; 7 | 8 | import joou.ULong; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | public class Vec2ul extends FuncRelational { 15 | 16 | public Vec2ul() { 17 | x.value = 0; 18 | y.value = 0; 19 | } 20 | 21 | public Vec2ul(int x, int y) { 22 | this((long) x, y); 23 | } 24 | 25 | public Vec2ul(long x, long y) { 26 | this.x.value = x; 27 | this.y.value = y; 28 | } 29 | 30 | public Vec2ul set(ULong x, ULong y) { 31 | this.x = x; 32 | this.y = y; 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_2/us/Vec2us.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._2.us; 7 | 8 | import joou.UShort; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | public class Vec2us extends FuncRelational { 15 | 16 | public Vec2us() { 17 | x.value = 0; 18 | y.value = 0; 19 | } 20 | 21 | public Vec2us(int x, int y) { 22 | this((short) x, (short) y); 23 | } 24 | 25 | public Vec2us(short x, short y) { 26 | this.x.value = x; 27 | this.y.value = y; 28 | } 29 | 30 | public Vec2us set(UShort x, UShort y) { 31 | this.x = x; 32 | this.y = y; 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/b/FuncCommon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.b; 7 | 8 | import glm.vec._2.b.*; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | abstract class FuncCommon { 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/b/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.b; 7 | 8 | import glm.Glm; 9 | import glm.vec._3.bool.Vec3bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec3b) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec3b) this); 23 | } 24 | 25 | public Vec3b not_() { 26 | return Glm.not((Vec3b) this, new Vec3b()); 27 | } 28 | 29 | public Vec3b not() { 30 | return Glm.not((Vec3b) this, (Vec3b) this); 31 | } 32 | 33 | public Vec3bool lessThan__(Vec3b b) { 34 | return Glm.lessThan((Vec3b) this, b, new Vec3bool()); 35 | } 36 | 37 | public Vec3bool lessThan(Vec3b b, Vec3bool res) { 38 | return Glm.lessThan((Vec3b) this, b, res); 39 | } 40 | 41 | public Vec3bool lessThanEqual__(Vec3b b) { 42 | return Glm.lessThanEqual((Vec3b) this, b, new Vec3bool()); 43 | } 44 | 45 | public Vec3bool lessThanEqual(Vec3b b, Vec3bool res) { 46 | return Glm.lessThanEqual((Vec3b) this, b, res); 47 | } 48 | 49 | public Vec3bool greaterThan__(Vec3b b) { 50 | return Glm.greaterThan((Vec3b) this, b, new Vec3bool()); 51 | } 52 | 53 | public Vec3bool greaterThan(Vec3b b, Vec3bool res) { 54 | return Glm.greaterThan((Vec3b) this, b, res); 55 | } 56 | 57 | public Vec3bool greaterThanEqual__(Vec3b b) { 58 | return Glm.greaterThanEqual((Vec3b) this, b, new Vec3bool()); 59 | } 60 | 61 | public Vec3bool greaterThanEqual(Vec3b b, Vec3bool res) { 62 | return Glm.greaterThanEqual((Vec3b) this, b, res); 63 | } 64 | 65 | public Vec3bool equal__(Vec3b b) { 66 | return Glm.equal((Vec3b) this, b, new Vec3bool()); 67 | } 68 | 69 | public Vec3bool equal(Vec3b b, Vec3bool res) { 70 | return Glm.equal((Vec3b) this, b, res); 71 | } 72 | 73 | public Vec3bool notEqual__(Vec3b b) { 74 | return Glm.notEqual((Vec3b) this, b, new Vec3bool()); 75 | } 76 | 77 | public Vec3bool notEqual(Vec3b b, Vec3bool res) { 78 | return Glm.notEqual((Vec3b) this, b, res); 79 | } 80 | 81 | public Vec3b lessThan(Vec3b b) { 82 | return Glm.lessThan((Vec3b) this, b, (Vec3b) this); 83 | } 84 | 85 | public Vec3b lessThan_(Vec3b b) { 86 | return Glm.lessThan((Vec3b) this, b, new Vec3b()); 87 | } 88 | 89 | public Vec3b lessThan(Vec3b b, Vec3b res) { 90 | return Glm.lessThan((Vec3b) this, b, res); 91 | } 92 | 93 | public Vec3b lessThanEqual(Vec3b b) { 94 | return Glm.lessThanEqual((Vec3b) this, b, (Vec3b) this); 95 | } 96 | 97 | public Vec3b lessThanEqual_(Vec3b b) { 98 | return Glm.lessThanEqual((Vec3b) this, b, new Vec3b()); 99 | } 100 | 101 | public Vec3b lessThanEqual(Vec3b b, Vec3b res) { 102 | return Glm.lessThanEqual((Vec3b) this, b, res); 103 | } 104 | 105 | public Vec3b greaterThan(Vec3b b) { 106 | return Glm.greaterThan((Vec3b) this, b, (Vec3b) this); 107 | } 108 | 109 | public Vec3b greaterThan_(Vec3b b) { 110 | return Glm.greaterThan((Vec3b) this, b, new Vec3b()); 111 | } 112 | 113 | public Vec3b greaterThan(Vec3b b, Vec3b res) { 114 | return Glm.greaterThan((Vec3b) this, b, res); 115 | } 116 | 117 | public Vec3b greaterThanEqual(Vec3b b) { 118 | return Glm.greaterThanEqual((Vec3b) this, b, (Vec3b) this); 119 | } 120 | 121 | public Vec3b greaterThanEqual_(Vec3b b) { 122 | return Glm.greaterThanEqual((Vec3b) this, b, new Vec3b()); 123 | } 124 | 125 | public Vec3b greaterThanEqual(Vec3b b, Vec3b res) { 126 | return Glm.greaterThanEqual((Vec3b) this, b, res); 127 | } 128 | 129 | public Vec3b equal(Vec3b b) { 130 | return Glm.equal((Vec3b) this, b, (Vec3b) this); 131 | } 132 | 133 | public Vec3b equal_(Vec3b b) { 134 | return Glm.equal((Vec3b) this, b, new Vec3b()); 135 | } 136 | 137 | public Vec3b equal(Vec3b b, Vec3b res) { 138 | return Glm.equal((Vec3b) this, b, res); 139 | } 140 | 141 | public Vec3b notEqual(Vec3b b) { 142 | return Glm.notEqual((Vec3b) this, b, (Vec3b) this); 143 | } 144 | 145 | public Vec3b notEqual_(Vec3b b) { 146 | return Glm.notEqual((Vec3b) this, b, new Vec3b()); 147 | } 148 | 149 | public Vec3b notEqual(Vec3b b, Vec3b res) { 150 | return Glm.notEqual((Vec3b) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/b/Vec3b.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.b; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | public class Vec3b extends FuncRelational{ 13 | 14 | 15 | 16 | public Vec3b() { 17 | this(0); 18 | } 19 | 20 | public Vec3b(int i) { 21 | this(i, i, i); 22 | } 23 | 24 | public Vec3b(byte b) { 25 | this(b, b, b); 26 | } 27 | 28 | public Vec3b(byte x, byte y, byte z) { 29 | this.x = x; 30 | this.y = y; 31 | this.z = z; 32 | } 33 | 34 | public Vec3b(int x, int y, int z) { 35 | this.x = (byte) x; 36 | this.y = (byte) y; 37 | this.z = (byte) z; 38 | } 39 | 40 | public Vec3b set(int x, int y, int z) { 41 | return set((byte) x, (byte) y, (byte) z); 42 | } 43 | 44 | public Vec3b set(byte x, byte y, byte z) { 45 | this.x = x; 46 | this.y = y; 47 | this.z = z; 48 | return this; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/bool/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.bool; 7 | 8 | import glm.Glm; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | abstract class FuncRelational { 15 | 16 | public static final int SIZE = 3 * Byte.BYTES; 17 | 18 | public boolean x, y, z; 19 | 20 | public boolean any() { 21 | return Glm.any((Vec3bool) this); 22 | } 23 | 24 | public boolean all() { 25 | return Glm.all((Vec3bool) this); 26 | } 27 | 28 | public Vec3bool not_() { 29 | return Glm.not((Vec3bool) this, new Vec3bool()); 30 | } 31 | 32 | public Vec3bool not() { 33 | return Glm.not((Vec3bool) this, (Vec3bool) this); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/bool/Vec3bool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.bool; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec3bool extends FuncRelational { 13 | 14 | public Vec3bool() { 15 | } 16 | 17 | public Vec3bool(boolean x, boolean y, boolean z) { 18 | this.x = x; 19 | this.y = y; 20 | this.z = z; 21 | } 22 | 23 | public Vec3bool set(boolean x, boolean y, boolean z) { 24 | this.x = x; 25 | this.y = y; 26 | this.z = z; 27 | return this; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/d/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.d; 7 | 8 | import glm.Glm; 9 | import glm.vec._3.bool.Vec3bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec3d) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec3d) this); 23 | } 24 | 25 | public Vec3d not_() { 26 | return Glm.not((Vec3d) this, new Vec3d()); 27 | } 28 | 29 | public Vec3d not() { 30 | return Glm.not((Vec3d) this, (Vec3d) this); 31 | } 32 | 33 | public Vec3bool lessThan__(Vec3d b) { 34 | return Glm.lessThan((Vec3d) this, b, new Vec3bool()); 35 | } 36 | 37 | public Vec3bool lessThan(Vec3d b, Vec3bool res) { 38 | return Glm.lessThan((Vec3d) this, b, res); 39 | } 40 | 41 | public Vec3bool lessThanEqual__(Vec3d b) { 42 | return Glm.lessThanEqual((Vec3d) this, b, new Vec3bool()); 43 | } 44 | 45 | public Vec3bool lessThanEqual(Vec3d b, Vec3bool res) { 46 | return Glm.lessThanEqual((Vec3d) this, b, res); 47 | } 48 | 49 | public Vec3bool greaterThan__(Vec3d b) { 50 | return Glm.greaterThan((Vec3d) this, b, new Vec3bool()); 51 | } 52 | 53 | public Vec3bool greaterThan(Vec3d b, Vec3bool res) { 54 | return Glm.greaterThan((Vec3d) this, b, res); 55 | } 56 | 57 | public Vec3bool greaterThanEqual__(Vec3d b) { 58 | return Glm.greaterThanEqual((Vec3d) this, b, new Vec3bool()); 59 | } 60 | 61 | public Vec3bool greaterThanEqual(Vec3d b, Vec3bool res) { 62 | return Glm.greaterThanEqual((Vec3d) this, b, res); 63 | } 64 | 65 | public Vec3bool equal__(Vec3d b) { 66 | return Glm.equal((Vec3d) this, b, new Vec3bool()); 67 | } 68 | 69 | public Vec3bool equal(Vec3d b, Vec3bool res) { 70 | return Glm.equal((Vec3d) this, b, res); 71 | } 72 | 73 | public Vec3bool notEqual__(Vec3d b) { 74 | return Glm.notEqual((Vec3d) this, b, new Vec3bool()); 75 | } 76 | 77 | public Vec3bool notEqual(Vec3d b, Vec3bool res) { 78 | return Glm.notEqual((Vec3d) this, b, res); 79 | } 80 | 81 | public Vec3d lessThan(Vec3d b) { 82 | return Glm.lessThan((Vec3d) this, b, (Vec3d) this); 83 | } 84 | 85 | public Vec3d lessThan_(Vec3d b) { 86 | return Glm.lessThan((Vec3d) this, b, new Vec3d()); 87 | } 88 | 89 | public Vec3d lessThan(Vec3d b, Vec3d res) { 90 | return Glm.lessThan((Vec3d) this, b, res); 91 | } 92 | 93 | public Vec3d lessThanEqual(Vec3d b) { 94 | return Glm.lessThanEqual((Vec3d) this, b, (Vec3d) this); 95 | } 96 | 97 | public Vec3d lessThanEqual_(Vec3d b) { 98 | return Glm.lessThanEqual((Vec3d) this, b, new Vec3d()); 99 | } 100 | 101 | public Vec3d lessThanEqual(Vec3d b, Vec3d res) { 102 | return Glm.lessThanEqual((Vec3d) this, b, res); 103 | } 104 | 105 | public Vec3d greaterThan(Vec3d b) { 106 | return Glm.greaterThan((Vec3d) this, b, (Vec3d) this); 107 | } 108 | 109 | public Vec3d greaterThan_(Vec3d b) { 110 | return Glm.greaterThan((Vec3d) this, b, new Vec3d()); 111 | } 112 | 113 | public Vec3d greaterThan(Vec3d b, Vec3d res) { 114 | return Glm.greaterThan((Vec3d) this, b, res); 115 | } 116 | 117 | public Vec3d greaterThanEqual(Vec3d b) { 118 | return Glm.greaterThanEqual((Vec3d) this, b, (Vec3d) this); 119 | } 120 | 121 | public Vec3d greaterThanEqual_(Vec3d b) { 122 | return Glm.greaterThanEqual((Vec3d) this, b, new Vec3d()); 123 | } 124 | 125 | public Vec3d greaterThanEqual(Vec3d b, Vec3d res) { 126 | return Glm.greaterThanEqual((Vec3d) this, b, res); 127 | } 128 | 129 | public Vec3d equal(Vec3d b) { 130 | return Glm.equal((Vec3d) this, b, (Vec3d) this); 131 | } 132 | 133 | public Vec3d equal_(Vec3d b) { 134 | return Glm.equal((Vec3d) this, b, new Vec3d()); 135 | } 136 | 137 | public Vec3d equal(Vec3d b, Vec3d res) { 138 | return Glm.equal((Vec3d) this, b, res); 139 | } 140 | 141 | public Vec3d notEqual(Vec3d b) { 142 | return Glm.notEqual((Vec3d) this, b, (Vec3d) this); 143 | } 144 | 145 | public Vec3d notEqual_(Vec3d b) { 146 | return Glm.notEqual((Vec3d) this, b, new Vec3d()); 147 | } 148 | 149 | public Vec3d notEqual(Vec3d b, Vec3d res) { 150 | return Glm.notEqual((Vec3d) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/d/Vec3d.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.d; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec3d extends FuncRelational { 13 | 14 | public Vec3d() { 15 | x = 0; 16 | y = 0; 17 | } 18 | 19 | public Vec3d(int x, int y, int z) { 20 | this((double) x, y, z); 21 | } 22 | 23 | public Vec3d(double x, double y, double z) { 24 | this.x = x; 25 | this.y = y; 26 | this.z = z; 27 | } 28 | 29 | public Vec3d set(double x, double y, double z) { 30 | this.x = x; 31 | this.y = y; 32 | this.z = z; 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/funcGeometric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | abstract class funcGeometric extends funcCommon { 13 | 14 | public Vec3 cross(Vec3 y) { 15 | return cross(y, (Vec3) this); 16 | } 17 | 18 | public Vec3 cross_(Vec3 y) { 19 | return cross(y, new Vec3()); 20 | } 21 | 22 | public Vec3 cross(Vec3 y, Vec3 res) { 23 | return cross((Vec3) this, y, res); 24 | } 25 | 26 | public static Vec3 cross(Vec3 x, Vec3 y, Vec3 res) { 27 | return res.set( 28 | x.y * y.z - y.y * x.z, 29 | x.z * y.x - y.z * x.x, 30 | x.x * y.y - y.x * x.y); 31 | } 32 | 33 | public float dot(Vec3 y) { 34 | return dot((Vec3) this, y); 35 | } 36 | 37 | public static float dot(Vec3 x, Vec3 y) { 38 | float tX = x.x * y.x; 39 | float tY = x.y * y.y; 40 | float tZ = x.z * y.z; 41 | return tX + tY + tZ; 42 | } 43 | 44 | /** 45 | * Normalize this vector. 46 | * 47 | * @return this 48 | */ 49 | public Vec3 normalize() { 50 | return normalize((Vec3) this); 51 | } 52 | 53 | public Vec3 normalize_() { 54 | return normalize(new Vec3()); 55 | } 56 | 57 | /** 58 | * Normalize this vector and store the result in res. 59 | * 60 | * @param res will hold the result 61 | * @return 62 | */ 63 | public Vec3 normalize(Vec3 res) { 64 | float invLength = (float) (1.0 / Math.sqrt(x * x + y * y + z * z)); 65 | res.x = x * invLength; 66 | res.y = y * invLength; 67 | res.z = z * invLength; 68 | return res; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/funcRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3; 7 | 8 | import glm.Glm; 9 | import glm.vec._3.bool.Vec3bool; 10 | 11 | /** 12 | * 13 | * @author elect 14 | */ 15 | abstract class funcRelational extends funcGeometric { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec3) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec3) this); 23 | } 24 | 25 | public Vec3 not_() { 26 | return Glm.not((Vec3) this, new Vec3()); 27 | } 28 | 29 | public Vec3 not() { 30 | return Glm.not((Vec3) this, (Vec3) this); 31 | } 32 | 33 | public Vec3bool lessThan__(Vec3 b) { 34 | return Glm.lessThan((Vec3) this, b, new Vec3bool()); 35 | } 36 | 37 | public Vec3bool lessThan(Vec3 b, Vec3bool res) { 38 | return Glm.lessThan((Vec3) this, b, res); 39 | } 40 | 41 | public Vec3bool lessThanEqual__(Vec3 b) { 42 | return Glm.lessThanEqual((Vec3) this, b, new Vec3bool()); 43 | } 44 | 45 | public Vec3bool lessThanEqual(Vec3 b, Vec3bool res) { 46 | return Glm.lessThanEqual((Vec3) this, b, res); 47 | } 48 | 49 | public Vec3bool greaterThan__(Vec3 b) { 50 | return Glm.greaterThan((Vec3) this, b, new Vec3bool()); 51 | } 52 | 53 | public Vec3bool greaterThan(Vec3 b, Vec3bool res) { 54 | return Glm.greaterThan((Vec3) this, b, res); 55 | } 56 | 57 | public Vec3bool greaterThanEqual__(Vec3 b) { 58 | return Glm.greaterThanEqual((Vec3) this, b, new Vec3bool()); 59 | } 60 | 61 | public Vec3bool greaterThanEqual(Vec3 b, Vec3bool res) { 62 | return Glm.greaterThanEqual((Vec3) this, b, res); 63 | } 64 | 65 | public Vec3bool equal__(Vec3 b) { 66 | return Glm.equal((Vec3) this, b, new Vec3bool()); 67 | } 68 | 69 | public Vec3bool equal(Vec3 b, Vec3bool res) { 70 | return Glm.equal((Vec3) this, b, res); 71 | } 72 | 73 | public Vec3bool notEqual__(Vec3 b) { 74 | return Glm.notEqual((Vec3) this, b, new Vec3bool()); 75 | } 76 | 77 | public Vec3bool notEqual(Vec3 b, Vec3bool res) { 78 | return Glm.notEqual((Vec3) this, b, res); 79 | } 80 | 81 | public Vec3 lessThan(Vec3 b) { 82 | return Glm.lessThan((Vec3) this, b, (Vec3) this); 83 | } 84 | 85 | public Vec3 lessThan_(Vec3 b) { 86 | return Glm.lessThan((Vec3) this, b, new Vec3()); 87 | } 88 | 89 | public Vec3 lessThan(Vec3 b, Vec3 res) { 90 | return Glm.lessThan((Vec3) this, b, res); 91 | } 92 | 93 | public Vec3 lessThanEqual(Vec3 b) { 94 | return Glm.lessThanEqual((Vec3) this, b, (Vec3) this); 95 | } 96 | 97 | public Vec3 lessThanEqual_(Vec3 b) { 98 | return Glm.lessThanEqual((Vec3) this, b, new Vec3()); 99 | } 100 | 101 | public Vec3 lessThanEqual(Vec3 b, Vec3 res) { 102 | return Glm.lessThanEqual((Vec3) this, b, res); 103 | } 104 | 105 | public Vec3 greaterThan(Vec3 b) { 106 | return Glm.greaterThan((Vec3) this, b, (Vec3) this); 107 | } 108 | 109 | public Vec3 greaterThan_(Vec3 b) { 110 | return Glm.greaterThan((Vec3) this, b, new Vec3()); 111 | } 112 | 113 | public Vec3 greaterThan(Vec3 b, Vec3 res) { 114 | return Glm.greaterThan((Vec3) this, b, res); 115 | } 116 | 117 | public Vec3 greaterThanEqual(Vec3 b) { 118 | return Glm.greaterThanEqual((Vec3) this, b, (Vec3) this); 119 | } 120 | 121 | public Vec3 greaterThanEqual_(Vec3 b) { 122 | return Glm.greaterThanEqual((Vec3) this, b, new Vec3()); 123 | } 124 | 125 | public Vec3 greaterThanEqual(Vec3 b, Vec3 res) { 126 | return Glm.greaterThanEqual((Vec3) this, b, res); 127 | } 128 | 129 | public Vec3 equal(Vec3 b) { 130 | return Glm.equal((Vec3) this, b, (Vec3) this); 131 | } 132 | 133 | public Vec3 equal_(Vec3 b) { 134 | return Glm.equal((Vec3) this, b, new Vec3()); 135 | } 136 | 137 | public Vec3 equal(Vec3 b, Vec3 res) { 138 | return Glm.equal((Vec3) this, b, res); 139 | } 140 | 141 | public Vec3 notEqual(Vec3 b) { 142 | return Glm.notEqual((Vec3) this, b, (Vec3) this); 143 | } 144 | 145 | public Vec3 notEqual_(Vec3 b) { 146 | return Glm.notEqual((Vec3) this, b, new Vec3()); 147 | } 148 | 149 | public Vec3 notEqual(Vec3 b, Vec3 res) { 150 | return Glm.notEqual((Vec3) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/i/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.i; 7 | 8 | import glm.Glm; 9 | import glm.vec._3.bool.Vec3bool; 10 | 11 | /** 12 | * 13 | * @author fschaefers 14 | */ 15 | abstract class FuncRelational extends funcCommon { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec3i) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec3i) this); 23 | } 24 | 25 | public Vec3i not_() { 26 | return Glm.not((Vec3i) this, new Vec3i()); 27 | } 28 | 29 | public Vec3i not() { 30 | return Glm.not((Vec3i) this, (Vec3i) this); 31 | } 32 | 33 | public Vec3bool lessThan__(Vec3i b) { 34 | return Glm.lessThan((Vec3i) this, b, new Vec3bool()); 35 | } 36 | 37 | public Vec3bool lessThan(Vec3i b, Vec3bool res) { 38 | return Glm.lessThan((Vec3i) this, b, res); 39 | } 40 | 41 | public Vec3bool lessThanEqual__(Vec3i b) { 42 | return Glm.lessThanEqual((Vec3i) this, b, new Vec3bool()); 43 | } 44 | 45 | public Vec3bool lessThanEqual(Vec3i b, Vec3bool res) { 46 | return Glm.lessThanEqual((Vec3i) this, b, res); 47 | } 48 | 49 | public Vec3bool greaterThan__(Vec3i b) { 50 | return Glm.greaterThan((Vec3i) this, b, new Vec3bool()); 51 | } 52 | 53 | public Vec3bool greaterThan(Vec3i b, Vec3bool res) { 54 | return Glm.greaterThan((Vec3i) this, b, res); 55 | } 56 | 57 | public Vec3bool greaterThanEqual__(Vec3i b) { 58 | return Glm.greaterThanEqual((Vec3i) this, b, new Vec3bool()); 59 | } 60 | 61 | public Vec3bool greaterThanEqual(Vec3i b, Vec3bool res) { 62 | return Glm.greaterThanEqual((Vec3i) this, b, res); 63 | } 64 | 65 | public Vec3bool equal__(Vec3i b) { 66 | return Glm.equal((Vec3i) this, b, new Vec3bool()); 67 | } 68 | 69 | public Vec3bool equal(Vec3i b, Vec3bool res) { 70 | return Glm.equal((Vec3i) this, b, res); 71 | } 72 | 73 | public Vec3bool notEqual__(Vec3i b) { 74 | return Glm.notEqual((Vec3i) this, b, new Vec3bool()); 75 | } 76 | 77 | public Vec3bool notEqual(Vec3i b, Vec3bool res) { 78 | return Glm.notEqual((Vec3i) this, b, res); 79 | } 80 | 81 | public Vec3i lessThan(Vec3i b) { 82 | return Glm.lessThan((Vec3i) this, b, (Vec3i) this); 83 | } 84 | 85 | public Vec3i lessThan_(Vec3i b) { 86 | return Glm.lessThan((Vec3i) this, b, new Vec3i()); 87 | } 88 | 89 | public Vec3i lessThan(Vec3i b, Vec3i res) { 90 | return Glm.lessThan((Vec3i) this, b, res); 91 | } 92 | 93 | public Vec3i lessThanEqual(Vec3i b) { 94 | return Glm.lessThanEqual((Vec3i) this, b, (Vec3i) this); 95 | } 96 | 97 | public Vec3i lessThanEqual_(Vec3i b) { 98 | return Glm.lessThanEqual((Vec3i) this, b, new Vec3i()); 99 | } 100 | 101 | public Vec3i lessThanEqual(Vec3i b, Vec3i res) { 102 | return Glm.lessThanEqual((Vec3i) this, b, res); 103 | } 104 | 105 | public Vec3i greaterThan(Vec3i b) { 106 | return Glm.greaterThan((Vec3i) this, b, (Vec3i) this); 107 | } 108 | 109 | public Vec3i greaterThan_(Vec3i b) { 110 | return Glm.greaterThan((Vec3i) this, b, new Vec3i()); 111 | } 112 | 113 | public Vec3i greaterThan(Vec3i b, Vec3i res) { 114 | return Glm.greaterThan((Vec3i) this, b, res); 115 | } 116 | 117 | public Vec3i greaterThanEqual(Vec3i b) { 118 | return Glm.greaterThanEqual((Vec3i) this, b, (Vec3i) this); 119 | } 120 | 121 | public Vec3i greaterThanEqual_(Vec3i b) { 122 | return Glm.greaterThanEqual((Vec3i) this, b, new Vec3i()); 123 | } 124 | 125 | public Vec3i greaterThanEqual(Vec3i b, Vec3i res) { 126 | return Glm.greaterThanEqual((Vec3i) this, b, res); 127 | } 128 | 129 | public Vec3i equal(Vec3i b) { 130 | return Glm.equal((Vec3i) this, b, (Vec3i) this); 131 | } 132 | 133 | public Vec3i equal_(Vec3i b) { 134 | return Glm.equal((Vec3i) this, b, new Vec3i()); 135 | } 136 | 137 | public Vec3i equal(Vec3i b, Vec3i res) { 138 | return Glm.equal((Vec3i) this, b, res); 139 | } 140 | 141 | public Vec3i notEqual(Vec3i b) { 142 | return Glm.notEqual((Vec3i) this, b, (Vec3i) this); 143 | } 144 | 145 | public Vec3i notEqual_(Vec3i b) { 146 | return Glm.notEqual((Vec3i) this, b, new Vec3i()); 147 | } 148 | 149 | public Vec3i notEqual(Vec3i b, Vec3i res) { 150 | return Glm.notEqual((Vec3i) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/i/Vec3i.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.i; 7 | 8 | import glm.Glm; 9 | import glm.vec._4.i.Vec4i; 10 | import java.io.PrintStream; 11 | import java.nio.ByteBuffer; 12 | import java.nio.ByteOrder; 13 | import java.nio.IntBuffer; 14 | 15 | /** 16 | * 17 | * @author GBarbieri 18 | */ 19 | public class Vec3i extends FuncRelational { 20 | 21 | public Vec3i() { 22 | x = 0; 23 | y = 0; 24 | z = 0; 25 | } 26 | 27 | public Vec3i(Vec3i v) { 28 | x = v.x; 29 | y = v.y; 30 | z = v.z; 31 | } 32 | 33 | public Vec3i(Vec4i v) { 34 | x = v.x; 35 | y = v.y; 36 | z = v.z; 37 | } 38 | 39 | public Vec3i(int i) { 40 | x = i; 41 | y = i; 42 | z = i; 43 | } 44 | 45 | public Vec3i(int x, int y, int z) { 46 | this.x = x; 47 | this.y = y; 48 | this.z = z; 49 | } 50 | 51 | public Vec3i(int[] fa) { 52 | this(fa, 0); 53 | } 54 | 55 | public Vec3i(int[] fa, int i) { 56 | x = fa[i + 0]; 57 | y = fa[i + 1]; 58 | z = fa[i + 2]; 59 | } 60 | 61 | public Vec3i(long x, long y, long z) { 62 | this.x = (int) x; 63 | this.y = (int) y; 64 | this.z = (int) z; 65 | } 66 | 67 | public Vec3i set(int i) { 68 | x = i; 69 | y = i; 70 | z = i; 71 | return this; 72 | } 73 | 74 | public Vec3i set(long x, long y, long z) { 75 | return set((int) x, (int) y, (int) z); 76 | } 77 | 78 | public Vec3i set(int x, int y, int z) { 79 | this.x = x; 80 | this.y = y; 81 | this.z = z; 82 | return this; 83 | } 84 | 85 | public Vec3i set(int[] fa) { 86 | x = fa[0]; 87 | y = fa[1]; 88 | z = fa[2]; 89 | return this; 90 | } 91 | 92 | public static Vec3i linearRand_(Vec3i min, Vec3i max) { 93 | return linearRand(min, max, new Vec3i()); 94 | } 95 | 96 | public static Vec3i linearRand(Vec3i min, Vec3i max, Vec3i res) { 97 | res.x = Glm.linearRand(min.x, max.x); 98 | res.y = Glm.linearRand(min.y, max.y); 99 | res.z = Glm.linearRand(min.z, max.z); 100 | return res; 101 | } 102 | 103 | public Vec3i negate() { 104 | return negate(this); 105 | } 106 | 107 | public Vec3i negate_() { 108 | return negate(new Vec3i()); 109 | } 110 | 111 | public Vec3i negate(Vec3i res) { 112 | res.x = -x; 113 | res.y = -y; 114 | res.z = -z; 115 | return res; 116 | } 117 | 118 | public float length() { 119 | return (float) Math.sqrt(x * x + y * y + z * z); 120 | } 121 | 122 | public int[] toIA_() { 123 | return toIA(new int[3]); 124 | } 125 | 126 | public int[] toIA(int[] ia) { 127 | ia[0] = x; 128 | ia[1] = y; 129 | ia[2] = z; 130 | return ia; 131 | } 132 | 133 | public IntBuffer toDib_() { 134 | return Vec3i.this.toDib(ByteBuffer.allocateDirect(SIZE).order(ByteOrder.nativeOrder()).asIntBuffer()); 135 | } 136 | 137 | public IntBuffer toDib(IntBuffer ib) { 138 | return toDib(ib, 0); 139 | } 140 | 141 | public IntBuffer toDib(IntBuffer ib, int index) { 142 | return ib 143 | .put(index + 0, x) 144 | .put(index + 1, y) 145 | .put(index + 2, z); 146 | } 147 | 148 | public ByteBuffer toDbb_() { 149 | return toDbb(ByteBuffer.allocateDirect(SIZE).order(ByteOrder.nativeOrder())); 150 | } 151 | 152 | public ByteBuffer toDbb(ByteBuffer bb) { 153 | return toDbb(bb, 0); 154 | } 155 | 156 | public ByteBuffer toDbb(ByteBuffer bb, int index) { 157 | return bb 158 | .putInt(index + 0 * Integer.BYTES, x) 159 | .putInt(index + 1 * Integer.BYTES, y) 160 | .putInt(index + 2 * Integer.BYTES, z); 161 | } 162 | 163 | public void print() { 164 | print("", System.out); 165 | } 166 | 167 | public void print(String title) { 168 | print(title, System.out); 169 | } 170 | 171 | public void print(String title, PrintStream printStream) { 172 | printStream.println( title + "\n(" + x + ", " + y + ", " + z + ")"); 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/l/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.l; 7 | 8 | import glm.Glm; 9 | import glm.vec._3.bool.Vec3bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec3l) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec3l) this); 23 | } 24 | 25 | public Vec3l not_() { 26 | return Glm.not((Vec3l) this, new Vec3l()); 27 | } 28 | 29 | public Vec3l not() { 30 | return Glm.not((Vec3l) this, (Vec3l) this); 31 | } 32 | 33 | public Vec3bool lessThan__(Vec3l b) { 34 | return Glm.lessThan((Vec3l) this, b, new Vec3bool()); 35 | } 36 | 37 | public Vec3bool lessThan(Vec3l a, Vec3l b, Vec3bool res) { 38 | return Glm.lessThan((Vec3l) this, b, res); 39 | } 40 | 41 | public Vec3bool lessThanEqual__(Vec3l b) { 42 | return Glm.lessThanEqual((Vec3l) this, b, new Vec3bool()); 43 | } 44 | 45 | public Vec3bool lessThanEqual(Vec3l b, Vec3bool res) { 46 | return Glm.lessThanEqual((Vec3l) this, b, res); 47 | } 48 | 49 | public Vec3bool greaterThan__(Vec3l b) { 50 | return Glm.greaterThan((Vec3l) this, b, new Vec3bool()); 51 | } 52 | 53 | public Vec3bool greaterThan(Vec3l b, Vec3bool res) { 54 | return Glm.greaterThan((Vec3l) this, b, res); 55 | } 56 | 57 | public Vec3bool greaterThanEqual__(Vec3l b) { 58 | return Glm.greaterThanEqual((Vec3l) this, b, new Vec3bool()); 59 | } 60 | 61 | public Vec3bool greaterThanEqual(Vec3l b, Vec3bool res) { 62 | return Glm.greaterThanEqual((Vec3l) this, b, res); 63 | } 64 | 65 | public Vec3bool equal__(Vec3l b) { 66 | return Glm.equal((Vec3l) this, b, new Vec3bool()); 67 | } 68 | 69 | public Vec3bool equal(Vec3l b, Vec3bool res) { 70 | return Glm.equal((Vec3l) this, b, res); 71 | } 72 | 73 | public Vec3bool notEqual__(Vec3l b) { 74 | return Glm.notEqual((Vec3l) this, b, new Vec3bool()); 75 | } 76 | 77 | public Vec3bool notEqual(Vec3l b, Vec3bool res) { 78 | return Glm.notEqual((Vec3l) this, b, res); 79 | } 80 | 81 | public Vec3l lessThan(Vec3l b) { 82 | return Glm.lessThan((Vec3l) this, b, (Vec3l) this); 83 | } 84 | 85 | public Vec3l lessThan_(Vec3l b) { 86 | return Glm.lessThan((Vec3l) this, b, new Vec3l()); 87 | } 88 | 89 | public Vec3l lessThan(Vec3l a, Vec3l b, Vec3l res) { 90 | return Glm.lessThan((Vec3l) this, b, res); 91 | } 92 | 93 | public Vec3l lessThanEqual(Vec3l b) { 94 | return Glm.lessThanEqual((Vec3l) this, b, (Vec3l) this); 95 | } 96 | 97 | public Vec3l lessThanEqual_(Vec3l b) { 98 | return Glm.lessThanEqual((Vec3l) this, b, new Vec3l()); 99 | } 100 | 101 | public Vec3l lessThanEqual(Vec3l b, Vec3l res) { 102 | return Glm.lessThanEqual((Vec3l) this, b, res); 103 | } 104 | 105 | public Vec3l greaterThan(Vec3l b) { 106 | return Glm.greaterThan((Vec3l) this, b, (Vec3l) this); 107 | } 108 | 109 | public Vec3l greaterThan_(Vec3l b) { 110 | return Glm.greaterThan((Vec3l) this, b, new Vec3l()); 111 | } 112 | 113 | public Vec3l greaterThan(Vec3l b, Vec3l res) { 114 | return Glm.greaterThan((Vec3l) this, b, res); 115 | } 116 | 117 | public Vec3l greaterThanEqual(Vec3l b) { 118 | return Glm.greaterThanEqual((Vec3l) this, b, (Vec3l) this); 119 | } 120 | 121 | public Vec3l greaterThanEqual_(Vec3l b) { 122 | return Glm.greaterThanEqual((Vec3l) this, b, new Vec3l()); 123 | } 124 | 125 | public Vec3l greaterThanEqual(Vec3l b, Vec3l res) { 126 | return Glm.greaterThanEqual((Vec3l) this, b, res); 127 | } 128 | 129 | public Vec3l equal(Vec3l b) { 130 | return Glm.equal((Vec3l) this, b, (Vec3l) this); 131 | } 132 | 133 | public Vec3l equal_(Vec3l b) { 134 | return Glm.equal((Vec3l) this, b, new Vec3l()); 135 | } 136 | 137 | public Vec3l equal(Vec3l b, Vec3l res) { 138 | return Glm.equal((Vec3l) this, b, res); 139 | } 140 | 141 | public Vec3l notEqual(Vec3l b) { 142 | return Glm.notEqual((Vec3l) this, b, (Vec3l) this); 143 | } 144 | 145 | public Vec3l notEqual_(Vec3l b) { 146 | return Glm.notEqual((Vec3l) this, b, new Vec3l()); 147 | } 148 | 149 | public Vec3l notEqual(Vec3l b, Vec3l res) { 150 | return Glm.notEqual((Vec3l) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/l/Vec3l.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.l; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec3l extends FuncRelational { 13 | 14 | public Vec3l() { 15 | x = 0; 16 | y = 0; 17 | } 18 | 19 | public Vec3l(int x, int y, int z) { 20 | this((long) x, y, z); 21 | } 22 | 23 | public Vec3l(long x, long y, long z) { 24 | this.x = x; 25 | this.y = y; 26 | this.z = z; 27 | } 28 | 29 | public Vec3l set(long x, long y, long z) { 30 | this.x = x; 31 | this.y = y; 32 | this.z = z; 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/s/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.s; 7 | 8 | import glm.Glm; 9 | import glm.vec._3.bool.Vec3bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec3s) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec3s) this); 23 | } 24 | 25 | public Vec3s not_() { 26 | return Glm.not((Vec3s) this, new Vec3s()); 27 | } 28 | 29 | public Vec3s not() { 30 | return Glm.not((Vec3s) this, (Vec3s) this); 31 | } 32 | 33 | public Vec3bool lessThan__(Vec3s b) { 34 | return Glm.lessThan((Vec3s) this, b, new Vec3bool()); 35 | } 36 | 37 | public Vec3bool lessThan(Vec3s b, Vec3bool res) { 38 | return Glm.lessThan((Vec3s) this, b, res); 39 | } 40 | 41 | public Vec3bool lessThanEqual__(Vec3s b) { 42 | return Glm.lessThanEqual((Vec3s) this, b, new Vec3bool()); 43 | } 44 | 45 | public Vec3bool lessThanEqual(Vec3s b, Vec3bool res) { 46 | return Glm.lessThanEqual((Vec3s) this, b, res); 47 | } 48 | 49 | public Vec3bool greaterThan__(Vec3s b) { 50 | return Glm.greaterThan((Vec3s) this, b, new Vec3bool()); 51 | } 52 | 53 | public Vec3bool greaterThan(Vec3s b, Vec3bool res) { 54 | return Glm.greaterThan((Vec3s) this, b, res); 55 | } 56 | 57 | public Vec3bool greaterThanEqual__(Vec3s b) { 58 | return Glm.greaterThanEqual((Vec3s) this, b, new Vec3bool()); 59 | } 60 | 61 | public Vec3bool greaterThanEqual(Vec3s b, Vec3bool res) { 62 | return Glm.greaterThanEqual((Vec3s) this, b, res); 63 | } 64 | 65 | public Vec3bool equal__(Vec3s b) { 66 | return Glm.equal((Vec3s) this, b, new Vec3bool()); 67 | } 68 | 69 | public Vec3bool equal(Vec3s a, Vec3s b, Vec3bool res) { 70 | return Glm.equal((Vec3s) this, b, res); 71 | } 72 | 73 | public Vec3bool notEqual__(Vec3s b) { 74 | return Glm.notEqual((Vec3s) this, b, new Vec3bool()); 75 | } 76 | 77 | public Vec3bool notEqual(Vec3s b, Vec3bool res) { 78 | return Glm.notEqual((Vec3s) this, b, res); 79 | } 80 | 81 | public Vec3s lessThan(Vec3s b) { 82 | return Glm.lessThan((Vec3s) this, b, (Vec3s) this); 83 | } 84 | 85 | public Vec3s lessThan_(Vec3s b) { 86 | return Glm.lessThan((Vec3s) this, b, new Vec3s()); 87 | } 88 | 89 | public Vec3s lessThan(Vec3s b, Vec3s res) { 90 | return Glm.lessThan((Vec3s) this, b, res); 91 | } 92 | 93 | public Vec3s lessThanEqual(Vec3s b) { 94 | return Glm.lessThanEqual((Vec3s) this, b, (Vec3s) this); 95 | } 96 | 97 | public Vec3s lessThanEqual_(Vec3s b) { 98 | return Glm.lessThanEqual((Vec3s) this, b, new Vec3s()); 99 | } 100 | 101 | public Vec3s lessThanEqual(Vec3s b, Vec3s res) { 102 | return Glm.lessThanEqual((Vec3s) this, b, res); 103 | } 104 | 105 | public Vec3s greaterThan(Vec3s b) { 106 | return Glm.greaterThan((Vec3s) this, b, (Vec3s) this); 107 | } 108 | 109 | public Vec3s greaterThan_(Vec3s b) { 110 | return Glm.greaterThan((Vec3s) this, b, new Vec3s()); 111 | } 112 | 113 | public Vec3s greaterThan(Vec3s b, Vec3s res) { 114 | return Glm.greaterThan((Vec3s) this, b, res); 115 | } 116 | 117 | public Vec3s greaterThanEqual(Vec3s b) { 118 | return Glm.greaterThanEqual((Vec3s) this, b, (Vec3s) this); 119 | } 120 | 121 | public Vec3s greaterThanEqual_(Vec3s b) { 122 | return Glm.greaterThanEqual((Vec3s) this, b, new Vec3s()); 123 | } 124 | 125 | public Vec3s greaterThanEqual(Vec3s b, Vec3s res) { 126 | return Glm.greaterThanEqual((Vec3s) this, b, res); 127 | } 128 | 129 | public Vec3s equal(Vec3s b) { 130 | return Glm.equal((Vec3s) this, b, (Vec3s) this); 131 | } 132 | 133 | public Vec3s equal_(Vec3s b) { 134 | return Glm.equal((Vec3s) this, b, new Vec3s()); 135 | } 136 | 137 | public Vec3s equal(Vec3s a, Vec3s b, Vec3s res) { 138 | return Glm.equal((Vec3s) this, b, res); 139 | } 140 | 141 | public Vec3s notEqual(Vec3s b) { 142 | return Glm.notEqual((Vec3s) this, b, (Vec3s) this); 143 | } 144 | 145 | public Vec3s notEqual_(Vec3s b) { 146 | return Glm.notEqual((Vec3s) this, b, new Vec3s()); 147 | } 148 | 149 | public Vec3s notEqual(Vec3s b, Vec3s res) { 150 | return Glm.notEqual((Vec3s) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/s/Vec3s.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.s; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec3s extends FuncRelational { 13 | 14 | public Vec3s() { 15 | x = 0; 16 | y = 0; 17 | z = 0; 18 | } 19 | 20 | public Vec3s(int x, int y, int z) { 21 | this((short) x, (short) y, (short) z); 22 | } 23 | 24 | public Vec3s(short x, short y, short z) { 25 | this.x = x; 26 | this.y = y; 27 | this.z = z; 28 | } 29 | 30 | public Vec3s set(int x, int y, int z) { 31 | return set((short) x, (short) y, (short) z); 32 | } 33 | 34 | public Vec3s set(short x, short y, short z) { 35 | this.x = x; 36 | this.y = y; 37 | this.z = z; 38 | return this; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/t/Vec3t.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.t; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | public class Vec3t { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/ub/Vec3ub.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.ub; 7 | 8 | import joou.UByte; 9 | 10 | /** 11 | * 12 | * @author elect 13 | */ 14 | public class Vec3ub extends FuncRelational { 15 | 16 | public Vec3ub() { 17 | x.value = 0; 18 | y.value = 0; 19 | z.value = 0; 20 | } 21 | 22 | public Vec3ub(int x, int y, int z) { 23 | this((byte) x, (byte) y, (byte) z); 24 | } 25 | 26 | public Vec3ub(byte x, byte y, byte z) { 27 | this(new UByte(x), new UByte(y), new UByte(z)); 28 | } 29 | 30 | public Vec3ub(UByte x, UByte y, UByte z) { 31 | this.x = x; 32 | this.y = y; 33 | this.z = z; 34 | } 35 | 36 | public Vec3ub set(UByte x, UByte y, UByte z) { 37 | this.x = x; 38 | this.y = y; 39 | this.z = z; 40 | return this; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/ui/Vec3ui.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.ui; 7 | 8 | import joou.UInt; 9 | 10 | /** 11 | * 12 | * @author elect 13 | */ 14 | public class Vec3ui extends FuncRelational { 15 | 16 | public Vec3ui() { 17 | x.value = 0; 18 | y.value = 0; 19 | } 20 | 21 | public Vec3ui(int x, int y, int z) { 22 | this(new UInt(x), new UInt(y), new UInt(z)); 23 | } 24 | 25 | public Vec3ui(UInt x, UInt y, UInt z) { 26 | this.x = x; 27 | this.y = y; 28 | this.z = z; 29 | } 30 | 31 | public Vec3ui set(UInt x, UInt y, UInt z) { 32 | this.x = x; 33 | this.y = y; 34 | this.z = z; 35 | return this; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/ul/Vec3ul.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.ul; 7 | 8 | import java.math.BigInteger; 9 | import joou.ULong; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | public class Vec3ul extends FuncRelational { 16 | 17 | public Vec3ul() { 18 | x.value = 0; 19 | y.value = 0; 20 | z.value = 0; 21 | } 22 | 23 | public Vec3ul(int x, int y, int z) { 24 | this((long) x, y, z); 25 | } 26 | 27 | public Vec3ul(long x, long y, long z) { 28 | this.x.value = x; 29 | this.y.value = y; 30 | this.z.value = z; 31 | } 32 | 33 | public Vec3ul set(ULong x, ULong y, ULong z) { 34 | this.x = x; 35 | this.y = y; 36 | this.z = z; 37 | return this; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_3/us/Vec3us.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._3.us; 7 | 8 | import joou.UShort; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | public class Vec3us extends FuncRelational { 15 | 16 | public Vec3us() { 17 | x.value = 0; 18 | y.value = 0; 19 | z.value = 0; 20 | } 21 | 22 | public Vec3us(int x, int y, int z) { 23 | this((short) x, (short) y, (short) z); 24 | } 25 | 26 | public Vec3us(short x, short y, short z) { 27 | this.x.value = x; 28 | this.y.value = y; 29 | this.z.value = z; 30 | } 31 | 32 | public Vec3us set(UShort x, UShort y, UShort z) { 33 | this.x = x; 34 | this.y = y; 35 | this.z = z; 36 | return this; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4; 7 | 8 | import glm.Glm; 9 | import glm.vec._4.bool.Vec4bool; 10 | 11 | /** 12 | * 13 | * @author elect 14 | */ 15 | abstract class FuncRelational extends funcGeometric { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec4) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec4) this); 23 | } 24 | 25 | public Vec4 not_() { 26 | return Glm.not((Vec4) this, new Vec4()); 27 | } 28 | 29 | public Vec4 not() { 30 | return Glm.not((Vec4) this, (Vec4) this); 31 | } 32 | 33 | public Vec4bool lessThan__(Vec4 b) { 34 | return Glm.lessThan((Vec4) this, b, new Vec4bool()); 35 | } 36 | 37 | public Vec4bool lessThan(Vec4 b, Vec4bool res) { 38 | return Glm.lessThan((Vec4) this, b, res); 39 | } 40 | 41 | public Vec4bool lessThanEqual__(Vec4 b) { 42 | return Glm.lessThanEqual((Vec4) this, b, new Vec4bool()); 43 | } 44 | 45 | public Vec4bool lessThanEqual(Vec4 b, Vec4bool res) { 46 | return Glm.lessThanEqual((Vec4) this, b, res); 47 | } 48 | 49 | public Vec4bool greaterThan__(Vec4 b) { 50 | return Glm.greaterThan((Vec4) this, b, new Vec4bool()); 51 | } 52 | 53 | public Vec4bool greaterThan(Vec4 b, Vec4bool res) { 54 | return Glm.greaterThan((Vec4) this, b, res); 55 | } 56 | 57 | public Vec4bool greaterThanEqual__(Vec4 b) { 58 | return Glm.greaterThanEqual((Vec4) this, b, new Vec4bool()); 59 | } 60 | 61 | public Vec4bool greaterThanEqual(Vec4 b, Vec4bool res) { 62 | return Glm.greaterThanEqual((Vec4) this, b, res); 63 | } 64 | 65 | public Vec4bool equal__(Vec4 b) { 66 | return Glm.equal((Vec4) this, b, new Vec4bool()); 67 | } 68 | 69 | public Vec4bool equal(Vec4 b, Vec4bool res) { 70 | return Glm.equal((Vec4) this, b, res); 71 | } 72 | 73 | public Vec4bool notEqual__(Vec4 b) { 74 | return Glm.notEqual((Vec4) this, b, new Vec4bool()); 75 | } 76 | 77 | public Vec4bool notEqual(Vec4 b, Vec4bool res) { 78 | return Glm.notEqual((Vec4) this, b, res); 79 | } 80 | 81 | public Vec4 lessThan(Vec4 b) { 82 | return Glm.lessThan((Vec4) this, b, (Vec4) this); 83 | } 84 | 85 | public Vec4 lessThan_(Vec4 b) { 86 | return Glm.lessThan((Vec4) this, b, new Vec4()); 87 | } 88 | 89 | public Vec4 lessThan(Vec4 b, Vec4 res) { 90 | return Glm.lessThan((Vec4) this, b, res); 91 | } 92 | 93 | public Vec4 lessThanEqual(Vec4 b) { 94 | return Glm.lessThanEqual((Vec4) this, b, (Vec4) this); 95 | } 96 | 97 | public Vec4 lessThanEqual_(Vec4 b) { 98 | return Glm.lessThanEqual((Vec4) this, b, new Vec4()); 99 | } 100 | 101 | public Vec4 lessThanEqual(Vec4 b, Vec4 res) { 102 | return Glm.lessThanEqual((Vec4) this, b, res); 103 | } 104 | 105 | public Vec4 greaterThan(Vec4 b) { 106 | return Glm.greaterThan((Vec4) this, b, (Vec4) this); 107 | } 108 | 109 | public Vec4 greaterThan_(Vec4 b) { 110 | return Glm.greaterThan((Vec4) this, b, new Vec4()); 111 | } 112 | 113 | public Vec4 greaterThan(Vec4 b, Vec4 res) { 114 | return Glm.greaterThan((Vec4) this, b, res); 115 | } 116 | 117 | public Vec4 greaterThanEqual(Vec4 b) { 118 | return Glm.greaterThanEqual((Vec4) this, b, (Vec4) this); 119 | } 120 | 121 | public Vec4 greaterThanEqual_(Vec4 b) { 122 | return Glm.greaterThanEqual((Vec4) this, b, new Vec4()); 123 | } 124 | 125 | public Vec4 greaterThanEqual(Vec4 b, Vec4 res) { 126 | return Glm.greaterThanEqual((Vec4) this, b, res); 127 | } 128 | 129 | public Vec4 equal(Vec4 b) { 130 | return Glm.equal((Vec4) this, b, (Vec4) this); 131 | } 132 | 133 | public Vec4 equal_(Vec4 b) { 134 | return Glm.equal((Vec4) this, b, new Vec4()); 135 | } 136 | 137 | public Vec4 equal(Vec4 b, Vec4 res) { 138 | return Glm.equal((Vec4) this, b, res); 139 | } 140 | 141 | public Vec4 notEqual(Vec4 b) { 142 | return Glm.notEqual((Vec4) this, b, (Vec4) this); 143 | } 144 | 145 | public Vec4 notEqual_(Vec4 b) { 146 | return Glm.notEqual((Vec4) this, b, new Vec4()); 147 | } 148 | 149 | public Vec4 notEqual(Vec4 b, Vec4 res) { 150 | return Glm.notEqual((Vec4) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/b/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.b; 7 | 8 | import glm.Glm; 9 | import glm.vec._4.bool.Vec4bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec4b) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec4b) this); 23 | } 24 | 25 | public Vec4b not_() { 26 | return Glm.not((Vec4b) this, new Vec4b()); 27 | } 28 | 29 | public Vec4b not() { 30 | return Glm.not((Vec4b) this, (Vec4b) this); 31 | } 32 | 33 | public Vec4bool lessThan__(Vec4b b) { 34 | return Glm.lessThan((Vec4b) this, b, new Vec4bool()); 35 | } 36 | 37 | public Vec4bool lessThan(Vec4b b, Vec4bool res) { 38 | return Glm.lessThan((Vec4b) this, b, res); 39 | } 40 | 41 | public Vec4bool lessThanEqual__(Vec4b b) { 42 | return Glm.lessThanEqual((Vec4b) this, b, new Vec4bool()); 43 | } 44 | 45 | public Vec4bool lessThanEqual(Vec4b b, Vec4bool res) { 46 | return Glm.lessThanEqual((Vec4b) this, b, res); 47 | } 48 | 49 | public Vec4bool greaterThan__(Vec4b b) { 50 | return Glm.greaterThan((Vec4b) this, b, new Vec4bool()); 51 | } 52 | 53 | public Vec4bool greaterThan(Vec4b b, Vec4bool res) { 54 | return Glm.greaterThan((Vec4b) this, b, res); 55 | } 56 | 57 | public Vec4bool greaterThanEqual__(Vec4b b) { 58 | return Glm.greaterThanEqual((Vec4b) this, b, new Vec4bool()); 59 | } 60 | 61 | public Vec4bool greaterThanEqual(Vec4b b, Vec4bool res) { 62 | return Glm.greaterThanEqual((Vec4b) this, b, res); 63 | } 64 | 65 | public Vec4bool equal__(Vec4b b) { 66 | return Glm.equal((Vec4b) this, b, new Vec4bool()); 67 | } 68 | 69 | public Vec4bool equal(Vec4b b, Vec4bool res) { 70 | return Glm.equal((Vec4b) this, b, res); 71 | } 72 | 73 | public Vec4bool notEqual__(Vec4b b) { 74 | return Glm.notEqual((Vec4b) this, b, new Vec4bool()); 75 | } 76 | 77 | public Vec4bool notEqual(Vec4b b, Vec4bool res) { 78 | return Glm.notEqual((Vec4b) this, b, res); 79 | } 80 | 81 | public Vec4b lessThan(Vec4b b) { 82 | return Glm.lessThan((Vec4b) this, b, (Vec4b) this); 83 | } 84 | 85 | public Vec4b lessThan_(Vec4b b) { 86 | return Glm.lessThan((Vec4b) this, b, new Vec4b()); 87 | } 88 | 89 | public Vec4b lessThan(Vec4b b, Vec4b res) { 90 | return Glm.lessThan((Vec4b) this, b, res); 91 | } 92 | 93 | public Vec4b lessThanEqual(Vec4b b) { 94 | return Glm.lessThanEqual((Vec4b) this, b, (Vec4b) this); 95 | } 96 | 97 | public Vec4b lessThanEqual_(Vec4b b) { 98 | return Glm.lessThanEqual((Vec4b) this, b, new Vec4b()); 99 | } 100 | 101 | public Vec4b lessThanEqual(Vec4b b, Vec4b res) { 102 | return Glm.lessThanEqual((Vec4b) this, b, res); 103 | } 104 | 105 | public Vec4b greaterThan(Vec4b b) { 106 | return Glm.greaterThan((Vec4b) this, b, (Vec4b) this); 107 | } 108 | 109 | public Vec4b greaterThan_(Vec4b b) { 110 | return Glm.greaterThan((Vec4b) this, b, new Vec4b()); 111 | } 112 | 113 | public Vec4b greaterThan(Vec4b b, Vec4b res) { 114 | return Glm.greaterThan((Vec4b) this, b, res); 115 | } 116 | 117 | public Vec4b greaterThanEqual(Vec4b b) { 118 | return Glm.greaterThanEqual((Vec4b) this, b, (Vec4b) this); 119 | } 120 | 121 | public Vec4b greaterThanEqual_(Vec4b b) { 122 | return Glm.greaterThanEqual((Vec4b) this, b, new Vec4b()); 123 | } 124 | 125 | public Vec4b greaterThanEqual(Vec4b b, Vec4b res) { 126 | return Glm.greaterThanEqual((Vec4b) this, b, res); 127 | } 128 | 129 | public Vec4b equal(Vec4b b) { 130 | return Glm.equal((Vec4b) this, b, (Vec4b) this); 131 | } 132 | 133 | public Vec4b equal_(Vec4b b) { 134 | return Glm.equal((Vec4b) this, b, new Vec4b()); 135 | } 136 | 137 | public Vec4b equal(Vec4b b, Vec4b res) { 138 | return Glm.equal((Vec4b) this, b, res); 139 | } 140 | 141 | public Vec4b notEqual(Vec4b b) { 142 | return Glm.notEqual((Vec4b) this, b, (Vec4b) this); 143 | } 144 | 145 | public Vec4b notEqual_(Vec4b b) { 146 | return Glm.notEqual((Vec4b) this, b, new Vec4b()); 147 | } 148 | 149 | public Vec4b notEqual(Vec4b b, Vec4b res) { 150 | return Glm.notEqual((Vec4b) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/b/Vec4b.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.b; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | public class Vec4b extends FuncRelational { 13 | 14 | public Vec4b() { 15 | this(0); 16 | } 17 | 18 | public Vec4b(int i) { 19 | this(i, i, i, i); 20 | } 21 | 22 | public Vec4b(byte b) { 23 | this(b, b, b, b); 24 | } 25 | 26 | public Vec4b(byte x, byte y, byte z, byte w) { 27 | this.x = x; 28 | this.y = y; 29 | this.z = z; 30 | this.w = w; 31 | } 32 | 33 | public Vec4b(int x, int y, int z, int w) { 34 | this.x = (byte) x; 35 | this.y = (byte) y; 36 | this.z = (byte) z; 37 | this.w = (byte) w; 38 | } 39 | 40 | public Vec4b set(int x, int y, int z, int w) { 41 | return set((byte) x, (byte) y, (byte) z, (byte) w); 42 | } 43 | 44 | public Vec4b set(byte x, byte y, byte z, byte w) { 45 | this.x = x; 46 | this.y = y; 47 | this.z = z; 48 | this.w = w; 49 | return this; 50 | } 51 | 52 | public boolean all() { 53 | return x == 1 && y == 1 && z == 1 && w == 1; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/bool/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.bool; 7 | 8 | import glm.Glm; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | abstract class FuncRelational { 15 | 16 | public static final int SIZE = 4 * Byte.BYTES; 17 | 18 | public boolean x, y, z, w; 19 | 20 | public boolean any() { 21 | return Glm.any((Vec4bool) this); 22 | } 23 | 24 | public boolean all() { 25 | return Glm.all((Vec4bool) this); 26 | } 27 | 28 | public Vec4bool not_() { 29 | return Glm.not((Vec4bool) this, new Vec4bool()); 30 | } 31 | 32 | public Vec4bool not() { 33 | return Glm.not((Vec4bool) this, (Vec4bool) this); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/bool/Vec4bool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.bool; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec4bool extends FuncRelational { 13 | 14 | public Vec4bool() { 15 | } 16 | 17 | public Vec4bool(boolean x, boolean y, boolean z, boolean w) { 18 | this.x = x; 19 | this.y = y; 20 | this.z = z; 21 | this.w = w; 22 | } 23 | 24 | public Vec4bool set(boolean x, boolean y, boolean z, boolean w) { 25 | this.x = x; 26 | this.y = y; 27 | this.z = z; 28 | this.w = w; 29 | return this; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/colorSpace.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public abstract class colorSpace extends noise { 13 | 14 | public Vec4 convertLinearToSRGB() { 15 | return compute_rgbToSrgb((Vec4) this, 0.41666f, (Vec4) this); 16 | } 17 | 18 | public Vec4 convertLinearToSRGB_() { 19 | return compute_rgbToSrgb((Vec4) this, 0.41666f, new Vec4()); 20 | } 21 | 22 | public Vec4 convertLinearToSRGB(Vec4 colorSRGB) { 23 | return compute_rgbToSrgb((Vec4) this, 0.41666f, colorSRGB); 24 | } 25 | 26 | public static Vec4 compute_rgbToSrgb(Vec4 colorRGB, float gammaCorrection, Vec4 colorSRGB) { 27 | // vecType const ClampedColor(clamp(ColorRGB, static_cast(0), static_cast(1))); 28 | float clampedColorX = Math.min(Math.max(colorRGB.x, 0), 1); 29 | float clampedColorY = Math.min(Math.max(colorRGB.y, 0), 1); 30 | float clampedColorZ = Math.min(Math.max(colorRGB.z, 0), 1); 31 | // x = pow(ClampedColor, vecType(GammaCorrection)) * static_cast(1.055) - static_cast(0.055) 32 | float xX = (float) (Math.pow(clampedColorX, gammaCorrection) * 1.055 - 0.055); 33 | float xY = (float) (Math.pow(clampedColorY, gammaCorrection) * 1.055 - 0.055); 34 | float xZ = (float) (Math.pow(clampedColorZ, gammaCorrection) * 1.055 - 0.055); 35 | // y = ClampedColor * static_cast(12.92) 36 | float yX = clampedColorX * 12.92f; 37 | float yY = clampedColorY * 12.92f; 38 | float yZ = clampedColorZ * 12.92f; 39 | // a = lessThan(ClampedColor, vecType(static_cast(0.0031308))) 40 | float aX = clampedColorX < 0.0031308f ? 1 : 0; 41 | float aY = clampedColorY < 0.0031308f ? 1 : 0; 42 | float aZ = clampedColorZ < 0.0031308f ? 1 : 0; 43 | // mix(x, y, a) 44 | colorSRGB.x = xX + aX * (yX - xX); 45 | colorSRGB.y = xY + aY * (yY - xY); 46 | colorSRGB.z = xZ + aZ * (yZ - xZ); 47 | colorSRGB.w = colorRGB.w; 48 | return colorSRGB; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/d/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.d; 7 | 8 | import glm.Glm; 9 | import glm.vec._4.bool.Vec4bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec4d) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec4d) this); 23 | } 24 | 25 | public Vec4d not_() { 26 | return Glm.not((Vec4d) this, new Vec4d()); 27 | } 28 | 29 | public Vec4d not() { 30 | return Glm.not((Vec4d) this, (Vec4d) this); 31 | } 32 | 33 | public Vec4bool lessThan__(Vec4d b) { 34 | return Glm.lessThan((Vec4d) this, b, new Vec4bool()); 35 | } 36 | 37 | public Vec4bool lessThan(Vec4d b, Vec4bool res) { 38 | return Glm.lessThan((Vec4d) this, b, res); 39 | } 40 | 41 | public Vec4bool lessThanEqual__(Vec4d b) { 42 | return Glm.lessThanEqual((Vec4d) this, b, new Vec4bool()); 43 | } 44 | 45 | public Vec4bool lessThanEqual(Vec4d b, Vec4bool res) { 46 | return Glm.lessThanEqual((Vec4d) this, b, res); 47 | } 48 | 49 | public Vec4bool greaterThan__(Vec4d b) { 50 | return Glm.greaterThan((Vec4d) this, b, new Vec4bool()); 51 | } 52 | 53 | public Vec4bool greaterThan(Vec4d b, Vec4bool res) { 54 | return Glm.greaterThan((Vec4d) this, b, res); 55 | } 56 | 57 | public Vec4bool greaterThanEqual__(Vec4d b) { 58 | return Glm.greaterThanEqual((Vec4d) this, b, new Vec4bool()); 59 | } 60 | 61 | public Vec4bool greaterThanEqual(Vec4d b, Vec4bool res) { 62 | return Glm.greaterThanEqual((Vec4d) this, b, res); 63 | } 64 | 65 | public Vec4bool equal__(Vec4d b) { 66 | return Glm.equal((Vec4d) this, b, new Vec4bool()); 67 | } 68 | 69 | public Vec4bool equal(Vec4d b, Vec4bool res) { 70 | return Glm.equal((Vec4d) this, b, res); 71 | } 72 | 73 | public Vec4bool notEqual__(Vec4d b) { 74 | return Glm.notEqual((Vec4d) this, b, new Vec4bool()); 75 | } 76 | 77 | public Vec4bool notEqual(Vec4d b, Vec4bool res) { 78 | return Glm.notEqual((Vec4d) this, b, res); 79 | } 80 | 81 | public Vec4d lessThan(Vec4d b) { 82 | return Glm.lessThan((Vec4d) this, b, (Vec4d) this); 83 | } 84 | 85 | public Vec4d lessThan_(Vec4d b) { 86 | return Glm.lessThan((Vec4d) this, b, new Vec4d()); 87 | } 88 | 89 | public Vec4d lessThan(Vec4d b, Vec4d res) { 90 | return Glm.lessThan((Vec4d) this, b, res); 91 | } 92 | 93 | public Vec4d lessThanEqual(Vec4d b) { 94 | return Glm.lessThanEqual((Vec4d) this, b, (Vec4d) this); 95 | } 96 | 97 | public Vec4d lessThanEqual_(Vec4d b) { 98 | return Glm.lessThanEqual((Vec4d) this, b, new Vec4d()); 99 | } 100 | 101 | public Vec4d lessThanEqual(Vec4d b, Vec4d res) { 102 | return Glm.lessThanEqual((Vec4d) this, b, res); 103 | } 104 | 105 | public Vec4d greaterThan(Vec4d b) { 106 | return Glm.greaterThan((Vec4d) this, b, (Vec4d) this); 107 | } 108 | 109 | public Vec4d greaterThan_(Vec4d b) { 110 | return Glm.greaterThan((Vec4d) this, b, new Vec4d()); 111 | } 112 | 113 | public Vec4d greaterThan(Vec4d b, Vec4d res) { 114 | return Glm.greaterThan((Vec4d) this, b, res); 115 | } 116 | 117 | public Vec4d greaterThanEqual(Vec4d b) { 118 | return Glm.greaterThanEqual((Vec4d) this, b, (Vec4d) this); 119 | } 120 | 121 | public Vec4d greaterThanEqual_(Vec4d b) { 122 | return Glm.greaterThanEqual((Vec4d) this, b, new Vec4d()); 123 | } 124 | 125 | public Vec4d greaterThanEqual(Vec4d b, Vec4d res) { 126 | return Glm.greaterThanEqual((Vec4d) this, b, res); 127 | } 128 | 129 | public Vec4d equal(Vec4d b) { 130 | return Glm.equal((Vec4d) this, b, (Vec4d) this); 131 | } 132 | 133 | public Vec4d equal_(Vec4d b) { 134 | return Glm.equal((Vec4d) this, b, new Vec4d()); 135 | } 136 | 137 | public Vec4d equal(Vec4d b, Vec4d res) { 138 | return Glm.equal((Vec4d) this, b, res); 139 | } 140 | 141 | public Vec4d notEqual(Vec4d b) { 142 | return Glm.notEqual((Vec4d) this, b, (Vec4d) this); 143 | } 144 | 145 | public Vec4d notEqual_(Vec4d b) { 146 | return Glm.notEqual((Vec4d) this, b, new Vec4d()); 147 | } 148 | 149 | public Vec4d notEqual(Vec4d b, Vec4d res) { 150 | return Glm.notEqual((Vec4d) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/d/Vec4d.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.d; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | public class Vec4d extends FuncRelational { 13 | 14 | public Vec4d() { 15 | 16 | } 17 | 18 | public Vec4d(double x, double y, double z, double w) { 19 | this.x = x; 20 | this.y = y; 21 | this.z = z; 22 | this.w = w; 23 | } 24 | 25 | public Vec4d set(double x, double y, double z, double w) { 26 | this.x = x; 27 | this.y = y; 28 | this.z = z; 29 | this.w = w; 30 | return this; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/funcGeometric.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | abstract class funcGeometric extends funcCommon { 13 | 14 | public float dot(Vec4 y) { 15 | return dot((Vec4) this, y); 16 | } 17 | 18 | public static float dot(Vec4 x, Vec4 y) { 19 | float tX = x.x * y.x; 20 | float tY = x.y * y.y; 21 | float tZ = x.z * y.z; 22 | float tW = x.w * y.w; 23 | return tX + tY + tZ + tW; 24 | } 25 | 26 | /** 27 | * Normalize this vector. 28 | * 29 | * @return this 30 | */ 31 | public Vec4 normalize() { 32 | return normalize((Vec4) this); 33 | } 34 | 35 | /** 36 | * Normalize this vector and store the result in res. 37 | * 38 | * @param res will hold the result 39 | * @return 40 | */ 41 | public Vec4 normalize(Vec4 res) { 42 | float invLength = (float) (1.0 / Math.sqrt(x * x + y * y + z * z + w * w)); 43 | res.x = x * invLength; 44 | res.y = y * invLength; 45 | res.z = z * invLength; 46 | res.w = w * invLength; 47 | return res; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/i/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.i; 7 | 8 | import glm.Glm; 9 | import glm.vec._4.bool.Vec4bool; 10 | 11 | /** 12 | * 13 | * @author fschaefers 14 | */ 15 | abstract class FuncRelational extends funcCommon { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec4i) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec4i) this); 23 | } 24 | 25 | public Vec4i not_() { 26 | return Glm.not((Vec4i) this, new Vec4i()); 27 | } 28 | 29 | public Vec4i not() { 30 | return Glm.not((Vec4i) this, (Vec4i) this); 31 | } 32 | 33 | public Vec4bool lessThan__(Vec4i b) { 34 | return Glm.lessThan((Vec4i) this, b, new Vec4bool()); 35 | } 36 | 37 | public Vec4bool lessThan(Vec4i b, Vec4bool res) { 38 | return Glm.lessThan((Vec4i) this, b, res); 39 | } 40 | 41 | public Vec4bool lessThanEqual__(Vec4i b) { 42 | return Glm.lessThanEqual((Vec4i) this, b, new Vec4bool()); 43 | } 44 | 45 | public Vec4bool lessThanEqual(Vec4i b, Vec4bool res) { 46 | return Glm.lessThanEqual((Vec4i) this, b, res); 47 | } 48 | 49 | public Vec4bool greaterThan__(Vec4i b) { 50 | return Glm.greaterThan((Vec4i) this, b, new Vec4bool()); 51 | } 52 | 53 | public Vec4bool greaterThan(Vec4i b, Vec4bool res) { 54 | return Glm.greaterThan((Vec4i) this, b, res); 55 | } 56 | 57 | public Vec4bool greaterThanEqual__(Vec4i b) { 58 | return Glm.greaterThanEqual((Vec4i) this, b, new Vec4bool()); 59 | } 60 | 61 | public Vec4bool greaterThanEqual(Vec4i b, Vec4bool res) { 62 | return Glm.greaterThanEqual((Vec4i) this, b, res); 63 | } 64 | 65 | public Vec4bool equal__(Vec4i b) { 66 | return Glm.equal((Vec4i) this, b, new Vec4bool()); 67 | } 68 | 69 | public Vec4bool equal(Vec4i b, Vec4bool res) { 70 | return Glm.equal((Vec4i) this, b, res); 71 | } 72 | 73 | public Vec4bool notEqual__(Vec4i b) { 74 | return Glm.notEqual((Vec4i) this, b, new Vec4bool()); 75 | } 76 | 77 | public Vec4bool notEqual(Vec4i b, Vec4bool res) { 78 | return Glm.notEqual((Vec4i) this, b, res); 79 | } 80 | 81 | public Vec4i lessThan(Vec4i b) { 82 | return Glm.lessThan((Vec4i) this, b, (Vec4i) this); 83 | } 84 | 85 | public Vec4i lessThan_(Vec4i b) { 86 | return Glm.lessThan((Vec4i) this, b, new Vec4i()); 87 | } 88 | 89 | public Vec4i lessThan(Vec4i b, Vec4i res) { 90 | return Glm.lessThan((Vec4i) this, b, res); 91 | } 92 | 93 | public Vec4i lessThanEqual(Vec4i b) { 94 | return Glm.lessThanEqual((Vec4i) this, b, (Vec4i) this); 95 | } 96 | 97 | public Vec4i lessThanEqual_(Vec4i b) { 98 | return Glm.lessThanEqual((Vec4i) this, b, new Vec4i()); 99 | } 100 | 101 | public Vec4i lessThanEqual(Vec4i b, Vec4i res) { 102 | return Glm.lessThanEqual((Vec4i) this, b, res); 103 | } 104 | 105 | public Vec4i greaterThan(Vec4i b) { 106 | return Glm.greaterThan((Vec4i) this, b, (Vec4i) this); 107 | } 108 | 109 | public Vec4i greaterThan_(Vec4i b) { 110 | return Glm.greaterThan((Vec4i) this, b, new Vec4i()); 111 | } 112 | 113 | public Vec4i greaterThan(Vec4i b, Vec4i res) { 114 | return Glm.greaterThan((Vec4i) this, b, res); 115 | } 116 | 117 | public Vec4i greaterThanEqual(Vec4i b) { 118 | return Glm.greaterThanEqual((Vec4i) this, b, (Vec4i) this); 119 | } 120 | 121 | public Vec4i greaterThanEqual_(Vec4i b) { 122 | return Glm.greaterThanEqual((Vec4i) this, b, new Vec4i()); 123 | } 124 | 125 | public Vec4i greaterThanEqual(Vec4i b, Vec4i res) { 126 | return Glm.greaterThanEqual((Vec4i) this, b, res); 127 | } 128 | 129 | public Vec4i equal(Vec4i b) { 130 | return Glm.equal((Vec4i) this, b, (Vec4i) this); 131 | } 132 | 133 | public Vec4i equal_(Vec4i b) { 134 | return Glm.equal((Vec4i) this, b, new Vec4i()); 135 | } 136 | 137 | public Vec4i equal(Vec4i b, Vec4i res) { 138 | return Glm.equal((Vec4i) this, b, res); 139 | } 140 | 141 | public Vec4i notEqual(Vec4i b) { 142 | return Glm.notEqual((Vec4i) this, b, (Vec4i) this); 143 | } 144 | 145 | public Vec4i notEqual_(Vec4i b) { 146 | return Glm.notEqual((Vec4i) this, b, new Vec4i()); 147 | } 148 | 149 | public Vec4i notEqual(Vec4i b, Vec4i res) { 150 | return Glm.notEqual((Vec4i) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/l/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.l; 7 | 8 | import glm.Glm; 9 | import glm.vec._4.bool.Vec4bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec4l) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec4l) this); 23 | } 24 | 25 | public Vec4l not_() { 26 | return Glm.not((Vec4l) this, new Vec4l()); 27 | } 28 | 29 | public Vec4l not() { 30 | return Glm.not((Vec4l) this, (Vec4l) this); 31 | } 32 | 33 | public Vec4bool lessThan__(Vec4l b) { 34 | return Glm.lessThan((Vec4l) this, b, new Vec4bool()); 35 | } 36 | 37 | public Vec4bool lessThan(Vec4l a, Vec4l b, Vec4bool res) { 38 | return Glm.lessThan((Vec4l) this, b, res); 39 | } 40 | 41 | public Vec4bool lessThanEqual__(Vec4l b) { 42 | return Glm.lessThanEqual((Vec4l) this, b, new Vec4bool()); 43 | } 44 | 45 | public Vec4bool lessThanEqual(Vec4l b, Vec4bool res) { 46 | return Glm.lessThanEqual((Vec4l) this, b, res); 47 | } 48 | 49 | public Vec4bool greaterThan__(Vec4l b) { 50 | return Glm.greaterThan((Vec4l) this, b, new Vec4bool()); 51 | } 52 | 53 | public Vec4bool greaterThan(Vec4l b, Vec4bool res) { 54 | return Glm.greaterThan((Vec4l) this, b, res); 55 | } 56 | 57 | public Vec4bool greaterThanEqual__(Vec4l b) { 58 | return Glm.greaterThanEqual((Vec4l) this, b, new Vec4bool()); 59 | } 60 | 61 | public Vec4bool greaterThanEqual(Vec4l b, Vec4bool res) { 62 | return Glm.greaterThanEqual((Vec4l) this, b, res); 63 | } 64 | 65 | public Vec4bool equal__(Vec4l b) { 66 | return Glm.equal((Vec4l) this, b, new Vec4bool()); 67 | } 68 | 69 | public Vec4bool equal(Vec4l b, Vec4bool res) { 70 | return Glm.equal((Vec4l) this, b, res); 71 | } 72 | 73 | public Vec4bool notEqual__(Vec4l b) { 74 | return Glm.notEqual((Vec4l) this, b, new Vec4bool()); 75 | } 76 | 77 | public Vec4bool notEqual(Vec4l b, Vec4bool res) { 78 | return Glm.notEqual((Vec4l) this, b, res); 79 | } 80 | 81 | public Vec4l lessThan(Vec4l b) { 82 | return Glm.lessThan((Vec4l) this, b, (Vec4l) this); 83 | } 84 | 85 | public Vec4l lessThan_(Vec4l b) { 86 | return Glm.lessThan((Vec4l) this, b, new Vec4l()); 87 | } 88 | 89 | public Vec4l lessThan(Vec4l a, Vec4l b, Vec4l res) { 90 | return Glm.lessThan((Vec4l) this, b, res); 91 | } 92 | 93 | public Vec4l lessThanEqual(Vec4l b) { 94 | return Glm.lessThanEqual((Vec4l) this, b, (Vec4l) this); 95 | } 96 | 97 | public Vec4l lessThanEqual_(Vec4l b) { 98 | return Glm.lessThanEqual((Vec4l) this, b, new Vec4l()); 99 | } 100 | 101 | public Vec4l lessThanEqual(Vec4l b, Vec4l res) { 102 | return Glm.lessThanEqual((Vec4l) this, b, res); 103 | } 104 | 105 | public Vec4l greaterThan(Vec4l b) { 106 | return Glm.greaterThan((Vec4l) this, b, (Vec4l) this); 107 | } 108 | 109 | public Vec4l greaterThan_(Vec4l b) { 110 | return Glm.greaterThan((Vec4l) this, b, new Vec4l()); 111 | } 112 | 113 | public Vec4l greaterThan(Vec4l b, Vec4l res) { 114 | return Glm.greaterThan((Vec4l) this, b, res); 115 | } 116 | 117 | public Vec4l greaterThanEqual(Vec4l b) { 118 | return Glm.greaterThanEqual((Vec4l) this, b, (Vec4l) this); 119 | } 120 | 121 | public Vec4l greaterThanEqual_(Vec4l b) { 122 | return Glm.greaterThanEqual((Vec4l) this, b, new Vec4l()); 123 | } 124 | 125 | public Vec4l greaterThanEqual(Vec4l b, Vec4l res) { 126 | return Glm.greaterThanEqual((Vec4l) this, b, res); 127 | } 128 | 129 | public Vec4l equal(Vec4l b) { 130 | return Glm.equal((Vec4l) this, b, (Vec4l) this); 131 | } 132 | 133 | public Vec4l equal_(Vec4l b) { 134 | return Glm.equal((Vec4l) this, b, new Vec4l()); 135 | } 136 | 137 | public Vec4l equal(Vec4l b, Vec4l res) { 138 | return Glm.equal((Vec4l) this, b, res); 139 | } 140 | 141 | public Vec4l notEqual(Vec4l b) { 142 | return Glm.notEqual((Vec4l) this, b, (Vec4l) this); 143 | } 144 | 145 | public Vec4l notEqual_(Vec4l b) { 146 | return Glm.notEqual((Vec4l) this, b, new Vec4l()); 147 | } 148 | 149 | public Vec4l notEqual(Vec4l b, Vec4l res) { 150 | return Glm.notEqual((Vec4l) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/l/Vec4l.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.l; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec4l extends FuncRelational { 13 | 14 | public Vec4l() { 15 | x = 0; 16 | y = 0; 17 | } 18 | 19 | public Vec4l(int x, int y, int z, int w) { 20 | this((long) x, y, z, w); 21 | } 22 | 23 | public Vec4l(long x, long y, long z, long w) { 24 | this.x = x; 25 | this.y = y; 26 | this.z = z; 27 | this.w = w; 28 | } 29 | 30 | public Vec4l set(long x, long y, long z, long w) { 31 | this.x = x; 32 | this.y = y; 33 | this.z = z; 34 | this.w = w; 35 | return this; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/s/FuncRelational.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.s; 7 | 8 | import glm.Glm; 9 | import glm.vec._4.bool.Vec4bool; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | abstract class FuncRelational extends ArithmeticOperators { 16 | 17 | public boolean any() { 18 | return Glm.any((Vec4s) this); 19 | } 20 | 21 | public boolean all() { 22 | return Glm.all((Vec4s) this); 23 | } 24 | 25 | public Vec4s not_() { 26 | return Glm.not((Vec4s) this, new Vec4s()); 27 | } 28 | 29 | public Vec4s not() { 30 | return Glm.not((Vec4s) this, (Vec4s) this); 31 | } 32 | 33 | public Vec4bool lessThan__(Vec4s b) { 34 | return Glm.lessThan((Vec4s) this, b, new Vec4bool()); 35 | } 36 | 37 | public Vec4bool lessThan(Vec4s b, Vec4bool res) { 38 | return Glm.lessThan((Vec4s) this, b, res); 39 | } 40 | 41 | public Vec4bool lessThanEqual__(Vec4s b) { 42 | return Glm.lessThanEqual((Vec4s) this, b, new Vec4bool()); 43 | } 44 | 45 | public Vec4bool lessThanEqual(Vec4s b, Vec4bool res) { 46 | return Glm.lessThanEqual((Vec4s) this, b, res); 47 | } 48 | 49 | public Vec4bool greaterThan__(Vec4s b) { 50 | return Glm.greaterThan((Vec4s) this, b, new Vec4bool()); 51 | } 52 | 53 | public Vec4bool greaterThan(Vec4s b, Vec4bool res) { 54 | return Glm.greaterThan((Vec4s) this, b, res); 55 | } 56 | 57 | public Vec4bool greaterThanEqual__(Vec4s b) { 58 | return Glm.greaterThanEqual((Vec4s) this, b, new Vec4bool()); 59 | } 60 | 61 | public Vec4bool greaterThanEqual(Vec4s b, Vec4bool res) { 62 | return Glm.greaterThanEqual((Vec4s) this, b, res); 63 | } 64 | 65 | public Vec4bool equal__(Vec4s b) { 66 | return Glm.equal((Vec4s) this, b, new Vec4bool()); 67 | } 68 | 69 | public Vec4bool equal(Vec4s a, Vec4s b, Vec4bool res) { 70 | return Glm.equal((Vec4s) this, b, res); 71 | } 72 | 73 | public Vec4bool notEqual__(Vec4s b) { 74 | return Glm.notEqual((Vec4s) this, b, new Vec4bool()); 75 | } 76 | 77 | public Vec4bool notEqual(Vec4s b, Vec4bool res) { 78 | return Glm.notEqual((Vec4s) this, b, res); 79 | } 80 | 81 | public Vec4s lessThan(Vec4s b) { 82 | return Glm.lessThan((Vec4s) this, b, (Vec4s) this); 83 | } 84 | 85 | public Vec4s lessThan_(Vec4s b) { 86 | return Glm.lessThan((Vec4s) this, b, new Vec4s()); 87 | } 88 | 89 | public Vec4s lessThan(Vec4s b, Vec4s res) { 90 | return Glm.lessThan((Vec4s) this, b, res); 91 | } 92 | 93 | public Vec4s lessThanEqual(Vec4s b) { 94 | return Glm.lessThanEqual((Vec4s) this, b, (Vec4s) this); 95 | } 96 | 97 | public Vec4s lessThanEqual_(Vec4s b) { 98 | return Glm.lessThanEqual((Vec4s) this, b, new Vec4s()); 99 | } 100 | 101 | public Vec4s lessThanEqual(Vec4s b, Vec4s res) { 102 | return Glm.lessThanEqual((Vec4s) this, b, res); 103 | } 104 | 105 | public Vec4s greaterThan(Vec4s b) { 106 | return Glm.greaterThan((Vec4s) this, b, (Vec4s) this); 107 | } 108 | 109 | public Vec4s greaterThan_(Vec4s b) { 110 | return Glm.greaterThan((Vec4s) this, b, new Vec4s()); 111 | } 112 | 113 | public Vec4s greaterThan(Vec4s b, Vec4s res) { 114 | return Glm.greaterThan((Vec4s) this, b, res); 115 | } 116 | 117 | public Vec4s greaterThanEqual(Vec4s b) { 118 | return Glm.greaterThanEqual((Vec4s) this, b, (Vec4s) this); 119 | } 120 | 121 | public Vec4s greaterThanEqual_(Vec4s b) { 122 | return Glm.greaterThanEqual((Vec4s) this, b, new Vec4s()); 123 | } 124 | 125 | public Vec4s greaterThanEqual(Vec4s b, Vec4s res) { 126 | return Glm.greaterThanEqual((Vec4s) this, b, res); 127 | } 128 | 129 | public Vec4s equal(Vec4s b) { 130 | return Glm.equal((Vec4s) this, b, (Vec4s) this); 131 | } 132 | 133 | public Vec4s equal_(Vec4s b) { 134 | return Glm.equal((Vec4s) this, b, new Vec4s()); 135 | } 136 | 137 | public Vec4s equal(Vec4s a, Vec4s b, Vec4s res) { 138 | return Glm.equal((Vec4s) this, b, res); 139 | } 140 | 141 | public Vec4s notEqual(Vec4s b) { 142 | return Glm.notEqual((Vec4s) this, b, (Vec4s) this); 143 | } 144 | 145 | public Vec4s notEqual_(Vec4s b) { 146 | return Glm.notEqual((Vec4s) this, b, new Vec4s()); 147 | } 148 | 149 | public Vec4s notEqual(Vec4s b, Vec4s res) { 150 | return Glm.notEqual((Vec4s) this, b, res); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/s/Vec4s.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.s; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class Vec4s extends FuncRelational { 13 | 14 | public Vec4s() { 15 | x = 0; 16 | y = 0; 17 | z = 0; 18 | w = 0; 19 | } 20 | 21 | public Vec4s(int x, int y, int z, int w) { 22 | this((short) x, (short) y, (short) z, (short) w); 23 | } 24 | 25 | public Vec4s(short x, short y, short z, short w) { 26 | this.x = x; 27 | this.y = y; 28 | this.z = z; 29 | this.w = w; 30 | } 31 | 32 | public Vec4s set(int x, int y, int z, int w) { 33 | return set((short) x, (short) y, (short) z, (short) w); 34 | } 35 | 36 | public Vec4s set(short x, short y, short z, short w) { 37 | this.x = x; 38 | this.y = y; 39 | this.z = z; 40 | this.w = w; 41 | return this; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/t/Vec4t.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.t; 7 | 8 | /** 9 | * 10 | * @author elect 11 | */ 12 | public class Vec4t { 13 | 14 | public T r; 15 | public T g; 16 | public T b; 17 | public T a; 18 | 19 | public Vec4t(T t) { 20 | r = t; 21 | g = t; 22 | b = t; 23 | a = t; 24 | } 25 | 26 | public Vec4t(T r, T g, T b, T a) { 27 | this.r = r; 28 | this.g = g; 29 | this.b = b; 30 | this.a = a; 31 | } 32 | 33 | // public T[] toArray() { 34 | // return new T[]{r, g, b, a}; 35 | // } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/ub/Vec4ub.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.ub; 7 | 8 | import joou.UByte; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | public class Vec4ub extends FuncRelational { 15 | 16 | public Vec4ub() { 17 | x.value = 0; 18 | y.value = 0; 19 | z.value = 0; 20 | w.value = 0; 21 | } 22 | 23 | public Vec4ub(int x, int y, int z, int w) { 24 | this((byte) x, (byte) y, (byte) z, (byte) w); 25 | } 26 | 27 | public Vec4ub(byte x, byte y, byte z, byte w) { 28 | this(new UByte(x), new UByte(y), new UByte(z), new UByte(w)); 29 | } 30 | 31 | public Vec4ub(UByte x, UByte y, UByte z, UByte w) { 32 | this.x = x; 33 | this.y = y; 34 | this.z = z; 35 | this.w = w; 36 | } 37 | 38 | public Vec4ub set(UByte x, UByte y, UByte z, UByte w) { 39 | this.x = x; 40 | this.y = y; 41 | this.z = z; 42 | this.w = w; 43 | return this; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/ul/Vec4ul.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.ul; 7 | 8 | import joou.ULong; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | public class Vec4ul extends FuncRelational { 15 | 16 | public Vec4ul() { 17 | x.value = 0; 18 | y.value = 0; 19 | z.value = 0; 20 | w.value = 0; 21 | } 22 | 23 | public Vec4ul(int x, int y, int z, int w) { 24 | this((long) x, y, z, w); 25 | } 26 | 27 | public Vec4ul(long x, long y, long z, long w) { 28 | this.x.value = x; 29 | this.y.value = y; 30 | this.z.value = z; 31 | this.w.value = w; 32 | } 33 | 34 | public Vec4ul set(ULong x, ULong y, ULong z, ULong w) { 35 | this.x = x; 36 | this.y = y; 37 | this.z = z; 38 | this.w = w; 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/glm/vec/_4/us/Vec4us.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm.vec._4.us; 7 | 8 | import joou.UShort; 9 | 10 | /** 11 | * 12 | * @author GBarbieri 13 | */ 14 | public class Vec4us extends FuncRelational { 15 | 16 | public Vec4us() { 17 | x.value = 0; 18 | y.value = 0; 19 | z.value = 0; 20 | w.value = 0; 21 | } 22 | 23 | public Vec4us(int x, int y, int z, int w) { 24 | this((short) x, (short) y, (short) z, (short) w); 25 | } 26 | 27 | public Vec4us(short x, short y, short z, short w) { 28 | this.x.value = x; 29 | this.y.value = y; 30 | this.z.value = z; 31 | this.w.value = w; 32 | } 33 | 34 | public Vec4us set(UShort x, UShort y, UShort z, UShort w) { 35 | this.x = x; 36 | this.y = y; 37 | this.z = z; 38 | this.w = w; 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/jglm/Mat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package jglm; 6 | 7 | /** 8 | * @deprecated 9 | * @author gbarbieri 10 | */ 11 | public class Mat { 12 | 13 | // protected float[] matrix; 14 | protected int order; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/jglm/Vec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package jglm; 6 | 7 | /** 8 | * @deprecated 9 | * @author gbarbieri 10 | */ 11 | public class Vec { 12 | 13 | protected float[] vector; 14 | protected int order; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/jglm/Vec2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package jglm; 6 | 7 | /** 8 | * @deprecated 9 | * @author gbarbieri 10 | */ 11 | public class Vec2 extends Vec { 12 | 13 | public float x; 14 | public float y; 15 | 16 | public Vec2() { 17 | 18 | x = 0; 19 | y = 0; 20 | } 21 | 22 | public Vec2(float[] floatArray) { 23 | vector = floatArray; 24 | x = vector[0]; 25 | y = vector[1]; 26 | } 27 | 28 | public Vec2(float x, float y) { 29 | 30 | this.x = x; 31 | this.y = y; 32 | vector = new float[]{x, y}; 33 | } 34 | 35 | public Vec2(float[] floatArray, int i) { 36 | 37 | vector = new float[]{floatArray[i], floatArray[i + 1]}; 38 | x = vector[0]; 39 | y = vector[1]; 40 | } 41 | 42 | public Vec2 normalize() { 43 | 44 | float length = ((float) Math.sqrt(x * x + y * y)); 45 | 46 | return new Vec2(x / length, y / length); 47 | } 48 | 49 | public Vec2 times(float scalar) { 50 | 51 | return new Vec2(x * scalar, y * scalar); 52 | } 53 | 54 | public Vec2 plus(Vec2 vec2) { 55 | 56 | return new Vec2(x + vec2.x, y + vec2.y); 57 | } 58 | 59 | public Vec2 minus(Vec2 vec2) { 60 | 61 | return new Vec2(x - vec2.x, y - vec2.y); 62 | } 63 | 64 | public Vec2 minus(Vec2i vec2) { 65 | 66 | return new Vec2(x - vec2.x, y - vec2.y); 67 | } 68 | 69 | public Vec2 negated() { 70 | 71 | return new Vec2(-x, -y); 72 | } 73 | 74 | public float length() { 75 | 76 | return (float) Math.sqrt(x * x + y * y); 77 | } 78 | 79 | public void print() { 80 | System.out.println("(" + x + ", " + y + ")"); 81 | } 82 | 83 | public void print(String title) { 84 | System.out.println(title + " (" + x + ", " + y + ")"); 85 | } 86 | 87 | public float[] toFloatArray(){ 88 | 89 | return new float[]{x, y}; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/jglm/Vec2i.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package jglm; 6 | 7 | /** 8 | * @deprecated 9 | * @author gbarbieri 10 | */ 11 | public class Vec2i extends Veci { 12 | 13 | public int x; 14 | public int y; 15 | 16 | public Vec2i() { 17 | 18 | x = 0; 19 | y = 0; 20 | } 21 | 22 | public Vec2i(int[] floatArray) { 23 | 24 | vector = floatArray; 25 | 26 | x = vector[0]; 27 | y = vector[1]; 28 | } 29 | 30 | public Vec2i(int x, int y) { 31 | 32 | this.x = x; 33 | this.y = y; 34 | vector = new int[]{x, y}; 35 | } 36 | 37 | public Vec2i(int[] intArray, int i) { 38 | 39 | vector = new int[]{intArray[i], intArray[i + 1]}; 40 | x = vector[0]; 41 | y = vector[1]; 42 | } 43 | 44 | public Vec2i plus(Vec2i vec2i) { 45 | 46 | return new Vec2i(x + vec2i.x, y + vec2i.y); 47 | } 48 | 49 | public Vec2i minus(Vec2i vec2i) { 50 | 51 | return new Vec2i(x - vec2i.x, y - vec2i.y); 52 | } 53 | 54 | public Vec2i times(int scalar) { 55 | 56 | return new Vec2i(x * scalar, y * scalar); 57 | } 58 | 59 | public Vec2 times(float scalar) { 60 | 61 | return new Vec2(x * scalar, y * scalar); 62 | } 63 | 64 | public Vec2i negated() { 65 | 66 | return new Vec2i(-x, -y); 67 | } 68 | 69 | public void print() { 70 | System.out.println("(" + x + ", " + y + ")"); 71 | } 72 | 73 | public void print(String title) { 74 | System.out.println(title + " (" + x + ", " + y + ")"); 75 | } 76 | 77 | public int[] toIntArray() { 78 | 79 | return new int[]{x, y}; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/jglm/Vec3i.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package jglm; 6 | 7 | /** 8 | * @deprecated 9 | * @author gbarbieri 10 | */ 11 | public class Vec3i extends Veci { 12 | 13 | public int x; 14 | public int y; 15 | public int z; 16 | 17 | public Vec3i() { 18 | } 19 | 20 | public Vec3i(int[] intArray) { 21 | vector = intArray; 22 | x = vector[0]; 23 | y = vector[1]; 24 | z = vector[2]; 25 | } 26 | 27 | public Vec3i(int x, int y, int z) { 28 | 29 | this.x = x; 30 | this.y = y; 31 | this.z = z; 32 | vector = new int[]{x, y, z}; 33 | } 34 | 35 | public Vec3i(int[] floatArray, int i) { 36 | 37 | vector = new int[]{floatArray[i], floatArray[i + 1], floatArray[i + 2]}; 38 | x = vector[0]; 39 | y = vector[1]; 40 | z = vector[2]; 41 | } 42 | 43 | // public Vec3i(Vec4i vec4i){ 44 | // 45 | // x = vec4i.x; 46 | // y = vec4i.y; 47 | // z = vec4i.z; 48 | // vector = new int[]{x, y, z}; 49 | // } 50 | // 51 | // public Vec3 normalize() { 52 | // 53 | // float length = ((float) Math.sqrt(x * x + y * y + z * z)); 54 | // 55 | // return new Vec3(x / length, y / length, z / length); 56 | // } 57 | // 58 | // public Vec3 times(float scalar) { 59 | // 60 | // return new Vec3(x * scalar, y * scalar, z * scalar); 61 | // } 62 | // 63 | // public Vec3 times(Quat quat) { 64 | // 65 | // Quat inverse = quat.conjugate(); 66 | // 67 | // return inverse.mult(this); 68 | // } 69 | // 70 | // public Vec3 plus(Vec3 vec3) { 71 | // 72 | // return new Vec3(x + vec3.x, y + vec3.y, z + vec3.z); 73 | // } 74 | // 75 | // public Vec3 minus(Vec3 vec3) { 76 | // 77 | // return new Vec3(x - vec3.x, y - vec3.y, z - vec3.z); 78 | // } 79 | // 80 | // public Vec3 crossProduct(Vec3 vec3) { 81 | // 82 | // return new Vec3(y * vec3.z - z * vec3.y, z * vec3.x - x * vec3.z, x * vec3.y - y * vec3.x); 83 | // } 84 | // 85 | // public Vec3 negated() { 86 | // 87 | // return new Vec3(-x, -y, -z); 88 | // } 89 | // 90 | // public float length() { 91 | // 92 | // return (float) Math.sqrt(x * x + y * y + z * z); 93 | // } 94 | // 95 | // public void print() { 96 | // System.out.println("(" + x + ", " + y + ", " + z + ")"); 97 | // } 98 | // 99 | // public void print(String title) { 100 | // System.out.println(title + " (" + x + ", " + y + ", " + z + ")"); 101 | // } 102 | // 103 | // public float[] toFloatArray(){ 104 | // 105 | // return new float[]{x, y, z}; 106 | // } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/jglm/Vec4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package jglm; 6 | 7 | /** 8 | * @deprecated 9 | * @author gbarbieri 10 | */ 11 | public class Vec4 extends Vec { 12 | 13 | public float x; 14 | public float y; 15 | public float z; 16 | public float w; 17 | 18 | public Vec4() { 19 | 20 | super(); 21 | } 22 | 23 | public Vec4(float[] vec4) { 24 | vector = vec4; 25 | x = vector[0]; 26 | y = vector[1]; 27 | z = vector[2]; 28 | w = vector[3]; 29 | } 30 | 31 | public Vec4(float value) { 32 | vector = new float[]{value, value, value, value}; 33 | x = vector[0]; 34 | y = vector[1]; 35 | z = vector[2]; 36 | w = vector[3]; 37 | } 38 | 39 | public Vec4(int[] floatArray) { 40 | 41 | x = floatArray[0]; 42 | y = floatArray[1]; 43 | z = floatArray[2]; 44 | w = floatArray[3]; 45 | 46 | vector = new float[]{x, y, z, w}; 47 | } 48 | 49 | public Vec4(Vec3 vec3, float w) { 50 | x = vec3.x; 51 | y = vec3.y; 52 | z = vec3.z; 53 | this.w = w; 54 | vector = new float[]{x, y, z, this.w}; 55 | } 56 | 57 | public Vec4(float[] floatArray, int i) { 58 | vector = new float[]{floatArray[i], floatArray[i + 1], floatArray[i + 2], floatArray[i + 3]}; 59 | x = vector[0]; 60 | y = vector[1]; 61 | z = vector[2]; 62 | w = vector[3]; 63 | } 64 | 65 | public Vec4(float x, float y, float z, float w) { 66 | this.x = x; 67 | this.y = y; 68 | this.z = z; 69 | this.w = w; 70 | vector = new float[]{this.x, this.y, this.z, this.w}; 71 | } 72 | 73 | public Vec4 normalize() { 74 | 75 | return new Vec4(x / length(), y / length(), z / length(), w / length()); 76 | } 77 | 78 | public float length() { 79 | 80 | return (float) Math.sqrt(x * x + y * y + z * z + w * w); 81 | } 82 | 83 | public void print() { 84 | System.out.println("(" + x + ", " + y + ", " + z + ", " + w + ")"); 85 | } 86 | 87 | public void print(String title) { 88 | System.out.println(title + " (" + x + ", " + y + ", " + z + ", " + w + ")"); 89 | } 90 | 91 | public Vec4 mult(float scalar) { 92 | 93 | return new Vec4(x * scalar, y * scalar, z * scalar, w * scalar); 94 | } 95 | 96 | public Vec4 mult(Vec4 vec4) { 97 | 98 | return new Vec4(x * vec4.x, y * vec4.y, z * vec4.z, w * vec4.w); 99 | } 100 | 101 | public Vec4 minus(Vec4 vec4) { 102 | 103 | return new Vec4(x - vec4.x, y - vec4.y, z - vec4.z, w - vec4.w); 104 | } 105 | 106 | public Vec4 minus(float scalar) { 107 | 108 | return new Vec4(x - scalar, y - scalar, z - scalar, w - scalar); 109 | } 110 | 111 | public Vec4 plus(Vec4 vec4) { 112 | 113 | return new Vec4(x + vec4.x, y + vec4.y, z + vec4.z, w + vec4.w); 114 | } 115 | 116 | public Vec4 divide(float scalar) { 117 | 118 | return new Vec4(x / scalar, y / scalar, z / scalar, w / scalar); 119 | } 120 | 121 | public float[] toFloatArray() { 122 | 123 | return new float[]{x, y, z, w}; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/jglm/Vec4i.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package jglm; 6 | 7 | /** 8 | * @deprecated 9 | * @author gbarbieri 10 | */ 11 | public class Vec4i extends Veci { 12 | 13 | public int x; 14 | public int y; 15 | public int z; 16 | public int w; 17 | 18 | public Vec4i() { 19 | 20 | super(); 21 | } 22 | 23 | public Vec4i(int[] vec4) { 24 | vector = vec4; 25 | x = vector[0]; 26 | y = vector[1]; 27 | z = vector[2]; 28 | w = vector[3]; 29 | } 30 | 31 | public Vec4i(int value) { 32 | vector = new int[]{value, value, value, value}; 33 | x = vector[0]; 34 | y = vector[1]; 35 | z = vector[2]; 36 | w = vector[3]; 37 | } 38 | 39 | public Vec4i(Vec3i vec3i, int w) { 40 | x = vec3i.x; 41 | y = vec3i.y; 42 | z = vec3i.z; 43 | this.w = w; 44 | vector = new int[]{x, y, z, this.w}; 45 | } 46 | 47 | public Vec4i(int[] intArray, int i) { 48 | vector = new int[]{intArray[i], intArray[i + 1], intArray[i + 2], intArray[i + 3]}; 49 | x = vector[0]; 50 | y = vector[1]; 51 | z = vector[2]; 52 | w = vector[3]; 53 | } 54 | 55 | public Vec4i(int x, int y, int z, int w) { 56 | this.x = x; 57 | this.y = y; 58 | this.z = z; 59 | this.w = w; 60 | vector = new int[]{this.x, this.y, this.z, this.w}; 61 | } 62 | 63 | public float length() { 64 | 65 | return (float) Math.sqrt(x * x + y * y + z * z + w * w); 66 | } 67 | 68 | public void print() { 69 | System.out.println("(" + x + ", " + y + ", " + z + ", " + w + ")"); 70 | } 71 | 72 | public void print(String title) { 73 | System.out.println(title + " (" + x + ", " + y + ", " + z + ", " + w + ")"); 74 | } 75 | 76 | // public Vec4 mult(float scalar) { 77 | // 78 | // return new Vec4(x * scalar, y * scalar, z * scalar, w * scalar); 79 | // } 80 | // 81 | // public Vec4 mult(Vec4 vec4) { 82 | // 83 | // return new Vec4(x * vec4.x, y * vec4.y, z * vec4.z, w * vec4.w); 84 | // } 85 | // 86 | // public Vec4 minus(Vec4 vec4) { 87 | // 88 | // return new Vec4(x - vec4.x, y - vec4.y, z - vec4.z, w - vec4.w); 89 | // } 90 | // 91 | // public Vec4 minus(float scalar) { 92 | // 93 | // return new Vec4(x - scalar, y - scalar, z - scalar, w - scalar); 94 | // } 95 | // 96 | // public Vec4 plus(Vec4 vec4) { 97 | // 98 | // return new Vec4(x + vec4.x, y + vec4.y, z + vec4.z, w + vec4.w); 99 | // } 100 | // 101 | // public Vec4 divide(float scalar) { 102 | // 103 | // return new Vec4(x / scalar, y / scalar, z / scalar, w / scalar); 104 | // } 105 | // 106 | public float[] toFloatArray() { 107 | 108 | return new float[]{x, y, z, w}; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/jglm/Veci.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package jglm; 6 | 7 | /** 8 | * @deprecated 9 | * @author gbarbieri 10 | */ 11 | public class Veci { 12 | 13 | protected int[] vector; 14 | protected int order; 15 | } -------------------------------------------------------------------------------- /src/main/java/joou/UMath.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package joou; 7 | 8 | /** 9 | * 10 | * @author GBarbieri 11 | */ 12 | public class UMath { 13 | 14 | public static UByte max(UByte a, UByte b) { 15 | return a.compareTo(b) > 0 ? a : b; 16 | } 17 | 18 | public static UInt max(UInt a, UInt b) { 19 | return a.compareTo(b) > 0 ? a : b; 20 | } 21 | 22 | public static ULong max(ULong a, ULong b) { 23 | return a.compareTo(b) > 0 ? a : b; 24 | } 25 | 26 | public static UShort max(UShort a, UShort b) { 27 | return a.compareTo(b) > 0 ? a : b; 28 | } 29 | 30 | public static UByte min(UByte a, UByte b) { 31 | return a.compareTo(b) < 0 ? a : b; 32 | } 33 | 34 | public static UInt min(UInt a, UInt b) { 35 | return a.compareTo(b) < 0 ? a : b; 36 | } 37 | 38 | public static ULong min(ULong a, ULong b) { 39 | return a.compareTo(b) < 0 ? a : b; 40 | } 41 | 42 | public static UShort min(UShort a, UShort b) { 43 | return a.compareTo(b) < 0 ? a : b; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/joou/UNumber.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2011-2016, Data Geekery GmbH (http://www.datageekery.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package joou; 17 | 18 | import java.math.BigInteger; 19 | 20 | /** 21 | * A base type for unsigned numbers. 22 | * 23 | * @author Lukas Eder 24 | */ 25 | public abstract class UNumber { 26 | 27 | /** 28 | * Generated UID 29 | */ 30 | private static final long serialVersionUID = -7666221938815339843L; 31 | 32 | /** 33 | * Get this number as a {@link BigInteger}. This is a convenience method for 34 | * calling new BigInteger(toString()) 35 | * @return 36 | */ 37 | public BigInteger toBigInteger() { 38 | return new BigInteger(toString()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/dev/Mat3Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package dev; 7 | 8 | import glm.mat._3.Mat3; 9 | import static org.junit.Assert.assertTrue; 10 | import org.junit.Test; 11 | 12 | /** 13 | * 14 | * @author GBarbieri 15 | */ 16 | public class Mat3Test { 17 | 18 | public Mat3Test(){ 19 | 20 | } 21 | 22 | @Test 23 | public void test_invTransp_a() { 24 | System.out.println("invTransp_a"); 25 | Mat3 mat = new Mat3(7,2,1,0,3,-1,-3,4,-2); 26 | Mat3 expResult = new Mat3(-2f, 3f, 9f, 8f, -11f, -34f, -5f, 7f, 21f); 27 | mat.invTransp(mat); 28 | assertTrue(mat.equals(expResult)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/dev/glmTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package dev; 7 | 8 | import glm.GlmTest; 9 | import org.junit.Assert; 10 | import org.junit.Test; 11 | 12 | /** 13 | * 14 | * @author GBarbieri 15 | */ 16 | public class glmTest { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/glm/GlmTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm; 7 | 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | 11 | /** 12 | * 13 | * @author GBarbieri 14 | */ 15 | public class GlmTest { 16 | 17 | @Test 18 | public void test_ceilMultiple_a() { 19 | System.out.println("ceilMultiple_a"); 20 | int result = Glm.ceilMultiple(60, 256); 21 | int expResult = 256; 22 | Assert.assertEquals(result, expResult); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/glm/_ArithmeticOperators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package glm; 7 | 8 | import static org.junit.Assert.assertTrue; 9 | import glm.vec._2.b.Vec2b; 10 | import org.junit.Test; 11 | 12 | /** 13 | * 14 | * @author GBarbieri 15 | */ 16 | public class _ArithmeticOperators { 17 | 18 | @Test 19 | public void vec2() { 20 | 21 | Vec2b a, b, c; 22 | 23 | a = new Vec2b(1); 24 | c = a.add_(1); 25 | a.add(1); 26 | assertTrue(a.equals(new Vec2b(2))); 27 | assertTrue(a.equals(c)); 28 | 29 | a = new Vec2b(1); 30 | b = new Vec2b(2, -1); 31 | c = a.add_(b); 32 | a.add(b); 33 | assertTrue(a.equals(new Vec2b(3, 0))); 34 | assertTrue(a.equals(c)); 35 | 36 | a = new Vec2b(1); 37 | c = a.sub_(1); 38 | a.sub(1); 39 | assertTrue(a.equals(new Vec2b(0))); 40 | assertTrue(a.equals(c)); 41 | 42 | a = new Vec2b(1); 43 | b = new Vec2b(2, -1); 44 | c = a.sub_(b); 45 | a.sub(b); 46 | assertTrue(a.equals(new Vec2b(-1, 2))); 47 | assertTrue(a.equals(c)); 48 | 49 | a = new Vec2b(1); 50 | c = a.mul_(2); 51 | a.mul(2); 52 | assertTrue(a.equals(new Vec2b(2))); 53 | assertTrue(a.equals(c)); 54 | 55 | a = new Vec2b(2); 56 | b = new Vec2b(2); 57 | c = a.div_(b); 58 | a.div(b); 59 | assertTrue(a.equals(new Vec2b(1))); 60 | assertTrue(a.equals(c)); 61 | 62 | a = new Vec2b(1, 2); 63 | b = new Vec2b(4, 5); 64 | 65 | c = a.add_(b); 66 | assertTrue(c.equals(new Vec2b(5, 7))); 67 | 68 | c = b.sub_(a); 69 | assertTrue(c.equals(new Vec2b(3))); 70 | 71 | c = a.mul_(b); 72 | assertTrue(c.equals(new Vec2b(4, 10))); 73 | 74 | c = b.div_(a); 75 | assertTrue(c.equals(new Vec2b(4, 2))); 76 | 77 | c = a.add_(1); 78 | assertTrue(c.equals(new Vec2b(2, 3))); 79 | 80 | c = b.sub_(1); 81 | assertTrue(c.equals(new Vec2b(3, 4))); 82 | 83 | c = a.mul_(2); 84 | assertTrue(c.equals(new Vec2b(2, 4))); 85 | 86 | c = b.div_(2); 87 | assertTrue(c.equals(new Vec2b(2))); 88 | } 89 | } 90 | --------------------------------------------------------------------------------