|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectacm.graphics.GMath
public class GMath
This class defines a variety of static mathematical methods
that are useful for the acm.graphics package.
| Method Summary | |
|---|---|
double |
angle(double x,
double y)
x, y). |
double |
angle(double x0,
double y0,
double x1,
double y1)
x0, y0) and
(x1, y1). |
double |
cosDegrees(double angle)
angle
is expressed in degrees. |
double |
distance(double x,
double y)
x, y). |
double |
distance(double x0,
double y0,
double x1,
double y1)
x0, y0)
and (x1, y1). |
int |
round(double x)
double value to the nearest int. |
double |
sinDegrees(double angle)
angle
is expressed in degrees. |
double |
tanDegrees(double angle)
angle
is expressed in degrees. |
double |
toDegrees(double radians)
|
double |
toRadians(double degrees)
|
| Method Detail |
|---|
public static double angle(double x,
double 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.
Usage: | double theta = angle(x, y); | ||||
Parameters: |
| ||||
Returns: | The angle from the origin to the point (x, y)
measured in degrees counterclockwise from the +x axis
|
public static double angle(double x0,
double y0,
double x1,
double y1)x0, y0) and
(x1, y1).
Usage: | double theta = angle(x0, y0, x1, y1); | ||||||||
Parameters: |
| ||||||||
Returns: | The angle formed by the line segment from
(x0, y0) to
(x1, y1)
|
public static double cosDegrees(double angle)angle
is expressed in degrees.
Usage: | double c = cosDegrees(angle); | ||
Parameter: |
| ||
Returns: | The trigonometric cosine of the angle |
public static double distance(double x,
double y)x, y).
Usage: | double d = distance(x, y); | ||||
Parameters: |
| ||||
Returns: | The distance from the origin to the point (x, y)
|
public static double distance(double x0,
double y0,
double x1,
double y1)x0, y0)
and (x1, y1).
Usage: | double d = distance(x0, y0, x1, y1); | ||||||||
Parameters: |
| ||||||||
Returns: | The distance between the points (x0, y0) and
(x1, y1)
|
public static int round(double x)double value to the nearest int.
Usage: | int n = round(x); | ||
Parameter: |
| ||
Returns: | The nearest int value
|
public static double sinDegrees(double angle)angle
is expressed in degrees.
Usage: | double s = sinDegrees(angle); | ||
Parameter: |
| ||
Returns: | The trigonometric sine of the angle |
public static double tanDegrees(double angle)angle
is expressed in degrees.
Usage: | double t = tanDegrees(angle); | ||
Parameter: |
| ||
Returns: | The trigonometric tangent of the angle |
public static double toDegrees(double radians)Math class, but was added only in JDK1.2, which is not
supported in all browsers.
Usage: | double degrees = toDegrees(radians); | ||
Parameter: |
| ||
Returns: | The equivalent angle in degrees |
public static double toRadians(double degrees)Math class, but was added only in JDK1.2, which is not
supported in all browsers.
Usage: | double radians = toRadians(degrees); | ||
Parameter: |
| ||
Returns: | The equivalent angle in radians |
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||