Search in sources :

Example 1 with Quaternionfc

use of org.joml.Quaternionfc in project Terasology by MovingBlocks.

the class RotationTest method testRotateSideYaw.

@Test
public void testRotateSideYaw() {
    Rotation rotation = Rotation.rotate(Yaw.CLOCKWISE_90);
    Quaternionfc rot = rotation.orientation();
    Vector3f dir = rot.transform(Side.FRONT.toDirection().asVector3f(), new Vector3f());
    assertEquals(Direction.inDirection(dir).toSide(), rotation.rotate(Side.FRONT));
    assertEquals(Side.LEFT, Rotation.rotate(Yaw.CLOCKWISE_90).rotate(Side.FRONT));
    assertEquals(Side.TOP, Rotation.rotate(Yaw.CLOCKWISE_90).rotate(Side.TOP));
}
Also used : Quaternionfc(org.joml.Quaternionfc) Vector3f(org.joml.Vector3f) Rotation(org.terasology.engine.math.Rotation) Test(org.junit.jupiter.api.Test)

Example 2 with Quaternionfc

use of org.joml.Quaternionfc in project Terasology by MovingBlocks.

the class RotationTest method testRotateMixed.

@Test
public void testRotateMixed() {
    Rotation rotation = Rotation.rotate(Yaw.CLOCKWISE_180, Pitch.CLOCKWISE_90, Roll.CLOCKWISE_90);
    Quaternionfc rot = rotation.orientation();
    Vector3f dir = rot.transform(Side.FRONT.toDirection().asVector3f(), new Vector3f());
    assertEquals(Direction.inDirection(dir).toSide(), rotation.rotate(Side.FRONT));
}
Also used : Quaternionfc(org.joml.Quaternionfc) Vector3f(org.joml.Vector3f) Rotation(org.terasology.engine.math.Rotation) Test(org.junit.jupiter.api.Test)

Example 3 with Quaternionfc

use of org.joml.Quaternionfc in project Terasology by MovingBlocks.

the class RotationTest method testRotateSideRoll.

@Test
public void testRotateSideRoll() {
    Rotation rotation = Rotation.rotate(Roll.CLOCKWISE_90);
    Quaternionfc rot = rotation.orientation();
    Vector3f dir = rot.transform(Side.TOP.toDirection().asVector3f(), new Vector3f());
    assertEquals(Direction.inDirection(dir).toSide(), rotation.rotate(Side.TOP));
    assertEquals(Side.LEFT, Rotation.rotate(Roll.CLOCKWISE_90).rotate(Side.TOP));
    assertEquals(Side.FRONT, Rotation.rotate(Roll.CLOCKWISE_90).rotate(Side.FRONT));
}
Also used : Quaternionfc(org.joml.Quaternionfc) Vector3f(org.joml.Vector3f) Rotation(org.terasology.engine.math.Rotation) Test(org.junit.jupiter.api.Test)

Example 4 with Quaternionfc

use of org.joml.Quaternionfc in project Terasology by MovingBlocks.

the class RotationTest method testRotateSidePitch.

@Test
public void testRotateSidePitch() {
    Rotation rotation = Rotation.rotate(Pitch.CLOCKWISE_90);
    Quaternionfc rot = rotation.orientation();
    Vector3f dir = rot.transform(Side.FRONT.toDirection().asVector3f(), new Vector3f());
    assertEquals(Direction.inDirection(dir).toSide(), rotation.rotate(Side.FRONT));
    assertEquals(Side.TOP, Rotation.rotate(Pitch.CLOCKWISE_90).rotate(Side.FRONT));
    assertEquals(Side.RIGHT, Rotation.rotate(Pitch.CLOCKWISE_90).rotate(Side.RIGHT));
}
Also used : Quaternionfc(org.joml.Quaternionfc) Vector3f(org.joml.Vector3f) Rotation(org.terasology.engine.math.Rotation) Test(org.junit.jupiter.api.Test)

Aggregations

Quaternionfc (org.joml.Quaternionfc)4 Vector3f (org.joml.Vector3f)4 Test (org.junit.jupiter.api.Test)4 Rotation (org.terasology.engine.math.Rotation)4