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 x, double y, double z) 

Source Link

Document

Simple constructor.

Usage

From source file:edu.mit.fss.examples.member.OrekitSurfaceElement.java

/**
 * Gets the slant range (in meters) from this element 
 * to the specified element.//w w w .j  av a  2  s  .c o m
 *
 * @param element the element
 * @return the slant range to
 */
public double getSlantRange(Element element) {
    if (element.getFrame() == ReferenceFrame.UNKNOWN) {
        logger.warn("Unknown reference frame for element " + element + ",  cannot compute elevation.");
        return 0;
    }
    try {
        // use Orekit library to convert between reference frames
        Vector3D thisPosition = new Vector3D(0, 0, 0);
        Vector3D thatPosition = element.getFrame().getOrekitFrame().getTransformTo(topoFrame, getDate())
                .transformPosition(element.getPosition());

        // compute vector distance
        return thisPosition.distance(thatPosition);
    } catch (OrekitException e) {
        logger.error(e.getMessage());
    }
    return 0;
}

From source file:com.kircherelectronics.androidlinearacceleration.sensor.AccelerationSensor.java

/**
 * Orient the measurements from the absolute Android device rotation into
 * the current device orientation. Note that the rotation is different based
 * on the current rotation of the device relative to the absolute Android
 * rotation. Do not confuse this with a rotation into absolute earth frame,
 * or the NED orientation that the algorithm assumes.
 * /* w  ww .jav a  2 s  .  c o m*/
 * @param measurements
 *            the measurements referenced to the absolute Android
 *            orientation.
 * @return the measurements referenced to the current device rotation.
 * 
 * @see http 
 *      ://developer.android.com/reference/android/hardware/SensorEvent.html
 *      #values
 */
private float[] quaternionToDeviceVehicleMode(float[] matrix) {

    vIn = new Vector3D(matrix[0], matrix[1], matrix[2]);
    vOut = rotationQuaternion.applyTo(vIn);

    float[] rotation = { (float) vOut.getX(), (float) vOut.getY(), (float) vOut.getZ() };

    return rotation;
}

From source file:edu.mit.fss.examples.member.OrekitSurfaceElement.java

@Override
public Vector3D getVelocity() {
    return new Vector3D(0, 0, 0);
}

From source file:com.kircherelectronics.fusedgyroscopeexplorer.sensor.MagneticSensor.java

/**
 * Orient the measurements from the absolute Android device rotation into
 * the current device orientation. Note that the rotation is different based
 * on the current rotation of the device relative to the absolute Android
 * rotation. Do not confuse this with a rotation into absolute earth frame,
 * or the NED orientation that the algorithm assumes.
 * //w  w w.j a  v  a  2  s.c  om
 * @param measurements
 *            the measurements referenced to the absolute Android
 *            orientation.
 * @return the measurements referenced to the current device rotation.
 * 
 * @see http 
 *      ://developer.android.com/reference/android/hardware/SensorEvent.html
 *      #values
 */
private float[] quaternionToDeviceVehicleMode(float[] matrix) {
    vIn = new Vector3D(matrix[0], matrix[1], matrix[2]);
    vOut = rotationQuaternion.applyTo(vIn);

    float[] rotation = { (float) vOut.getX(), (float) vOut.getY(), (float) vOut.getZ() };

    return rotation;
}

From source file:edu.mit.fss.examples.member.OrekitOrbitalElement.java

/**
 * Checks if there is a line of sight between this element 
 * and the specified element./*from   w ww. j a va  2s  .c o m*/
 *
 * @param element the element
 * @return true, if there is a line of sight
 */
public boolean isLineOfSightVisible(Element element) {
    if (element.getFrame() == ReferenceFrame.UNKNOWN) {
        logger.warn("Unknown reference frame for element " + element + ",  cannot compute slant range.");
        return false;
    }
    if (element instanceof OrbitalElement) {
        // for orbital elements, check for Earth occlusion
        try {
            Vector3D thisPosition = getPosition();
            Vector3D thatPosition = element.getFrame().getOrekitFrame()
                    .getTransformTo(state.getFrame(), state.getDate()).transformPosition(element.getPosition());
            // calculate intersection point on Earth surface between elements
            // if null, there is no intersection and a line of sight exists
            return null == earth.getIntersectionPoint(new Line(thisPosition, thatPosition, 0.1),
                    new Vector3D(0, 0, 0), state.getFrame(), state.getDate());
        } catch (OrekitException e) {
            logger.error(e.getMessage());
            return false;
        }
    } else if (element instanceof SurfaceElement) {
        // for surface elements, check the elevation angle
        SurfaceElement surf = (SurfaceElement) element;
        try {
            // create a topocentric frame at surface element
            TopocentricFrame topo = new TopocentricFrame(earth,
                    new GeodeticPoint(FastMath.toRadians(surf.getLatitude()),
                            FastMath.toRadians(surf.getLongitude()), surf.getAltitude()),
                    element.getName());
            return topo.getElevation(getPosition(), state.getFrame(), state.getDate()) > 0;
        } catch (OrekitException e) {
            logger.error(e.getMessage());
            return false;
        }
    } else {
        logger.warn("Unknown type of element " + element + ",  cannot compute life of sight.");
        return false;
    }
}

From source file:Engine.Player.java

public ArrayList<DPolygon> GetPolygons(double x, double y) {
    /*Cube head = new Cube(- halfHeadSize + x, - halfHeadSize + y, ViewFrom[2] - halfHeadSize + epsBody,
    halfHeadSize * 2.0, halfHeadSize * 2.0, halfHeadSize * 2.0, Color.YELLOW, PlayerId);
    head.Polys[2].DrawablePolygon.texture = GenerateTerrain.img;
            // w ww.j a  v a2  s.  co  m
            
    Cube neck = new Cube(- halfNeckSize + x, - halfNeckSize + y, ViewFrom[2] - headSize + halfNeckSize,
        halfNeckSize * 2.0, halfNeckSize * 2.0, halfNeckSize, Color.PINK, PlayerId);
    Cube corpus = new Cube(- halfCorupsXSize + x, - halfCorupsYSize + y, ViewFrom[2] - corpusZSize - headSize + halfNeckSize - epsBody,
        halfCorupsXSize * 2.0, halfCorupsYSize * 2.0, 2 * halfCorpusZSize, Color.BLUE, PlayerId);
            
    Cube legs = new Cube(- halfLegSizeX + x, - halfLegSizeY + y, ViewFrom[2] - legZSize - corpusZSize - headSize + halfNeckSize - epsBody - epsBody,
        2 * halfLegSizeX, 2 * halfLegSizeY, legZSize, Color.MAGENTA, PlayerId);
            
    Cube hands = new Cube(- halfHandsXSize + x, - halfHandsYSize + y, ViewFrom[2] - handsZSize - headSize + halfNeckSize - epsBody,
        halfHandsXSize * 2.0, halfHandsYSize * 2.0, handsZSize, Color.CYAN, PlayerId);
            
            
            
    ArrayList<DPolygon> all = new ArrayList<DPolygon>();
            
    rot += 0.01;
            
    head.rotation = rot;
    head.setRotAdd();
    head.updatePoly();
            
    neck.rotation = rot;
    neck.updatePoly();
            
    corpus.rotation = rot;
    corpus.updatePoly();
            
    legs.rotation = rot;
    legs.updatePoly();
            
    hands.rotation = rot;
    hands.updatePoly();
            
            
    AddArrayToArrayList(all, head.GetPolygons());
    AddArrayToArrayList(all, neck.GetPolygons());
    AddArrayToArrayList(all, corpus.GetPolygons());
    AddArrayToArrayList(all, hands.GetPolygons());
    AddArrayToArrayList(all, legs.GetPolygons());*/

    //rot = Math.PI*0.75;
    //rot += 0.01;

    /*if (MoveDirection != null)
    {
    //0
    if (Math.abs(MoveDirection.getX()) < 0.1 && MoveDirection.getY() > 0.1) rot = 0;
    //1/4
    if (MoveDirection.getX() > 0.1 && MoveDirection.getY() > 0.1) rot = -Math.PI / 4.0;
    //1/2
    if (MoveDirection.getX() > 0.1 && Math.abs(MoveDirection.getY()) < 0.1) rot = -Math.PI / 2.0;
    //3/4
    if (MoveDirection.getX() > 0.1 && MoveDirection.getY() < 0.1) rot = -3.0 * Math.PI / 4.0;
    //1
    if (Math.abs(MoveDirection.getX()) < 0.1 && MoveDirection.getY() < 0.1) rot = -Math.PI;
    //5/4
    if (MoveDirection.getX() < 0.1 && MoveDirection.getY() < 0.1) rot = -5.0 * Math.PI / 4.0;
    //3/2
    if (MoveDirection.getX() < 0.1 && Math.abs(MoveDirection.getY()) < 0.1) rot = -3.0 * Math.PI / 2.0;
    //7/4
    if (MoveDirection.getX() < 0.1 && MoveDirection.getY() > 0.1) rot = -7.0 * Math.PI / 4.0;
            
    rot += 2 *  Math.PI / 4;
    }*/
    if (PositionIFace != null) {
        rot = Math.PI / 4.0;

        Vector3D v1 = new Vector3D(PositionIFace.getX(), PositionIFace.getY(), 0);
        Vector3D v2 = new Vector3D(ViewFrom[0], ViewFrom[1], 0);
        Vector3D v3 = (v1.subtract(v2)).normalize();

        Vector3D cross = Vector3D.crossProduct(v3, new Vector3D(1, 0, 0));
        double dot = Vector3D.dotProduct(v3, new Vector3D(1, 0, 0));

        double angle = Math.atan2(cross.getZ(), dot);
        rot += -angle;
    }

    double xx = -halfHeadSize + x;
    double yy = -halfHeadSize + y;
    double[] r = rotatePoint(xx, yy, xx, yy, rot - Math.PI * 0.75);

    Cube head = new Cube(r[0], r[1], ViewFrom[2] - halfHeadSize + epsBody, halfHeadSize * 2.0,
            halfHeadSize * 2.0, halfHeadSize * 2.0, Color.YELLOW, PlayerId);

    head.Polys[2].DrawablePolygon.texture = GenerateTerrain.img;

    Cube neck = new Cube(-halfNeckSize + x, -halfNeckSize + y, ViewFrom[2] - headSize + halfNeckSize,
            halfNeckSize * 2.0, halfNeckSize * 2.0, halfNeckSize, Color.PINK, PlayerId);
    Cube corpus = new Cube(-halfCorupsXSize + x, -halfCorupsYSize + y,
            ViewFrom[2] - corpusZSize - headSize + halfNeckSize - epsBody, halfCorupsXSize * 2.0,
            halfCorupsYSize * 2.0, 2 * halfCorpusZSize, Color.BLUE, PlayerId);

    Cube legs = new Cube(-halfLegSizeX + x, -halfLegSizeY + y,
            ViewFrom[2] - legZSize - corpusZSize - headSize + halfNeckSize - epsBody - epsBody,
            2 * halfLegSizeX, 2 * halfLegSizeY, legZSize, Color.MAGENTA, PlayerId);

    xx = -halfHandsXSize + x;
    yy = -halfHandsYSize + y;//- halfHandsYSize + (halfHandsYSize / 2.0) + y;
    r = rotatePoint(xx, yy, x - 0.5, y - halfHandsYSize, rot - Math.PI * 0.75);

    Cube handLeft = new Cube(r[0], r[1], ViewFrom[2] - handsZSize - headSize + halfNeckSize - epsBody, 1,
            halfHandsYSize * 2.0, handsZSize, Color.CYAN, PlayerId);

    xx = halfHandsXSize + x - 1;
    yy = -halfHandsYSize + y;//- halfHandsYSize + (halfHandsYSize / 2.0) + y;
    r = rotatePoint(xx, yy, x - 0.5, y - halfHandsYSize, rot - Math.PI * 0.75);

    Cube handRight = new Cube(r[0], r[1], ViewFrom[2] - handsZSize - headSize + halfNeckSize - epsBody, 1,
            halfHandsYSize * 2.0, handsZSize, Color.CYAN, PlayerId);

    xx = -2 + x;
    yy = -halfLegSizeY + y;//- halfHandsYSize + (halfHandsYSize / 2.0) + y;
    r = rotatePoint(xx, yy, x - 0.75, y - halfLegSizeY, rot - Math.PI * 0.75);

    Cube legLeft = new Cube(r[0], r[1],
            ViewFrom[2] - legZSize - corpusZSize - headSize + halfNeckSize - epsBody - epsBody, 1.5,
            halfLegSizeY * 2.0, legZSize, Color.CYAN, PlayerId);

    xx = 2 + x - 1.5;
    yy = -halfLegSizeY + y;//- halfHandsYSize + (halfHandsYSize / 2.0) + y;
    r = rotatePoint(xx, yy, x - 0.75, y - halfLegSizeY, rot - Math.PI * 0.75);

    Cube legRight = new Cube(r[0], r[1],
            ViewFrom[2] - legZSize - corpusZSize - headSize + halfNeckSize - epsBody - epsBody, 1.5,
            halfLegSizeY * 2.0, legZSize, Color.CYAN, PlayerId);
    //Cube legs = new Cube(- halfLegSizeX + x, - halfLegSizeY + y, ViewFrom[2] - legZSize - corpusZSize - headSize + halfNeckSize - epsBody - epsBody,
    //      2 * halfLegSizeX, 2 * halfLegSizeY, legZSize, Color.MAGENTA, PlayerId);

    ArrayList<DPolygon> all = new ArrayList<DPolygon>();

    //rot += 0.00;

    head.rotation = rot;
    head.setRotAdd();
    head.updatePoly();

    neck.rotation = rot;
    neck.updatePoly();

    corpus.rotation = rot;
    corpus.updatePoly();

    legs.rotation = rot;
    legs.updatePoly();

    handLeft.rotation = rot;
    handLeft.updatePoly();

    handRight.rotation = rot;
    handRight.updatePoly();

    legLeft.rotation = rot;
    legLeft.updatePoly();

    legRight.rotation = rot;
    legRight.updatePoly();

    AddArrayToArrayList(all, head.GetPolygons());
    AddArrayToArrayList(all, neck.GetPolygons());
    AddArrayToArrayList(all, corpus.GetPolygons());
    AddArrayToArrayList(all, handLeft.GetPolygons());
    AddArrayToArrayList(all, handRight.GetPolygons());
    AddArrayToArrayList(all, legLeft.GetPolygons());
    AddArrayToArrayList(all, legRight.GetPolygons());

    /*
            
            
            
            
            
    //rot = Math.PI*0.75;
    rot += 0.01;
    double xx = - halfHeadSize + x;
    double yy = - halfHeadSize + y;
    double[]r = rotatePoint(xx, yy, xx, yy, rot - Math.PI*0.75);
            
    Cube head = new Cube(r[0], r[1], ViewFrom[2] - halfHeadSize + epsBody,
    halfHeadSize * 2.0, halfHeadSize * 2.0, halfHeadSize * 2.0, Color.YELLOW, PlayerId, x, y, rot - Math.PI*0.75);
            
    head.Polys[2].DrawablePolygon.texture = GenerateTerrain.img;
            
            
    Cube neck = new Cube(- halfNeckSize + x, - halfNeckSize + y, ViewFrom[2] - headSize + halfNeckSize,
        halfNeckSize * 2.0, halfNeckSize * 2.0, halfNeckSize, Color.PINK, PlayerId, x, y, rot - Math.PI*0.75);
    Cube corpus = new Cube(- halfCorupsXSize + x, - halfCorupsYSize + y, ViewFrom[2] - corpusZSize - headSize + halfNeckSize - epsBody,
        halfCorupsXSize * 2.0, halfCorupsYSize * 2.0, 2 * halfCorpusZSize, Color.BLUE, PlayerId, x, y, rot - Math.PI*0.75);
            
    Cube legs = new Cube(- halfLegSizeX + x, - halfLegSizeY + y, ViewFrom[2] - legZSize - corpusZSize - headSize + halfNeckSize - epsBody - epsBody,
        2 * halfLegSizeX, 2 * halfLegSizeY, legZSize, Color.MAGENTA, PlayerId, x, y, rot - Math.PI*0.75);
            
    //xx = - halfHandsXSize + 0.5 + x;
    //yy = - halfHandsYSize + (halfHandsYSize / 2.0) + y;
            
    Cube hands = new Cube(- halfHandsXSize + x, - halfHandsYSize + y, ViewFrom[2] - handsZSize - headSize + halfNeckSize - epsBody,
        1, halfHandsYSize * 2.0, handsZSize, Color.CYAN, PlayerId, x, y, rot - Math.PI*0.75);
            
     ArrayList<DPolygon> all = new ArrayList<DPolygon>();
            
    AddArrayToArrayList(all, head.GetPolygons());
    AddArrayToArrayList(all, neck.GetPolygons());
    AddArrayToArrayList(all, corpus.GetPolygons());
    AddArrayToArrayList(all, hands.GetPolygons());
    AddArrayToArrayList(all, legs.GetPolygons());*/
    return all;
}

From source file:gbt.ubt.tool.Orthorectifier.java

public static BoundedPropagator generateEphemeris(InputParameters params) throws IOException, OrekitException {
    /*/*ww  w.j  av a  2 s  .  c o  m*/
     This function generates the satellite ephemeris for the duration of the acquisition using the orbital
     state vector that is embedded in the product header (MPH). This state vector is normally the restituted
     orbit from the Flight Operations Segment.
     The open source Orekit library (https://www.orekit.org/) is used to perform the numerical propagation.
     The generated ephemeris compares well against the available DORIS Precise Orbit files (maximum 10 metre
     displacement vector magnitude during propagation duration).
     */
    if (params.orthorectify) {
        System.out.println("Orthorectification is selected, performing orbit propagation");

        /* Get the acquisition duration and state vector from the L1b product */
        DataProvidersManager.getInstance().addProvider(new ZipJarCrawler(new File("orekit-data.zip")));
        Product readProduct = ProductIO.readProduct(params.inputFileLocation);
        Date startTime = readProduct.getStartTime().getAsDate();
        Date stopTime = readProduct.getEndTime().getAsDate();
        MetadataElement metadataRoot = readProduct.getMetadataRoot();
        Date vectorTime = metadataRoot.getElementAt(0).getAttributeUTC("STATE_VECTOR_TIME").getAsDate();
        Double xPos = metadataRoot.getElementAt(0).getAttributeDouble("X_POSITION");
        Double yPos = metadataRoot.getElementAt(0).getAttributeDouble("Y_POSITION");
        Double zPos = metadataRoot.getElementAt(0).getAttributeDouble("Z_POSITION");
        Double xVel = metadataRoot.getElementAt(0).getAttributeDouble("X_VELOCITY");
        Double yVel = metadataRoot.getElementAt(0).getAttributeDouble("Y_VELOCITY");
        Double zVel = metadataRoot.getElementAt(0).getAttributeDouble("Z_VELOCITY");

        /* Product state vector in fixed frame and UTC
         Note state vector and product/acquisition start time are not coincident
         */
        Frame fixedFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, false);
        TimeScale utc = TimeScalesFactory.getUTC();
        GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
        cal.setTime(vectorTime);
        AbsoluteDate initialDate = new AbsoluteDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1,
                cal.get(Calendar.DATE), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE),
                cal.get(Calendar.SECOND), utc);
        Vector3D position = new Vector3D(xPos, yPos, zPos);
        Vector3D velocity = new Vector3D(xVel, yVel, zVel);

        /* Orekit can only propate orbits defined in inertial reference frame
         Convert state vector to J2000 (EME2000) frame.
         */
        Frame inertialFrame = FramesFactory.getEME2000();
        Transform frameTransform = fixedFrame.getTransformTo(inertialFrame, initialDate);
        PVCoordinates transformPVCoordinates = frameTransform
                .transformPVCoordinates(new PVCoordinates(position, velocity));

        /* Set initial spacecraft state */
        double mu = 3.986004415e+14; // Central attraction coefficient
        Orbit initialOrbit = new CartesianOrbit(transformPVCoordinates, inertialFrame, initialDate, mu);
        SpacecraftState initialState = new SpacecraftState(initialOrbit, 7892.0); // Orbital parameters and Envisat dry mass

        /* Set up numerical integrator for propagation */
        double minStep = 1;
        double maxStep = 1000;
        double initialStep = 60;
        OrbitType propagationType = OrbitType.CARTESIAN;
        double[][] tolerance = NumericalPropagator.tolerances(0.001, initialOrbit, propagationType);
        AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxStep, tolerance[0],
                tolerance[1]);
        integrator.setInitialStepSize(initialStep);
        NumericalPropagator propagator = new NumericalPropagator(integrator);
        propagator.setOrbitType(propagationType);

        /* Add force models to the propagator:
         Consider central body (Earth) gravity pertubation
         Consider third body (Sun & Moon) gravity pertubation
         Other pertubations are not considered (computation speed/accuracy trade-off)
         */
        NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(21, 21);
        ForceModel holmesFeatherstone = new HolmesFeatherstoneAttractionModel(
                FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider);
        propagator.addForceModel(holmesFeatherstone);
        propagator.addForceModel(new ThirdBodyAttraction(CelestialBodyFactory.getSun()));
        propagator.addForceModel(new ThirdBodyAttraction(CelestialBodyFactory.getMoon()));

        /* Run  the propagator to generate the ephemeris */
        propagator.setInitialState(initialState);
        propagator.setEphemerisMode();
        cal.setTime(startTime);
        AbsoluteDate startDate = new AbsoluteDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1,
                cal.get(Calendar.DATE), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE),
                cal.get(Calendar.SECOND), utc);
        cal.setTime(stopTime);
        AbsoluteDate stopDate = new AbsoluteDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1,
                cal.get(Calendar.DATE), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE),
                cal.get(Calendar.SECOND), utc);
        SpacecraftState finalState = propagator.propagate(startDate.shiftedBy(-600.0),
                stopDate.shiftedBy(600.0));
        BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();

        return ephemeris;
    } else {
        return null;
    }
}

From source file:fingerprint.MyStructureFingerprint.java

private LinkedHashMap<PhiThetaInterval, List<PointIfc>> groupResiduesAccordingToSolidAngleAccordingToLocalStructureBarycenter(
        PointIfc barycenterShape, MyStructureIfc myStructureHere) { // strongly reusing code of groupPoints

    List<PointIfc> listRepresentativePoints = new ArrayList<>();

    for (MyChainIfc chain : myStructureHere.getAllChainsRelevantForShapeBuilding()) {
        for (MyMonomerIfc monomer : chain.getMyMonomers()) {
            float[] coords = ToolsMathAppliedToMyStructure.getCoordinatesOfRepresentativeAtom(monomer);
            PointIfc point = new Point(coords);
            listRepresentativePoints.add(point);
        }//from  ww  w  .  ja  v  a  2 s  .c  o  m
    }

    // defining 36 zones in solid space
    double deltaOnlyForTheta = Math.PI / 8.0;
    int countOfIncrementAngle = 8;
    // group monomers

    EquidistributionPhi equidistributionPhi = new EquidistributionPhi();
    List<Double> phiValues = equidistributionPhi.getMapCountOfIntervalsAndPointValues()
            .get(countOfIncrementAngle);
    // theta in map ranges from -pi to +pi in agreement with apache spherical coodinates
    List<Double> tethaValues = ShapeReductorTools.doBinningThetaValues(deltaOnlyForTheta,
            countOfIncrementAngle);

    List<PhiThetaInterval> sectors = generateSector(deltaOnlyForTheta, phiValues, tethaValues);

    // create the Map to return
    LinkedHashMap<PhiThetaInterval, List<PointIfc>> groupPoints = new LinkedHashMap<>();

    Iterator<PhiThetaInterval> it = sectors.iterator();
    while (it.hasNext()) {
        PhiThetaInterval sector = it.next();
        List<PointIfc> listPoints = new ArrayList<>();
        groupPoints.put(sector, listPoints);
    }

    for (PointIfc point : listRepresentativePoints) {

        float[] pointRelativeToBarycenter = MathTools.v1minusV2(point.getCoords(), barycenterShape.getCoords());
        Vector3D pointRelativeToBarycenterV3d = new Vector3D(pointRelativeToBarycenter[0],
                pointRelativeToBarycenter[1], pointRelativeToBarycenter[2]);

        SphericalCoordinates pointShericalRelative = new SphericalCoordinates(pointRelativeToBarycenterV3d);

        PhiThetaInterval intervalForThisPoint = getIntervalFromSphericalCoordinates(pointShericalRelative,
                sectors);

        if (intervalForThisPoint == null) { // it could be that some points doesnt fit so I should make the binning a bit larger I guess
            continue;
        }
        groupPoints.get(intervalForThisPoint).add(point);
    }

    return groupPoints;
}

From source file:gin.melec.Cube.java

/**
 * Give the next plane, by checking first if the segment created by the two
 * vertices cross the current plane.//  w ww  . ja  v a  2s .co m
 * @param v1, the first vertex.
 * @param v2, the second vertex.
 * @param plane, the plane that might be intersected.
 * @param currentSplit, the current split used.
 * @return the next split of the border.
 */
private AbstractSplit getNextSplit(final Vertex v1, final Vertex v2, CustomPlane plane,
        AbstractSplit currentSplit) {
    Vector3D vect1 = new Vector3D(v1.getX(), v1.getY(), v1.getZ());
    Vector3D vect2 = new Vector3D(v2.getX(), v2.getY(), v2.getZ());
    Line line = new Line(vect1, vect2, 0.001);

    Vector3D intersection = plane.intersection(line);
    AbstractSplit result = null;
    if (intersection != null && vect1.distance(vect2) > vect1.distance(intersection)) {
        if (plane.getSplit1() == currentSplit) {
            result = plane.getSplit2();
        } else if (plane.getSplit2() == currentSplit) {
            result = plane.getSplit1();
        }
    }
    return result;
}

From source file:gin.melec.Cube.java

/**
 * Set the planes of the cube./*from  ww w.  ja  v  a 2 s . c o  m*/
 */
private void setPlanes() {
    Vector3D orig = new Vector3D(xMin, yMin, zMin);
    Vector3D origX = new Vector3D(xMax, yMin, zMin);
    Vector3D origY = new Vector3D(xMin, yMax, zMin);
    Vector3D origZ = new Vector3D(xMin, yMin, zMax);
    Vector3D xZ = new Vector3D(xMax, yMin, zMax);
    Vector3D xY = new Vector3D(xMax, yMax, zMin);
    Vector3D yZ = new Vector3D(xMin, yMax, zMax);
    Vector3D xYZ = new Vector3D(xMax, yMax, zMax);

    Vector3D constructedVector;

    constructedVector = new Vector3D((origY.getX() - 100), (origY.getY() + 100), origY.getZ());
    frontLeftPlane = new CustomPlane(frontSplit, leftSplit, origY, yZ, constructedVector, 0.001);

    constructedVector = new Vector3D((xY.getX() - 100), (xY.getY() - 100), xY.getZ());
    frontRightPlane = new CustomPlane(frontSplit, rightSplit, xY, xYZ, constructedVector, 0.001);

    constructedVector = new Vector3D(origY.getX(), (origY.getY() - 100), (origY.getZ() + 100));
    frontUpPlane = new CustomPlane(frontSplit, upSplit, origY, xY, constructedVector, 0.001);

    constructedVector = new Vector3D(yZ.getX(), (yZ.getY() - 100), (yZ.getZ() - 100));
    frontDownPlane = new CustomPlane(frontSplit, downSplit, yZ, xYZ, constructedVector, 0.001);

    constructedVector = new Vector3D((orig.getX() + 100), (orig.getY() + 100), orig.getZ());
    backLeftPlane = new CustomPlane(backSplit, leftSplit, orig, origZ, constructedVector, 0.001);

    constructedVector = new Vector3D((origX.getX() - 100), (origX.getY() + 100), origX.getZ());
    backRightPlane = new CustomPlane(backSplit, rightSplit, origX, xZ, constructedVector, 0.001);

    constructedVector = new Vector3D(orig.getX(), (orig.getY() + 100), (orig.getZ() + 100));
    backUpPlane = new CustomPlane(backSplit, upSplit, orig, origX, constructedVector, 0.001);

    constructedVector = new Vector3D(origZ.getX(), (origZ.getY() + 100), (origZ.getZ() - 100));
    backDownPlane = new CustomPlane(backSplit, downSplit, origZ, xZ, constructedVector, 0.001);

    constructedVector = new Vector3D((orig.getX() + 100), orig.getY(), (orig.getZ() + 100));
    leftUpPlane = new CustomPlane(leftSplit, upSplit, orig, origY, constructedVector, 0.001);

    constructedVector = new Vector3D((origZ.getX() + 100), origZ.getY(), (origZ.getZ() - 100));
    leftDownPlane = new CustomPlane(leftSplit, downSplit, origZ, yZ, constructedVector, 0.001);

    constructedVector = new Vector3D((origX.getX() - 100), origX.getY(), (origX.getZ() + 100));
    rightUpPlane = new CustomPlane(rightSplit, upSplit, origX, xY, constructedVector, 0.001);

    constructedVector = new Vector3D((xZ.getX() - 100), xZ.getY(), (xZ.getZ() - 100));
    rightDownPlane = new CustomPlane(rightSplit, downSplit, xZ, xYZ, constructedVector, 0.001);
}