Search in sources :

Example 6 with Transformation

use of org.spongepowered.api.util.transformation.Transformation in project SpongeCommon by SpongePowered.

the class TransformationTest method performRotationTest.

private Transformation performRotationTest(final Rotation rotation, final Vector3d original, final Vector3d expected, final Vector3d origin, final int rotateTimes) {
    // given this builder
    final SpongeTransformationBuilder transformationBuilder = new SpongeTransformationBuilder();
    // when rotating
    for (int i = 0; i < rotateTimes; ++i) {
        transformationBuilder.rotate(rotation);
    }
    final Transformation transformation = transformationBuilder.origin(origin).build();
    // then perform the transformation
    final Vector3d result = transformation.transformPosition(original);
    Assertions.assertEquals(expected, result, "Did not get expected rotation.");
    return transformation;
}
Also used : Transformation(org.spongepowered.api.util.transformation.Transformation) Vector3d(org.spongepowered.math.vector.Vector3d)

Aggregations

Transformation (org.spongepowered.api.util.transformation.Transformation)6 Vector3d (org.spongepowered.math.vector.Vector3d)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 MethodSource (org.junit.jupiter.params.provider.MethodSource)5 Rotation (org.spongepowered.api.util.rotation.Rotation)3 Stream (java.util.stream.Stream)1 Assertions (org.junit.jupiter.api.Assertions)1 Arguments (org.junit.jupiter.params.provider.Arguments)1 Mockito (org.mockito.Mockito)1 Answer (org.mockito.stubbing.Answer)1 BlockState (org.spongepowered.api.block.BlockState)1 Angle (org.spongepowered.api.util.Angle)1 Axis (org.spongepowered.api.util.Axis)1 ArchetypeVolume (org.spongepowered.api.world.volume.archetype.ArchetypeVolume)1 StubState (org.spongepowered.common.test.stub.block.StubState)1 AbstractReferentArchetypeVolume (org.spongepowered.common.world.volume.buffer.archetype.AbstractReferentArchetypeVolume)1 SpongeArchetypeVolume (org.spongepowered.common.world.volume.buffer.archetype.SpongeArchetypeVolume)1 Vector3i (org.spongepowered.math.vector.Vector3i)1