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

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

Introduction

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

Prototype

public double getX() 

Source Link

Document

Get the abscissa of the vector.

Usage

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.//  w ww .  ja  v  a  2s .c o  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. jav a2  s  .  co m*/
        FWEntityFX bwEntityFX = new FWEntityFX(world, entity);
        FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX);
        return bwEntityFX.wrapped;
    }
}

From source file:nova.core.wrapper.mc.forge.v17.network.netty.MCNetworkManager.java

public void sendToAllAround(PacketAbstract message, World world, Vector3D point, double range) {
    sendToAllAround(message, world, point.getX(), point.getY(), point.getZ(), range);
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

public Block getBlockInstance(net.minecraft.world.IBlockAccess access, Vector3D position) {
    /**/* w w  w .  ja v a 2  s  .  c  o  m*/
     * If this block has a TileEntity, forward the method into the Stateful
     * block. Otherwise, create a new instance of the block and forward the
     * methods over.
     */
    if (hasTileEntity(0)) {
        FWTile tileWrapper = (FWTile) access.getTileEntity((int) position.getX(), (int) position.getY(),
                (int) position.getZ());
        if (tileWrapper != null && tileWrapper.getBlock() != null) {
            return tileWrapper.getBlock();
        }

        System.out.println("Error: Block in TileWrapper is null.");
    }
    return getBlockInstance((nova.core.world.World) Game.natives().toNova(access), position);

}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld.java

@Override
public void markStaticRender(Vector3D position) {
    world().markBlockForUpdate((int) position.getX(), (int) position.getY(), (int) position.getZ());
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld.java

@Override
public void markChange(Vector3D position) {
    world().notifyBlockChange((int) position.getX(), (int) position.getY(), (int) position.getZ(),
            access.getBlock((int) position.getX(), (int) position.getY(), (int) position.getZ()));
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld.java

@Override
public Optional<Block> getBlock(Vector3D position) {
    net.minecraft.block.Block mcBlock = access.getBlock((int) position.getX(), (int) position.getY(),
            (int) position.getZ());
    if (mcBlock == null || mcBlock == Blocks.air) {
        Block airBlock = Game.blocks().getAirBlock().build();
        airBlock.components.add(new MCBlockTransform(airBlock, this, position));
        return Optional.of(airBlock);
    } else if (mcBlock instanceof FWBlock) {
        return Optional.of(((FWBlock) mcBlock).getBlockInstance(access, position));
    } else {//from  w ww. ja v  a 2  s  . c om
        return Optional.of(new BWBlock(mcBlock, this, position));
    }
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld.java

@Override
public boolean setBlock(Vector3D position, BlockFactory blockFactory) {
    //TODO: Implement object arguments
    net.minecraft.block.Block mcBlock = Game.natives().toNative(blockFactory.build());
    return world().setBlock((int) position.getX(), (int) position.getY(), (int) position.getZ(),
            mcBlock != null ? mcBlock : Blocks.air);
}