Java Code Examples for org.apache.commons.lang3.mutable.MutableDouble#doubleValue()

The following examples show how to use org.apache.commons.lang3.mutable.MutableDouble#doubleValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RectangleAndArcCollider.java    From notreal2d with MIT License 5 votes vote down vote up
private void updateNearestPoint(
        @Nonnull Body body, @Nonnull Point2D point, @Nonnull Mutable<Point2D> nearestPoint,
        @Nonnull MutableDouble distanceToNearestPoint) {
    double distanceToPoint = body.getDistanceTo(point);

    if (distanceToPoint >= epsilon
            && (nearestPoint.get() == null || distanceToPoint < distanceToNearestPoint.doubleValue())) {
        nearestPoint.set(point);
        distanceToNearestPoint.setValue(distanceToPoint);
    }
}
 
Example 2
Source File: RectangleAndArcCollider.java    From notreal2d with MIT License 5 votes vote down vote up
private static void updateFarthestPoint(
        @Nonnull Body body, @Nonnull Point2D point, @Nonnull Mutable<Point2D> farthestPoint,
        @Nonnull MutableDouble distanceToFarthestPoint, double startAngle, double finishAngle) {
    double distanceToPoint = body.getDistanceTo(point);

    if (GeometryUtil.isAngleBetween(new Vector2D(body.getPosition(), point).getAngle(), startAngle, finishAngle)
            && (farthestPoint.get() == null || distanceToPoint > distanceToFarthestPoint.doubleValue())) {
        farthestPoint.set(point);
        distanceToFarthestPoint.setValue(distanceToPoint);
    }
}
 
Example 3
Source File: SumDouble.java    From attic-apex-malhar with Apache License 2.0 4 votes vote down vote up
@Override
public Double getOutput(MutableDouble accumulatedValue)
{
  return accumulatedValue.doubleValue();
}
 
Example 4
Source File: Position.java    From ij-ridgedetection with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute line points.
 *
 * @param ku
 *            the ku
 * @param ismax
 *            the ismax
 * @param ev
 *            the ev
 * @param nx
 *            the nx
 * @param ny
 *            the ny
 * @param px
 *            the px
 * @param py
 *            the py
 * @param width
 *            the width
 * @param height
 *            the height
 * @param low
 *            the low
 * @param high
 *            the high
 * @param mode
 *            the mode
 */
/*
 * For each point in the image determine whether there is a local maximum of the
 * second directional derivative in the direction (nx[l],ny[l]) within the
 * pixels's boundaries. If so, set ismax[l] to 2 if the eigenvalue ev[l] is
 * larger than high, to 1 if ev[l] is larger than low, and to 0 otherwise.
 * Furthermore, put the sub-pixel position of the maximum into (px[l],py[l]).
 * The parameter mode determines whether maxima (dark lines points) or minima
 * (bright line points) should be selected. The partial derivatives of the image
 * are input as ku[].
 */
private void compute_line_points(float[][] ku, byte[] ismax, float[] ev, float[] nx, float[] ny, float[] px,
		float[] py, int width, int height, double low, double high, int mode) {
	int r, c, l;
	double[] k = new double[5];
	double[] eigval = new double[2];
	double[][] eigvec = new double[2][2];
	double a, b;
	MutableDouble t = new MutableDouble();
	MutableInt num = new MutableInt();
	double n1, n2;
	double p1, p2;
	double val;

	for (r = 0; r < height; r++) {
		for (c = 0; c < width; c++) {
			l = LinesUtil.LINCOOR(r, c, width);

			k[0] = ku[0][l];
			k[1] = ku[1][l];
			k[2] = ku[2][l];
			k[3] = ku[3][l];
			k[4] = ku[4][l];
			ev[l] = (float) 0.0;
			nx[l] = (float) 0.0;
			ny[l] = (float) 0.0;
			compute_eigenvals(k[2], k[3], k[4], eigval, eigvec);
			if (mode == LinesUtil.MODE_LIGHT)
				val = -eigval[0];
			else
				val = eigval[0];
			if (val > 0.0) {
				ev[l] = (float) val;
				n1 = eigvec[0][0];
				n2 = eigvec[0][1];
				a = k[2] * n1 * n1 + 2.0 * k[3] * n1 * n2 + k[4] * n2 * n2;
				b = k[0] * n1 + k[1] * n2;
				solve_linear(a, b, t, num);
				if (num.intValue() != 0) {
					p1 = t.doubleValue() * n1;
					p2 = t.doubleValue() * n2;
					if (Math.abs(p1) <= PIXEL_BOUNDARY && Math.abs(p2) <= PIXEL_BOUNDARY) {
						if (val >= low) {
							if (val >= high)
								ismax[l] = 2;
							else
								ismax[l] = 1;
						}
						nx[l] = (float) n1;
						ny[l] = (float) n2;
						px[l] = (float) (r + p1);
						py[l] = (float) (c + p2);
					}
				}
			}
		}
	}
}