public class GMath extends Object
acm.graphics package.| Modifier and Type | Method and Description |
|---|---|
static float |
angle(float x,
float y)
Returns the angle in degrees from the origin to the point
(
x, y). |
static float |
angle(float x0,
float y0,
float x1,
float y1)
Computes the angle in degrees formed by a line segment from the
point (
x0, y0) and
(x1, y1). |
static float |
cosDegrees(float angle)
Returns the trigonometric cosine of its argument where
angle
is expressed in degrees. |
static float |
distance(float x,
float y)
Computes the distance between the origin and the point
(
x, y). |
static float |
distance(float x0,
float y0,
float x1,
float y1)
Computes the distance between the points (
x0, y0)
and (x1, y1). |
static int |
round(float x)
Rounds a
float value to the nearest int. |
static float |
sinDegrees(float angle)
Returns the trigonometric sine of its argument where
angle
is expressed in degrees. |
static float |
tanDegrees(float angle)
Returns the trigonometric tangent of its argument where
angle
is expressed in degrees. |
static float |
toDegrees(float radians)
Converts an angle from radians to degrees.
|
static float |
toRadians(float degrees)
Converts an angle from degrees to radians.
|
public static int round(float x)
float value to the nearest int.x - A float valueint valuepublic static float sinDegrees(float angle)
angle
is expressed in degrees.angle - An angle measured in degreespublic static float cosDegrees(float angle)
angle
is expressed in degrees.angle - An angle measured in degreespublic static float tanDegrees(float angle)
angle
is expressed in degrees.angle - An angle measured in degreespublic static float toDegrees(float radians)
Math class, but was added only in JDK1.2, which is not
supported in all browsers.radians - An angle measured in radianspublic static float toRadians(float degrees)
Math class, but was added only in JDK1.2, which is not
supported in all browsers.degrees - An angle measured in degreespublic static float distance(float x,
float y)
x, y).x - The x-coordinate of the pointy - The y-coordinate of the pointx, y)public static float distance(float x0,
float y0,
float x1,
float y1)
x0, y0)
and (x1, y1).x0 - The x-coordinate of one pointy0 - The y-coordinate of that pointx1 - The x-coordinate of the other pointy1 - The y-coordinate of that pointx0, y0) and
(x1, y1)public static float angle(float x,
float y)
x, y). This method is easier to use than
atan2 because it specifies the displacements in the usual
x/y order and because it takes care of the fact that the Java coordinate
system is flipped. The point (0, 0) is arbitrarily defined to be at
angle 0.x - The x-coordinate of the pointy - The y-coordinate of the pointx, y)
measured in degrees counterclockwise from the +x axispublic static float angle(float x0,
float y0,
float x1,
float y1)
x0, y0) and
(x1, y1).x0 - The x-coordinate of one pointy0 - The y-coordinate of that pointx1 - The x-coordinate of the other pointy1 - The y-coordinate of that pointx0, y0) to
(x1, y1)