Search in sources :

Example 11 with DD

use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.

the class TriPredicate method triAreaDD2.

public static DD triAreaDD2(final Point a, final Point b, final Point c) {
    final DD t1 = DD.valueOf(b.getX()).selfSubtract(a.getX()).selfMultiply(DD.valueOf(c.getY()).selfSubtract(a.getY()));
    final DD t2 = DD.valueOf(b.getY()).selfSubtract(a.getY()).selfMultiply(DD.valueOf(c.getX()).selfSubtract(a.getX()));
    return t1.selfSubtract(t2);
}
Also used : DD(com.revolsys.geometry.math.DD)

Example 12 with DD

use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.

the class CGAlgorithmsDD method orientationIndex.

public static int orientationIndex(final double x1, final double y1, final double x2, final double y2, final double x, final double y) {
    // fast filter for orientation index
    // avoids use of slow extended-precision arithmetic in many cases
    final int index = orientationIndexFilter(x1, y1, x2, y2, x, y);
    if (index <= 1) {
        return index;
    }
    // normalize coordinates
    final DD dx1 = DD.valueOf(x2).selfAdd(-x1);
    final DD dy1 = DD.valueOf(y2).selfAdd(-y1);
    final DD dx2 = DD.valueOf(x).selfAdd(-x2);
    final DD dy2 = DD.valueOf(y).selfAdd(-y2);
    // sign of determinant - unrolled for performance
    return dx1.selfMultiply(dy2).selfSubtract(dy1.selfMultiply(dx2)).signum();
}
Also used : DD(com.revolsys.geometry.math.DD) Point(com.revolsys.geometry.model.Point)

Example 13 with DD

use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.

the class DDExpressionPerf method runDoubleDouble.

public double runDoubleDouble(final int nIter) {
    final Stopwatch sw = new Stopwatch();
    for (int i = 0; i < nIter; i++) {
        final DD a = new DD(9.0);
        final DD factor = new DD(10.0);
        final DD aMul = factor.multiply(a);
        final DD aDiv = a.divide(factor);
        final DD det = a.multiply(a).subtract(aMul.multiply(aDiv));
    // System.out.println(aDiv);
    // System.out.println(det);
    }
    sw.stop();
    // + sw.getTimeString());
    return sw.getTime() / (double) nIter;
}
Also used : DD(com.revolsys.geometry.math.DD) Stopwatch(com.revolsys.geometry.util.Stopwatch)

Example 14 with DD

use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.

the class DDExpressionPerf method runDoubleDoubleSelf.

// *
public double runDoubleDoubleSelf(final int nIter) {
    final Stopwatch sw = new Stopwatch();
    for (int i = 0; i < nIter; i++) {
        final double a = 9.0;
        final double factor = 10.0;
        final DD c = new DD(9.0);
        c.selfMultiply(factor);
        final DD b = new DD(9.0);
        b.selfDivide(factor);
        final DD a2 = new DD(a);
        a2.selfMultiply(a);
        final DD b2 = new DD(b);
        b2.selfMultiply(c);
        a2.selfDivide(b2);
        final DD det = a2;
    // System.out.println(aDiv);
    // System.out.println(det);
    }
    sw.stop();
    // + sw.getTimeString());
    return sw.getTime() / (double) nIter;
}
Also used : DD(com.revolsys.geometry.math.DD) Stopwatch(com.revolsys.geometry.util.Stopwatch)

Example 15 with DD

use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.

the class TriPredicate method isInCircleDD2.

public static boolean isInCircleDD2(final Point a, final Point b, final Point c, final Point p) {
    final DD aTerm = DD.sqr(a.getX()).selfAdd(DD.sqr(a.getY())).selfMultiply(triAreaDD2(b, c, p));
    final DD bTerm = DD.sqr(b.getX()).selfAdd(DD.sqr(b.getY())).selfMultiply(triAreaDD2(a, c, p));
    final DD cTerm = DD.sqr(c.getX()).selfAdd(DD.sqr(c.getY())).selfMultiply(triAreaDD2(a, b, p));
    final DD pTerm = DD.sqr(p.getX()).selfAdd(DD.sqr(p.getY())).selfMultiply(triAreaDD2(a, b, c));
    final DD sum = aTerm.selfSubtract(bTerm).selfAdd(cTerm).selfSubtract(pTerm);
    final boolean isInCircle = sum.doubleValue() > 0;
    return isInCircle;
}
Also used : DD(com.revolsys.geometry.math.DD)

Aggregations

DD (com.revolsys.geometry.math.DD)34 Stopwatch (com.revolsys.geometry.util.Stopwatch)3 Point (com.revolsys.geometry.model.Point)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1