Bug 18: Separated ShapeRenderer II

This commit is contained in:
Robert Vokac 2024-10-12 16:25:34 +02:00
parent 0201173b5a
commit 473a54d912
Signed by: robertvokac
GPG Key ID: FB9CE8E20AADA55F

View File

@ -25,6 +25,8 @@ import static com.pixelgamelibrary.api.math.AngleUnit.NORMALIZED;
import static com.pixelgamelibrary.api.math.AngleUnit.RADIAN; import static com.pixelgamelibrary.api.math.AngleUnit.RADIAN;
/** /**
* Utility class for converting between different angle units.
* Provides methods to convert degrees, radians, gradians, and normalized values.
* *
* @author robertvokac * @author robertvokac
*/ */
@ -65,9 +67,18 @@ class AngleUnitConverter {
return normalized * _360_DEGREES; return normalized * _360_DEGREES;
} }
/**
* Converts the given value from one angle unit to another.
*
* @param value the value to convert
* @param inputAngleUnit the unit of the input value
* @param outputAngleUnit the unit of the output value
* @return the converted value in the target angle unit
* @throws PixelException if the conversion is not supported
*/
public static float convert(float value, AngleUnit inputAngleUnit, AngleUnit outputAngleUnit) { public static float convert(float value, AngleUnit inputAngleUnit, AngleUnit outputAngleUnit) {
if (inputAngleUnit == outputAngleUnit) { if (inputAngleUnit == outputAngleUnit) {
//nothing to do // No conversion needed
return value; return value;
} }
if (inputAngleUnit == AngleUnit.DEGREE) { if (inputAngleUnit == AngleUnit.DEGREE) {
@ -95,8 +106,8 @@ class AngleUnitConverter {
throw new PixelException("Unsupported operation."); throw new PixelException("Unsupported operation.");
} }
} }
// Convert to degrees as an intermediate step
float degrees = convert(value, inputAngleUnit, AngleUnit.DEGREE); float degrees = convert(value, inputAngleUnit, AngleUnit.DEGREE);
return convert(degrees, AngleUnit.DEGREE, outputAngleUnit); return convert(degrees, AngleUnit.DEGREE, outputAngleUnit);
} }
} }