private double getDPadValue(Event event) { double dPadValue = event.getValue(); double value = 0.0; if (MathTools.epsilonEquals(dPadValue, 0.25, 1e-3)) { value = 1.0; } if (MathTools.epsilonEquals(dPadValue, 0.75, 1e-3)) { value = -1.0; } return value; }
public static double computeAlphaGivenBreakFrequency(double breakFrequencyInHetrz, double dt) { double alpha = 1.0 - 4.0 * dt * breakFrequencyInHetrz; alpha = MathTools.clamp(alpha, 0.0, 1.0); return alpha; }
@Override public String toString() { return getClass().getSimpleName() + ": H: " + MathTools.roundToSignificantFigures(values[0], 4) + " S: " + MathTools.roundToSignificantFigures(values[1], 4) + " V: " + MathTools.roundToSignificantFigures(values[2], 4); }
private static double getCosineAngleWithCosineLaw(double l_neighbour1, double l_neighbour2, double l_opposite) { checkIntervalContains(l_neighbour1, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_neighbour2, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_opposite, 0.0, Double.POSITIVE_INFINITY); double cosAngle = MathTools.clamp((square(l_neighbour1) + square(l_neighbour2) - square(l_opposite)) / (2.0 * l_neighbour1 * l_neighbour2), -1.0, 1.0); return cosAngle; }
public static double getCosineAngleDotWithCosineLaw(double l_neighbour1, double l_neighbour2, double lDot_neighbour2, double l_opposite, double lDot_opposite) { checkIntervalContains(l_neighbour1, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_neighbour2, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_opposite, 0.0, Double.POSITIVE_INFINITY); double cosAngleDot = (square(l_neighbour2) * lDot_neighbour2 - 2.0 * l_neighbour2 * l_opposite * lDot_opposite - lDot_neighbour2 * square(l_neighbour1) + lDot_neighbour2 * square(l_opposite)) / (2.0 * square(l_neighbour2) * l_neighbour1); return cosAngleDot; }
public static double getCosineAngleDDotWithCosineLaw(double l_neighbour1, double l_neighbour2, double lDot_neighbour2, double lDDot_neighbour2, double l_opposite, double lDot_opposite, double lDDot_opposite) { checkIntervalContains(l_neighbour1, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_neighbour2, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_opposite, 0.0, Double.POSITIVE_INFINITY); double cosAngleDDot = (cube(l_neighbour2) * lDDot_neighbour2 - 2 * square(l_neighbour2 * lDot_opposite) - 2 * square(l_neighbour2) * l_opposite * lDDot_opposite + 4 * l_neighbour2 * lDot_neighbour2 * l_opposite * lDot_opposite + 2 * square(lDot_neighbour2 * l_neighbour1) - 2 * square( lDot_neighbour2 * l_opposite) - l_neighbour2 * lDDot_neighbour2 * square(l_neighbour1) + l_neighbour2 * lDDot_neighbour2 * square(l_opposite)) / (2.0 * cube(l_neighbour2) * l_neighbour1); return cosAngleDDot; }
private Color getHeatColor(int heat) { double maxHeat = 30.0; int heatIndex = (int) MathTools.roundToPrecision(MathTools.clamp((heat / maxHeat) * 500.0, 0.0, 499.0), 1.0); return ColorConversions.awtToJfx(rainbow[heatIndex]); }
private void computeOther(double value) { k++; sum = sum + value; double mKLast = mK; double kDouble = (double)k; mK = mKLast + (value - mKLast) / kDouble; qK = qK + (kDouble - 1.0) * MathTools.square(value - mKLast) / kDouble; }
public void enableWeightMethod(double maxWeight, double minWeight) { MathTools.checkIntervalContains(minWeight, 1.0-3, 100.0); MathTools.checkIntervalContains(maxWeight, 1.0-3, 100.0); this.useWeightMethod = true; double weightRatio = maxWeight / minWeight; this.minWeight = 1.0; this.maxWeight = weightRatio; }
public static double getCosineAngleWithCosineLaw(double l_neighbour1, double l_neighbour2, double l_opposite) { checkIntervalContains(l_neighbour1, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_neighbour2, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_opposite, 0.0, Double.POSITIVE_INFINITY); double cosAngle = MathTools .clamp((square(l_neighbour1) + square(l_neighbour2) - square(l_opposite)) / (2.0 * l_neighbour1 * l_neighbour2), -1.0, 1.0); return cosAngle; }
public void printResultsForTest() { System.out.println(timeMatrix); System.out.println(time.get(0) + " : " + time.get(1) + " : " + time.get(2)); System.out.println(parametersX.get(1)[0] + " : " + parametersX.get(1)[1] + " : " + parametersX.get(1)[2]); System.out.println(parametersY.get(1)[0] + " : " + parametersY.get(1)[1] + " : " + parametersY.get(1)[2]); System.out.println(parametersZ.get(1)[0] + " : " + parametersZ.get(1)[1] + " : " + parametersZ.get(1)[2]); System.out.println(parametersX.get(1)[0] * MathTools.square(time.get(0)) + parametersX.get(1)[1] * time.get(0) + parametersX.get(1)[2]); System.out.println(parametersX.get(1)[0] * MathTools.square(time.get(1)) + parametersX.get(1)[1] * time.get(1) + parametersX.get(1)[2]); System.out.println(parametersX.get(1)[0] * MathTools.square(time.get(2)) + parametersX.get(1)[1] * time.get(2) + parametersX.get(1)[2]); System.out.println(2 * parametersX.get(1)[0] * time.get(0) + parametersX.get(1)[1]); System.out.println(2 * parametersX.get(1)[0] * time.get(1) + parametersX.get(1)[1]); System.out.println(2 * parametersX.get(1)[0] * time.get(2) + parametersX.get(1)[1]); System.out.println("final check"); System.out.println(xDot); }
public static double getAngleDDotWithCosineLaw(double l_neighbour1, double l_neighbour2, double lDot_neighbour2, double lDDot_neighbour2, double l_opposite, double lDot_opposite, double lDDot_opposite) { checkIntervalContains(l_neighbour1, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_neighbour2, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_opposite, 0.0, Double.POSITIVE_INFINITY); double cosAngle = getCosineAngleWithCosineLaw(l_neighbour1, l_neighbour2, l_opposite); double cosAngleDot = getCosineAngleDotWithCosineLaw(l_neighbour1, l_neighbour2, lDot_neighbour2, l_opposite, lDot_opposite); double cosAngleDDot = getCosineAngleDDotWithCosineLaw(l_neighbour1, l_neighbour2, lDot_neighbour2, lDDot_neighbour2, l_opposite, lDot_opposite, lDDot_opposite); double angleDDot = (-cosAngleDDot + cosAngleDDot * square(cosAngle) - cosAngleDot * cosAngleDot * cosAngle) / pow(1 - square(cosAngle), 3.0 / 2.0); return angleDDot; }
public static double getAngleDotWithCosineLaw(double l_neighbour1, double l_neighbour2, double lDot_neighbour2, double l_opposite, double lDot_opposite) { checkIntervalContains(l_neighbour1, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_neighbour2, 0.0, Double.POSITIVE_INFINITY); checkIntervalContains(l_opposite, 0.0, Double.POSITIVE_INFINITY); double cosAngle = getCosineAngleWithCosineLaw(l_neighbour1, l_neighbour2, l_opposite); double cosAngleDot = getCosineAngleDotWithCosineLaw(l_neighbour1, l_neighbour2, lDot_neighbour2, l_opposite, lDot_opposite); double angleDot = -cosAngleDot / sqrt(1 - cosAngle * cosAngle); return angleDot; }
@Override public boolean currentlyMeetsGoal() { return MathTools.epsilonEquals(yoDouble.getDoubleValue(), goalValue, epsilon); }
public static double computeAlphaGivenBreakFrequencyProperly(double breakFrequencyInHertz, double dt) { if (Double.isInfinite(breakFrequencyInHertz)) return 0.0; double omega = 2.0 * Math.PI * breakFrequencyInHertz; double alpha = (1.0 - omega * dt / 2.0) / (1.0 + omega * dt / 2.0); alpha = MathTools.clamp(alpha, 0.0, 1.0); return alpha; }
private static int calculateTimeoutInMilliseconds(double testDuration) { double potentialTimeout = (testDuration * 5.0); double timeoutInSeconds = (potentialTimeout > 30.0) ? MathTools.roundToSignificantFigures(potentialTimeout, 2) : 30.0; return Conversions.secondsToMilliseconds(timeoutInSeconds); } }
public static void getAcceleration(FrameVector3D accelerationToPack, ReferenceFrame frame, double angle, double angleDot, double angleDDot, double radius, double radiusDot, double radiusDDot, double zDDot) { double cos = Math.cos(angle); double sin = Math.sin(angle); accelerationToPack.setToZero(frame); double xDDot = -cos * radius * MathTools.square(angleDot) - 2.0 * sin * angleDot * radiusDot - radius * sin * angleDDot + cos * radiusDDot; double yDDot = -sin * radius * MathTools.square(angleDot) + 2.0 * cos * angleDot * radiusDot + radius * cos * angleDDot + sin * radiusDDot; accelerationToPack.setX(xDDot); accelerationToPack.setY(yDDot); accelerationToPack.setZ(zDDot); }
public void getPosition(FramePoint3D positionToPack, double parameter) { double q = parameter; MathTools.checkIntervalContains(q, 0.0, 1.0); positionToPack.setToZero(referenceFrame); // c2 * q^2 positionToPack.set(c2); positionToPack.scale(MathTools.square(q)); // c1 * q tempPackPosition.set(c1); tempPackPosition.scale(q); positionToPack.add(tempPackPosition); // c0 positionToPack.add(c0); }
public void setTrajectoryTime(double duration) { MathTools.checkIntervalContains(duration, 0.0, Double.POSITIVE_INFINITY); trajectoryTime.set(duration); }
@Override public boolean epsilonEquals(NormalOcTreeMessage other, double epsilon) { if (treeDepth != other.treeDepth) return false; if (!MathTools.epsilonEquals(resolution, other.resolution, epsilon)) return false; if (!root.epsilonEquals(other.root, epsilon)) return false; return true; } }