FreeHEP API
Version v1.2.2

org.freehep.util
Class DiscreteAngle

java.lang.Object
  |
  +--org.freehep.util.DiscreteAngle

public class DiscreteAngle
extends Object

Calculates 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.

Version:
$Id: DiscreteAngle.java,v 1.1 2003/06/10 18:26:16 duns Exp $
Author:
Mark Donszelmann

Constructor Summary
DiscreteAngle()
           
 
Method Summary
 Double addAngle(double angle)
          Adds a discrete angle to the set.
 double getAngle(double angle)
          Returns the closest angle to any discrete angle in the set.
static void main(String[] args)
           
 boolean removeAngle(double angle)
          Removes a discrete angle from the set.
 boolean removeAngle(Double angle)
          Removes a discrete angle from the set.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiscreteAngle

public DiscreteAngle()
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 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(Double angle)
Removes a discrete angle from the set.


toString

public String toString()
Overrides:
toString in class Object

main

public static void main(String[] args)

FreeHEP API
Version v1.2.2

Copyright © 2000-2003 FreeHEP, All Rights Reserved.