Java Code Examples for org.joml.Matrix4f#positiveX()

The following examples show how to use org.joml.Matrix4f#positiveX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Matrix4fTest.java    From JOML with MIT License 5 votes vote down vote up
public static void testPositiveXRotateY() {
    Vector3f dir = new Vector3f();
    Matrix4f m = new Matrix4f()
            .rotateY((float) Math.toRadians(90));
    m.positiveX(dir);
    TestUtil.assertVector3fEquals(new Vector3f(0, 0, 1), dir, 1E-7f);
}
 
Example 2
Source File: Matrix4fTest.java    From JOML with MIT License 5 votes vote down vote up
public static void testPositiveXRotateXY() {
    Vector3f dir = new Vector3f();
    Matrix4f m = new Matrix4f()
            .rotateY((float) Math.toRadians(90)).rotateX((float) Math.toRadians(45));
    m.positiveX(dir);
    TestUtil.assertVector3fEquals(new Vector3f(0, 1, 1).normalize(), dir, 1E-7f);
}
 
Example 3
Source File: Matrix4fTest.java    From JOML with MIT License 5 votes vote down vote up
public static void testPositiveXPerspectiveRotateY() {
    Vector3f dir = new Vector3f();
    Matrix4f m = new Matrix4f()
            .perspective((float) Math.toRadians(90), 1.0f, 0.1f, 100.0f)
            .rotateY((float) Math.toRadians(90));
    m.positiveX(dir);
    TestUtil.assertVector3fEquals(new Vector3f(0, 0, -1), dir, 1E-7f);
}
 
Example 4
Source File: Matrix4fTest.java    From JOML with MIT License 5 votes vote down vote up
public static void testPositiveXPerspectiveRotateXY() {
    Vector3f dir = new Vector3f();
    Matrix4f m = new Matrix4f()
            .perspective((float) Math.toRadians(90), 1.0f, 0.1f, 100.0f)
            .rotateY((float) Math.toRadians(90)).rotateX((float) Math.toRadians(45));
    m.positiveX(dir);
    TestUtil.assertVector3fEquals(new Vector3f(0, -1, -1).normalize(), dir, 1E-7f);
}
 
Example 5
Source File: Matrix4fTest.java    From JOML with MIT License 5 votes vote down vote up
public static void testPositiveXYZLookAt() {
    Vector3f dir = new Vector3f();
    Matrix4f m = new Matrix4f()
            .lookAt(0, 0, 0, -1, 0, 0, 0, 1, 0);
    m.positiveX(dir);
    TestUtil.assertVector3fEquals(new Vector3f(0, 0, -1).normalize(), dir, 1E-7f);
    m.positiveY(dir);
    TestUtil.assertVector3fEquals(new Vector3f(0, 1, 0).normalize(), dir, 1E-7f);
    m.positiveZ(dir);
    TestUtil.assertVector3fEquals(new Vector3f(1, 0, 0).normalize(), dir, 1E-7f);
}
 
Example 6
Source File: Matrix4fTest.java    From JOML with MIT License 5 votes vote down vote up
public static void testPositiveXYZSameAsInvert() {
    Vector3f dir = new Vector3f();
    Vector3f dir2 = new Vector3f();
    Matrix4f m = new Matrix4f().rotateXYZ(0.12f, 1.25f, -2.56f);
    Matrix4f inv = new Matrix4f(m).invert();
    m.positiveX(dir);
    inv.transformDirection(dir2.set(1, 0, 0));
    TestUtil.assertVector3fEquals(dir2, dir, 1E-6f);
    m.positiveY(dir);
    inv.transformDirection(dir2.set(0, 1, 0));
    TestUtil.assertVector3fEquals(dir2, dir, 1E-6f);
    m.positiveZ(dir);
    inv.transformDirection(dir2.set(0, 0, 1));
    TestUtil.assertVector3fEquals(dir2, dir, 1E-6f);
}