Example usage for org.apache.commons.math3.geometry.euclidean.threed Vector3D getZ

List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D getZ

Introduction

In this page you can find the example usage for org.apache.commons.math3.geometry.euclidean.threed Vector3D getZ.

Prototype

public double getZ() 

Source Link

Document

Get the height of the vector.

Usage

From source file:nova.core.util.math.Vector3DUtil.java

public static Vector3D cartesianProduct(Vector3D a, Vector3D b) {
    return new Vector3D(a.getX() * b.getX(), a.getY() * b.getY(), a.getZ() * b.getZ());
}

From source file:nova.core.util.math.Vector3DUtil.java

public static Vector3D xCross(Vector3D vec) {
    return new Vector3D(0, vec.getZ(), -vec.getY());
}

From source file:nova.core.util.math.Vector3DUtil.java

/**
 * Calculates one by vectos.// w  ww .  java  2 s .co m
 * @param vec vector to be reciprocated.
 * @return reciprocal of vec.
 */
public static Vector3D reciprocal(Vector3D vec) {
    return new Vector3D(1 / vec.getX(), 1 / vec.getY(), 1 / vec.getZ());
}

From source file:nova.core.util.math.Vector3DUtil.java

public static Vector3D perpendicular(Vector3D vec) {
    // Special case. Z == 0 would cause a error.
    //noinspection FloatingPointEquality
    if (vec.getZ() == 0) {
        return zCross(vec);
    }//from w  ww. j  a  v a  2 s  .co  m

    return xCross(vec);
}

From source file:nova.core.util.math.Vector3DUtil.java

public static Vector3D round(Vector3D vec) {
    return new Vector3D(FastMath.round(vec.getX()), FastMath.round(vec.getY()), FastMath.round(vec.getZ()));
}

From source file:nova.core.util.math.Vector3DUtil.java

public static Vector3D ceil(Vector3D vec) {
    return new Vector3D(FastMath.ceil(vec.getX()), FastMath.ceil(vec.getY()), FastMath.ceil(vec.getZ()));
}

From source file:nova.core.util.math.Vector3DUtil.java

public static Vector3D floor(Vector3D vec) {
    return new Vector3D(FastMath.floor(vec.getX()), FastMath.floor(vec.getY()), FastMath.floor(vec.getZ()));
}

From source file:nova.core.util.math.Vector3DUtil.java

public static Vector3D abs(Vector3D vec) {
    return new Vector3D(FastMath.abs(vec.getX()), FastMath.abs(vec.getY()), FastMath.abs(vec.getZ()));
}

From source file:nova.core.util.RayTracer.java

/**
 * Calculates intersection with the given ray between a certain distance
 * interval.//from   w w w.java  2  s. co  m
 * <p>
 * Ray-box intersection is using IEEE numerical properties to ensure the
 * test is both robust and efficient, as described in:
 * <br>
 * <code>Amy Williams, Steve Barrus, R. Keith Morley, and Peter Shirley: "An
 * Efficient and Robust Ray-Box Intersection Algorithm" Journal of graphics
 * tools, 10(1):49-54, 2005</code>
 * @param cuboid The cuboid to trace
 * @param minDist The minimum distance
 * @param maxDist The maximum distance
 * @return intersection point on the bounding box (only the first is
 * returned) or null if no intersection
 */
public Optional<Vector3D> rayTrace(Cuboid cuboid, double minDist, double maxDist) {
    Vector3D bbox;

    double tMin;
    double tMax;

    bbox = ray.signDirX ? cuboid.max : cuboid.min;
    tMin = (bbox.getX() - ray.origin.getX()) * ray.invDir.getX();
    bbox = ray.signDirX ? cuboid.min : cuboid.max;
    tMax = (bbox.getX() - ray.origin.getX()) * ray.invDir.getX();

    //Y
    bbox = ray.signDirY ? cuboid.max : cuboid.min;
    double tyMin = (bbox.getY() - ray.origin.getY()) * ray.invDir.getY();
    bbox = ray.signDirY ? cuboid.min : cuboid.max;
    double tyMax = (bbox.getY() - ray.origin.getY()) * ray.invDir.getY();

    //Check with the current tMin and tMax to see if the clipping is out of bounds
    if ((tMin > tyMax) || (tyMin > tMax)) {
        return Optional.empty();
    }

    //Reset tMin and tMax
    if (tyMin > tMin) {
        tMin = tyMin;
    }
    if (tyMax < tMax) {
        tMax = tyMax;
    }
    bbox = ray.signDirZ ? cuboid.max : cuboid.min;
    double tzMin = (bbox.getZ() - ray.origin.getZ()) * ray.invDir.getZ();
    bbox = ray.signDirZ ? cuboid.min : cuboid.max;
    double tzMax = (bbox.getZ() - ray.origin.getZ()) * ray.invDir.getZ();

    //Check with the current tMin and tMax to see if the clipping is out of bounds
    if ((tMin > tzMax) || (tzMin > tMax)) {
        return Optional.empty();
    }

    //Reset tMin and tMax
    if (tzMin > tMin) {
        tMin = tzMin;
    }
    if (tzMax < tMax) {
        tMax = tzMax;
    }

    if ((tMin < maxDist) && (tMax > minDist)) {
        return Optional.of(ray.origin.add(ray.dir.scalarMultiply(tMin)));
    }

    return Optional.empty();
}

From source file:nova.core.wrapper.mc.forge.v17.launcher.ClientProxy.java

@Override
public Entity spawnParticle(net.minecraft.world.World world, Entity entity) {
    //Backward entity particle unwrapper
    if (entity instanceof BWEntityFX) {
        EntityFX entityFX = ((BWEntityFX) entity).createEntityFX();
        Vector3D position = entity.position();
        entityFX.posX = position.getX();
        entityFX.posY = position.getY();
        entityFX.posZ = position.getZ();
        FMLClientHandler.instance().getClient().effectRenderer.addEffect(entityFX);
        return Game.natives().toNova(entityFX);
    } else {//from   w  w w.j  a  va2  s.com
        FWEntityFX bwEntityFX = new FWEntityFX(world, entity);
        FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX);
        return bwEntityFX.wrapped;
    }
}