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

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

Introduction

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

Prototype

public Vector3D(double[] v) throws DimensionMismatchException 

Source Link

Document

Simple constructor.

Usage

From source file:org.jtrfp.trcl.obj.SmokeSystem.java

private boolean isNewSmokeFeasible(final Vector3D loc, SmokeType type) {
    final TreeSet<Smoke> proximalSmokes = new TreeSet<Smoke>(new Comparator<Smoke>() {
        @Override/*from www .  jav  a  2s  .c o m*/
        public int compare(Smoke o1, Smoke o2) {
            return Misc.satCastInt(o1.getTimeOfLastReset() - o2.getTimeOfLastReset());
        }
    });
    for (int smokeTypeIndex = 0; smokeTypeIndex < allSmokes.length; smokeTypeIndex++) {
        Smoke[] explosionsOfThisType = allSmokes[smokeTypeIndex];
        for (Smoke thisSmoke : explosionsOfThisType) {
            if (thisSmoke.isActive()) {
                final double distance = new Vector3D(thisSmoke.getPosition()).distance(loc);
                if (distance < 1000)
                    return false;
                if (distance < OneShotBillboardEvent.PROXIMITY_TEST_DIST)
                    proximalSmokes.add(thisSmoke);
            } // end if(isActive)
        } // end for(explosionsOfThisType)
    } // end for(explosions)
    if (proximalSmokes.size() + 1 > OneShotBillboardEvent.MAX_PROXIMAL_EVENTS)
        proximalSmokes.first().destroy();// Destroy oldest
    return true;
}

From source file:org.jtrfp.trcl.obj.SpawnsRandomExplosionsAndDebris.java

@Override
public void _tick(long timeMillis) {
    if (Math.random() < .05) {
        explosions.triggerExplosion(new Vector3D(getParent().getPosition()), ExplosionType.Blast);
    }/*from ww  w . ja  v a  2s .c  om*/
    if (Math.random() < .05) {
        explosions.triggerExplosion(new Vector3D(getParent().getPosition()), ExplosionType.Billow);
    }
    if (Math.random() < .1) {
        debris.spawn(new Vector3D(getParent().getPosition()), new Vector3D(Math.random() * 50000 - 25000,
                Math.random() * 50000 - 25000, Math.random() * 50000 - 25000));
    }
}

From source file:org.jtrfp.trcl.obj.WorldObject.java

/**
 * @return the heading
 */
public final Vector3D getLookAt() {
    return new Vector3D(heading);
}

From source file:org.jtrfp.trcl.obj.WorldObject.java

public Vector3D getHeading() {
    assert !(top[0] == 0 && top[1] == 0 && top[2] == 0);
    return new Vector3D(heading);
}

From source file:org.jtrfp.trcl.obj.WorldObject.java

/**
 * @return the top/*w w  w.java 2 s . c om*/
 */
public final Vector3D getTop() {
    assert !(top[0] == 0 && top[1] == 0 && top[2] == 0);
    return new Vector3D(top);
}

From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel.java

/** {@inheritDoc} */
public void addContribution(final SpacecraftState s, final TimeDerivativesEquations adder)
        throws OrekitException {

    // get the position in body frame
    final AbsoluteDate date = s.getDate();
    final Transform fromBodyFrame = bodyFrame.getTransformTo(s.getFrame(), date);
    final Transform toBodyFrame = fromBodyFrame.getInverse();
    final Vector3D position = toBodyFrame.transformPosition(s.getPVCoordinates().getPosition());

    // gradient of the non-central part of the gravity field
    final Vector3D gInertial = fromBodyFrame.transformVector(new Vector3D(gradient(date, position)));

    adder.addXYZAcceleration(gInertial.getX(), gInertial.getY(), gInertial.getZ());

}

From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel.java

/** {@inheritDoc} */
public FieldVector3D<DerivativeStructure> accelerationDerivatives(final AbsoluteDate date, final Frame frame,
        final FieldVector3D<DerivativeStructure> position, final FieldVector3D<DerivativeStructure> velocity,
        final FieldRotation<DerivativeStructure> rotation, final DerivativeStructure mass)
        throws OrekitException {

    // get the position in body frame
    final Transform fromBodyFrame = bodyFrame.getTransformTo(frame, date);
    final Transform toBodyFrame = fromBodyFrame.getInverse();
    final Vector3D positionBody = toBodyFrame.transformPosition(position.toVector3D());

    // compute gradient and Hessian
    final GradientHessian gh = gradientHessian(date, positionBody);

    // gradient of the non-central part of the gravity field
    final double[] gInertial = fromBodyFrame.transformVector(new Vector3D(gh.getGradient())).toArray();

    // Hessian of the non-central part of the gravity field
    final RealMatrix hBody = new Array2DRowRealMatrix(gh.getHessian(), false);
    final RealMatrix rot = new Array2DRowRealMatrix(toBodyFrame.getRotation().getMatrix());
    final RealMatrix hInertial = rot.transpose().multiply(hBody).multiply(rot);

    // distribute all partial derivatives in a compact acceleration vector
    final int parameters = mass.getFreeParameters();
    final int order = mass.getOrder();
    final double[] derivatives = new double[1 + parameters];
    final DerivativeStructure[] accDer = new DerivativeStructure[3];
    for (int i = 0; i < 3; ++i) {

        // first element is value of acceleration (i.e. gradient of field)
        derivatives[0] = gInertial[i];/*ww w  .java2  s .  c o  m*/

        // next three elements are one row of the Jacobian of acceleration (i.e. Hessian of field)
        derivatives[1] = hInertial.getEntry(i, 0);
        derivatives[2] = hInertial.getEntry(i, 1);
        derivatives[3] = hInertial.getEntry(i, 2);

        // next elements (three or four depending on mass being used or not) are left as 0

        accDer[i] = new DerivativeStructure(parameters, order, derivatives);

    }

    return new FieldVector3D<DerivativeStructure>(accDer);

}

From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel.java

/** {@inheritDoc} */
public FieldVector3D<DerivativeStructure> accelerationDerivatives(final SpacecraftState s,
        final String paramName) throws OrekitException, IllegalArgumentException {

    complainIfNotSupported(paramName);//  w  w  w .j a v  a2  s  .  co  m

    // get the position in body frame
    final AbsoluteDate date = s.getDate();
    final Transform fromBodyFrame = bodyFrame.getTransformTo(s.getFrame(), date);
    final Transform toBodyFrame = fromBodyFrame.getInverse();
    final Vector3D position = toBodyFrame.transformPosition(s.getPVCoordinates().getPosition());

    // gradient of the non-central part of the gravity field
    final Vector3D gInertial = fromBodyFrame.transformVector(new Vector3D(gradient(date, position)));

    return new FieldVector3D<DerivativeStructure>(
            new DerivativeStructure(1, 1, gInertial.getX(), gInertial.getX() / mu),
            new DerivativeStructure(1, 1, gInertial.getY(), gInertial.getY() / mu),
            new DerivativeStructure(1, 1, gInertial.getZ(), gInertial.getZ() / mu));

}