Class AngleRange
Class AngleRange
- java.lang.Object
-
- com.here.sdk.core.AngleRange
-
public final class AngleRange extends java.lang.ObjectRepresents angle ranges as a circular sector by using an absolute start angle and a relative range angle called extent. They both define a sector on a circle. All angles are in degrees and are clockwise-oriented. By default, the AngleRange represents the entire circle, the value is in the range of [0, 360]. Values will be corrected during construction using normalization for the start angle and clamping for the extent angle, ensuring a valid range for all possible inputs.
-
-
Constructor Summary
Constructors Constructor Description AngleRange()Constructs a range covering a full circle.AngleRange(double start, double extent)Constructs an AngleRange from the provided start and extent angles.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleclosestInRange(double angleClockwiseInDegreesFromNorth)Get the angle that is closest to the given one and in range.booleanequals(java.lang.Object obj)static AngleRangefromDirectionDegreesClockwise(double center, double extent)Constructs an AngleRange from the provided center angle defining the direction and an angular width to extent the range by 50% clockwise and 50% counter-clockwise from its center angle.static AngleRangefromMinMaxDegreesClockwise(double min, double max)Constructs an AngleRange from the provided minimum and maximum angles.inthashCode()booleaninRange(double angleClockwiseInDegreesFromNorth)Check if a given angle in degrees, clockwise from north is in range or not.doublemax()Get the maximum angle defined by the range in degrees, clockwise from north, normalized to [0,360).
-
-
-
Constructor Detail
-
AngleRange
public AngleRange(double start, double extent)Constructs an AngleRange from the provided start and extent angles. Corrects values if they exceed the ranges.
- Parameters:
start-Start angle, running clockwise, in degrees from north. The value will be normalized to [0.0, 360.0).
extent-The range's extent, running clockwise, in degrees from start. The value will be clamped to the range of [0, 360] degrees.
-
AngleRange
public AngleRange()
Constructs a range covering a full circle.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
fromMinMaxDegreesClockwise
@NonNull public static AngleRange fromMinMaxDegreesClockwise(double min, double max)
Constructs an AngleRange from the provided minimum and maximum angles. Corrects values if they exceed the ranges. The angles are always interpreted in clockwise orientation.
- Parameters:
min-Angle where to start the circular sector, running clockwise, in degrees from north. The value will be normalized to [0.0, 360.0).
max-Angle where the circular sector ends, running clockwise, in degrees from north. The value will be normalized to [0.0, 360.0).
- Returns:
Created AngleRange from the provided minimum and maximum angles.
-
fromDirectionDegreesClockwise
@NonNull public static AngleRange fromDirectionDegreesClockwise(double center, double extent)
Constructs an AngleRange from the provided center angle defining the direction and an angular width to extent the range by 50% clockwise and 50% counter-clockwise from its center angle. Corrects values if they exceed the ranges. Example: direction = 90, extent = 10 means the circle sector is pointing east, with an extent of 5 degrees north-wards and 5 degrees south-wards.
- Parameters:
center-Start angle, running clockwise, in degrees from north. The value will be normalized to [0.0, 360.0).
extent-The range's extent, running clockwise, in degrees from start. The value will be clamped to the range of [0, 360] degrees.
- Returns:
Created AngleRange from the provided center angle and the range's extent.
-
inRange
public boolean inRange(double angleClockwiseInDegreesFromNorth)
Check if a given angle in degrees, clockwise from north is in range or not.
- Parameters:
angleClockwiseInDegreesFromNorth-An angle in degrees from north. Will be normalized before testing.
- Returns:
True, if an angle is in range,falseotherwise.
-
closestInRange
public double closestInRange(double angleClockwiseInDegreesFromNorth)
Get the angle that is closest to the given one and in range. If the angle to both ends of the range is the same, the value in the clockwise direction is returned. If the given angle is in range already, it will be returned as normalized angle.
- Parameters:
angleClockwiseInDegreesFromNorth-An angle in degrees from north. Will be normalized.
- Returns:
The closest, normalized in-range angle in degrees, clockwise from north. If the given angle is in range already, the given angle will be returned as normalized angle in degree, clockwise from north.
-
max
public double max()
Get the maximum angle defined by the range in degrees, clockwise from north, normalized to [0,360).
- Returns:
Maximum angle of the range in degrees, clockwise from north, normalized to [0,360).
-
-