Example usage for org.apache.commons.math.geometry Vector3D crossProduct

List of usage examples for org.apache.commons.math.geometry Vector3D crossProduct

Introduction

In this page you can find the example usage for org.apache.commons.math.geometry Vector3D crossProduct.

Prototype

public static Vector3D crossProduct(Vector3D v1, Vector3D v2) 

Source Link

Document

Compute the cross-product of two vectors.

Usage

From source file:orchestration.path.RectShape.java

private static boolean testIntersection(Vector3D p, Vector3D r, Vector3D q, Vector3D s) {
    double bottomFactor = Vector3D.crossProduct(r, s).getNorm();
    if (bottomFactor == 0)
        return false; // parallel
    else {//from w ww. j  av a  2 s .c o m
        double t = Vector3D.crossProduct((q.subtract(p)), s).getNorm() / bottomFactor;
        double u = Vector3D.crossProduct((q.subtract(p)), r).getNorm() / bottomFactor;
        if (0 <= t && t <= 1 && 0 <= u && u <= 1)
            return true;
        else
            return false;
    }
}

From source file:playground.vsp.analysis.modules.ptTripAnalysis.utils.GeoCalculator.java

@Deprecated
public static double averageStraightDistance(Tuple<Coord, Coord> straightOne, Tuple<Coord, Coord> straightTwo) {
    double dAC, dCE, dBF, dBD;
    //get dist between start/start and end/end
    dAC = distanceBetween2Points(straightOne.getFirst(), straightTwo.getFirst());
    dBD = distanceBetween2Points(straightOne.getSecond(), straightTwo.getSecond());

    // get shortest dist from the start of the first straight to the second straight
    Vector3D pointA, pointB, pointC, pointD, cd, ab, temp;

    pointA = Coord2Vector3D(straightOne.getFirst());
    pointB = Coord2Vector3D(straightOne.getSecond());
    pointC = Coord2Vector3D(straightTwo.getFirst());
    pointD = Coord2Vector3D(straightTwo.getSecond());

    ab = new Vector3D(1, pointB, -1, pointA);
    cd = new Vector3D(1, pointD, -1, pointC);

    // get dCE//from   w  w  w.  j a v a 2s .  c  o  m
    temp = new Vector3D(1, pointC, -1, pointA);
    temp = Vector3D.crossProduct(temp, ab);
    dCE = temp.getNorm() / ab.getNorm();

    // get dBF
    temp = new Vector3D(1, pointB, -1, pointC);
    temp = Vector3D.crossProduct(temp, cd);
    dBF = temp.getNorm() / cd.getNorm();
    return (0.5 * (Math.min(dAC, dCE) + Math.min(dBF, dBD)));
}