Search in sources :

Example 1 with BaseVector3f

use of org.terasology.math.geom.BaseVector3f in project Terasology by MovingBlocks.

the class Region3i method createFromCenterExtents.

/**
 * Create a region with center point and x,y,z coordinate extents size
 * @param center the center point of region
 * @param extents the extents size of each side of region
 * @return a new region base on the center point and extents size
 */
public static Region3i createFromCenterExtents(BaseVector3f center, BaseVector3f extents) {
    Vector3f min = new Vector3f(center.x() - extents.x(), center.y() - extents.y(), center.z() - extents.z());
    Vector3f max = new Vector3f(center.x() + extents.x(), center.y() + extents.y(), center.z() + extents.z());
    max.x = max.x - Math.ulp(max.x);
    max.y = max.y - Math.ulp(max.y);
    max.z = max.z - Math.ulp(max.z);
    return createFromMinMax(new Vector3i(min), new Vector3i(max));
}
Also used : Vector3f(org.terasology.math.geom.Vector3f) BaseVector3f(org.terasology.math.geom.BaseVector3f) BaseVector3i(org.terasology.math.geom.BaseVector3i) Vector3i(org.terasology.math.geom.Vector3i)

Aggregations

BaseVector3f (org.terasology.math.geom.BaseVector3f)1 BaseVector3i (org.terasology.math.geom.BaseVector3i)1 Vector3f (org.terasology.math.geom.Vector3f)1 Vector3i (org.terasology.math.geom.Vector3i)1