use of org.spongepowered.math.vector.Vector3d in project SpongeCommon by SpongePowered.
the class SpongeAABBTest method testExpandVector3d.
@Test
void testExpandVector3d() {
final AABB aabb1 = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13));
final AABB aabb2 = new SpongeAABB(new Vector3d(-4, 3, 2.5), new Vector3d(12, 9, 13.5));
Assertions.assertEquals(aabb2, aabb1.expand(new Vector3d(10, -2, 1)));
}
use of org.spongepowered.math.vector.Vector3d in project SpongeCommon by SpongePowered.
the class SpongeAABBTest method testSize.
@Test
void testSize() {
final AABB aabb = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13));
Assertions.assertEquals(new Vector3d(6, 8, 10), aabb.size());
}
use of org.spongepowered.math.vector.Vector3d in project SpongeCommon by SpongePowered.
the class SpongeAABBTest method newIntersectingAABB.
private static AABB newIntersectingAABB(AABB with) {
final Vector3d wMin = with.min();
final Vector3d wSize = with.size();
final double iSizeX = RANDOM.nextDouble() * wSize.x();
final double iSizeY = RANDOM.nextDouble() * wSize.y();
final double iSizeZ = RANDOM.nextDouble() * wSize.z();
final double eSizeX = RANDOM.nextDouble() * 4 + 4;
final double eSizeY = RANDOM.nextDouble() * 4 + 4;
final double eSizeZ = RANDOM.nextDouble() * 4 + 4;
final Vector3d min = wMin.sub(eSizeX, eSizeY, eSizeZ);
final Vector3d max = wMin.add(iSizeX, iSizeY, iSizeZ);
return new SpongeAABB(min, max);
}
use of org.spongepowered.math.vector.Vector3d in project SpongeCommon by SpongePowered.
the class SpongeAABBTest method testConstructor.
@Test
void testConstructor() {
final AABB aabb1 = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13));
Assertions.assertEquals(new Vector3d(1, 2, 3), aabb1.min());
Assertions.assertEquals(new Vector3d(7, 10, 13), aabb1.max());
final AABB aabb2 = new SpongeAABB(new Vector3d(11, 2, 3), new Vector3d(7, -10, 13));
Assertions.assertEquals(new Vector3d(7, -10, 3), aabb2.min());
Assertions.assertEquals(new Vector3d(11, 2, 13), aabb2.max());
try {
new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(1, 10, 13));
Assertions.fail();
} catch (IllegalArgumentException ignored) {
// pass
}
try {
new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 2, 13));
Assertions.fail();
} catch (IllegalArgumentException ignored) {
// pass
}
try {
new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 3));
Assertions.fail();
} catch (IllegalArgumentException ignored) {
// pass
}
}
use of org.spongepowered.math.vector.Vector3d in project SpongeCommon by SpongePowered.
the class SpongeAABBTest method testExpandVector3i.
@Test
void testExpandVector3i() {
final AABB aabb1 = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13));
final AABB aabb2 = new SpongeAABB(new Vector3d(-4, 3, 2.5), new Vector3d(12, 9, 13.5));
Assertions.assertEquals(aabb2, aabb1.expand(new Vector3i(10, -2, 1)));
}
Aggregations