java.lang.Object
org.jhotdraw8.geom.Angles
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleangle(double x1, double y1, double x2, double y2) Gets the angle of the specified line.static doubleanglesSignedSpan(double from, double to) Signed shortest distance between two angles.static doubleangleSubtract(double from, double to) Signed difference of two angles.static doubleanglesUnsignedSpan(double from, double to) Unsigned shortest distance between two angles.static doubleatan2(double dy, double dx) Computes atan2 if dy and dx are large enough.static doubleatan2Ellipse(double cx, double cy, double rx, double ry, double x, double y) static doublecosDegrees(double aDeg) Returns the trigonometric cosine of an angle in degrees.static intdirection(double x1, double y1, double x2, double y2) Returns the direction OUT_TOP, OUT_BOTTOM, OUT_LEFT, OUT_RIGHT from one point to another one.static @NonNull Point2D.Doubleperp(double x, double y) Gets the perpendicular vector to the given vector.static doublesinDegrees(double aDeg) Returns the trigonometric sine of an angle in degrees.
-
Constructor Details
-
Angles
public Angles()
-
-
Method Details
-
angle
public static double angle(double x1, double y1, double x2, double y2) Gets the angle of the specified line.- Parameters:
x1- the x-coordinate of point 1 on the liney1- the y-coordinate of point 1 on the linex2- the x-coordinate of point 2 on the liney2- the y-coordinate of point 2 on the line- Returns:
- the angle in radians
-
atan2
public static double atan2(double dy, double dx) Computes atan2 if dy and dx are large enough.Math.atan2 can go into an infinite loop if dy and dx are almost zero.
- Parameters:
dy- the dydx- the dx- Returns:
- atan2 of dy, dx or 0.
-
angleSubtract
public static double angleSubtract(double from, double to) Signed difference of two angles.- Parameters:
from- angle 0to- angle 1- Returns:
- -PI <= diff <= PI.
-
anglesSignedSpan
public static double anglesSignedSpan(double from, double to) Signed shortest distance between two angles.- Parameters:
from- angle 0to- angle 1- Returns:
- -PI <= diff <= PI.
-
anglesUnsignedSpan
public static double anglesUnsignedSpan(double from, double to) Unsigned shortest distance between two angles.- Parameters:
from- angle 0to- angle 1- Returns:
- 0 <= diff <= PI.
-
direction
public static int direction(double x1, double y1, double x2, double y2) Returns the direction OUT_TOP, OUT_BOTTOM, OUT_LEFT, OUT_RIGHT from one point to another one.- Parameters:
x1- the x coordinate of point 1y1- the y coordinate of point 1x2- the x coordinate of point 2y2- the y coordinate of point 2- Returns:
- the direction
-
perp
Gets the perpendicular vector to the given vector.- Parameters:
x- the x value of the vectory- the x value of the vector- Returns:
- the perpendicular vector
-
atan2Ellipse
public static double atan2Ellipse(double cx, double cy, double rx, double ry, double x, double y) -
sinDegrees
public static double sinDegrees(double aDeg) Returns the trigonometric sine of an angle in degrees.References:
- Values of Trigonometric ratios for 0, 30, 45, 60 and 90 degrees
- mathinstructor.net
- Parameters:
aDeg- an angle in degrees- Returns:
- the sine of the argument
-
cosDegrees
public static double cosDegrees(double aDeg) Returns the trigonometric cosine of an angle in degrees.References:
- Values of Trigonometric ratios for 0, 30, 45, 60 and 90 degrees
- mathinstructor.net
- Parameters:
aDeg- an angle in degrees- Returns:
- the cosine of the argument
-