Commit daf025d2 authored by NicolaiO's avatar NicolaiO 🐼 Committed by TIGERs GitLab
Browse files

Resolve "Rework NumDefendersCalc"

Closes #1727 and #1718

See merge request main/Sumatra!1495

sumatra-commit: cf6667f0d167a1049c51ea910562d4248c941b82
parent 0dd29310
Pipeline #17544 passed with stage
in 4 minutes and 48 seconds
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.math;
......@@ -191,7 +191,7 @@ public final class SumatraMath
/**
* Cap value if outside of the range, else return value.
* Cap value if outside the range, else return value.
*
* @param value the value
* @param bound1 the first bound value
......@@ -206,6 +206,22 @@ public final class SumatraMath
}
/**
* Cap value if outside the range, else return value.
*
* @param value the value
* @param bound1 the first bound value
* @param bound2 the second bound value
* @return value in range [bound1..bound2] or [bound2..bound1]
*/
public static int cap(final int value, final int bound1, final int bound2)
{
int min = Math.min(bound1, bound2);
int max = Math.max(bound1, bound2);
return Math.max(min, Math.min(max, value));
}
/**
* Solves for the real roots of a quadratic equation with real
* coefficients. The quadratic equation is of the form
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment