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:org.orekit.utils.TimeStampedPVCoordinatesTest.java

@Test
public void testInterpolateNonPolynomial() {
    AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH;

    List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>();
    for (double dt : new double[] { 0.0, 0.5, 1.0 }) {
        Vector3D position = new Vector3D(FastMath.cos(dt), FastMath.sin(dt), 0.0);
        Vector3D velocity = new Vector3D(-FastMath.sin(dt), FastMath.cos(dt), 0.0);
        Vector3D acceleration = new Vector3D(-FastMath.cos(dt), -FastMath.sin(dt), 0.0);
        sample.add(new TimeStampedPVCoordinates(t0.shiftedBy(dt), position, velocity, acceleration));
    }//from   w ww .  j av a 2  s.c o  m

    for (double dt = 0; dt < 1.0; dt += 0.01) {
        TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(t0.shiftedBy(dt),
                CartesianDerivativesFilter.USE_PVA, sample);
        Vector3D p = interpolated.getPosition();
        Vector3D v = interpolated.getVelocity();
        Vector3D a = interpolated.getAcceleration();
        Assert.assertEquals(FastMath.cos(dt), p.getX(), 3.0e-10 * p.getNorm());
        Assert.assertEquals(FastMath.sin(dt), p.getY(), 3.0e-10 * p.getNorm());
        Assert.assertEquals(0, p.getZ(), 3.0e-10 * p.getNorm());
        Assert.assertEquals(-FastMath.sin(dt), v.getX(), 3.0e-9 * v.getNorm());
        Assert.assertEquals(FastMath.cos(dt), v.getY(), 3.0e-9 * v.getNorm());
        Assert.assertEquals(0, v.getZ(), 3.0e-9 * v.getNorm());
        Assert.assertEquals(-FastMath.cos(dt), a.getX(), 4.0e-8 * a.getNorm());
        Assert.assertEquals(-FastMath.sin(dt), a.getY(), 4.0e-8 * a.getNorm());
        Assert.assertEquals(0, a.getZ(), 4.0e-8 * a.getNorm());
    }

}

From source file:org.rhwlab.dispim.nucleus.NamedNucleusFile.java

License:asdf

static public RealMatrix rotationMatrix(Vector3D A, Vector3D B) {
    Vector3D a = A.normalize();/*  w w w. j a  va2s  .  c  om*/
    Vector3D b = B.normalize();
    Vector3D v = a.crossProduct(b);

    double s = v.getNormSq();
    double c = a.dotProduct(b);

    RealMatrix vx = MatrixUtils.createRealMatrix(3, 3);
    vx.setEntry(1, 0, v.getZ());
    vx.setEntry(0, 1, -v.getZ());
    vx.setEntry(2, 0, -v.getY());
    vx.setEntry(0, 2, v.getY());
    vx.setEntry(2, 1, v.getX());
    vx.setEntry(1, 2, -v.getX());

    RealMatrix vx2 = vx.multiply(vx);
    RealMatrix scaled = vx2.scalarMultiply((1.0 - c) / s);

    RealMatrix ident = MatrixUtils.createRealIdentityMatrix(3);
    RealMatrix sum = vx.add(scaled);
    RealMatrix ret = ident.add(sum);

    return ret;
}

From source file:org.surmon.pattern.visualization.math.GLSphericalCoordinates.java

public GLSphericalCoordinates(Vector3D v) {
    super(new Vector3D(v.getZ(), v.getX(), v.getY()));
}

From source file:org.surmon.pattern.visualization.math.GLSphericalCoordinates.java

@Override
public Vector3D getCartesian() {
    Vector3D v = super.getCartesian();
    return new Vector3D(v.getY(), v.getZ(), v.getX());
}

From source file:org.surmon.pattern.visualization.math.GLSphericalCoordinates.java

public Vec3 getCartesianGLM() {
    Vector3D v = super.getCartesian();
    return new Vec3((float) v.getY(), (float) v.getZ(), (float) v.getX());
}

From source file:sceneGraph.Rot.java

public DVector applyTo(DVector v) {
    Vector3D result = new Vector3D((double) v.x, (double) v.y, (double) v.z);
    result = rotation.applyTo(result);/*from   w  w  w  .j a  v a  2 s  .c  o  m*/
    return new DVector((double) result.getX(), (double) result.getY(), (double) result.getZ());
}

From source file:sceneGraph.Rot.java

public DVector getAxis() {
    Vector3D v = rotation.getAxis();
    return new DVector((double) v.getX(), (double) v.getY(), (double) v.getZ());
}

From source file:sceneGraph.Rot.java

public PVector applyTo(PVector v) {
    Vector3D result = new Vector3D((double) v.x, (double) v.y, (double) v.z);
    result = rotation.applyTo(result);//ww  w  .  j av  a2s.c  o  m
    return new PVector((float) result.getX(), (float) result.getY(), (float) result.getZ());
}

From source file:services.SimulationService.java

public Ray convertRayToModelSpace(Point3D origin, Point3D end, SWGObject object) {

    Point3D position = object.getPosition();

    WB_M44 translateMatrix = new WB_M44(1, 0, 0, position.x, 0, 1, 0, position.y, 0, 0, 1, position.z, 0, 0, 0,
            1);//from w  w  w .java2 s  . c o m

    float radians = object.getRadians();
    float sin = (float) Math.sin(radians);
    float cos = (float) Math.cos(radians);

    WB_M44 rotationMatrix = new WB_M44(cos, 0, sin, 0, 0, 1, 0, 0, -sin, 0, cos, 0, 0, 0, 0, 1);

    WB_M44 modelSpace = null;
    try {
        modelSpace = translateMatrix.mult(rotationMatrix).inverse();
    } catch (Exception ex) {
        // It's usually a bank terminal causing this
        //System.out.println("The object " + object.getTemplate() + " at x:" + object.getWorldPosition().x + " z:" + object.getWorldPosition().z + " causes a problem during modelspaceconversion. Can be safely ignored.");
        if (modelSpace == null)
            return new Ray(origin, new Vector3D(0, 0, 0));
    }

    float originX = (float) (modelSpace.m11 * origin.x + modelSpace.m12 * origin.y + modelSpace.m13 * origin.z
            + modelSpace.m14);
    float originY = (float) (modelSpace.m21 * origin.x + modelSpace.m22 * origin.y + modelSpace.m23 * origin.z
            + modelSpace.m24);
    float originZ = (float) (modelSpace.m31 * origin.x + modelSpace.m32 * origin.y + modelSpace.m33 * origin.z
            + modelSpace.m34);

    origin = new Point3D(originX, originY, originZ);

    float endX = (float) (modelSpace.m11 * end.x + modelSpace.m12 * end.y + modelSpace.m13 * end.z
            + modelSpace.m14);
    float endY = (float) (modelSpace.m21 * end.x + modelSpace.m22 * end.y + modelSpace.m23 * end.z
            + modelSpace.m24);
    float endZ = (float) (modelSpace.m31 * end.x + modelSpace.m32 * end.y + modelSpace.m33 * end.z
            + modelSpace.m34);

    end = new Point3D(endX, endY, endZ);
    Vector3D direction = new Vector3D(end.x - origin.x, end.y - origin.y, end.z - origin.z);
    if (direction.getX() > 0 && direction.getY() > 0 && direction.getZ() > 0)
        direction.normalize();

    return new Ray(origin, direction);

}