org.freehep.util
Class DiscreteAngle
- java.lang.Object
-
- org.freehep.util.DiscreteAngle
-
public class DiscreteAngle extends java.lang.ObjectCalculates a discrete angle from an arbitrary angle, based on a set of given angles. The class calculates the angle by dividing 360 degrees into segments based on the discrete angles. It then will calculate the closest discrete angle for a given angle. Discrete angles can be added and removed. This class can be used to constrain the mouse movement (or its result) if one wants to draw under certain angles only.
-
-
Constructor Summary
Constructors Constructor and Description DiscreteAngle()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.DoubleaddAngle(double angle)Adds a discrete angle to the set.doublegetAngle(double angle)Returns the closest angle to any discrete angle in the set.static voidmain(java.lang.String[] args)booleanremoveAngle(double angle)Removes a discrete angle from the set.booleanremoveAngle(java.lang.Double angle)Removes a discrete angle from the set.java.lang.StringtoString()
-
-
-
Method Detail
-
getAngle
public double getAngle(double angle)
Returns the closest angle to any discrete angle in the set. Returns itself if the set is empty. Returns the only discrete angle if the set only contains one angle.
-
addAngle
public java.lang.Double addAngle(double angle)
Adds a discrete angle to the set.
-
removeAngle
public boolean removeAngle(double angle)
Removes a discrete angle from the set.
-
removeAngle
public boolean removeAngle(java.lang.Double angle)
Removes a discrete angle from the set.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
main
public static void main(java.lang.String[] args)
-
-
DMelt 3.0 © DataMelt by jWork.ORG