|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hermes.HermesMath
public class HermesMath
A collection of helpful math utilities.
HINT: Use import static hermes.HermesMath.*;
to access these methods like you would Processing library functions.
Field Summary | |
---|---|
static float |
INFINITY
|
static float |
MINUS_INFINITY
|
Constructor Summary | |
---|---|
HermesMath()
|
Method Summary | |
---|---|
static float |
angle(PVector dir)
Returns the angle of the vector. |
static float |
average(float[] values)
Averages an array of floats. |
static float |
average(float v1,
float v2)
Averages two float values. |
static PVector |
cloneVector(PVector vector)
Instantiates a new vector that is a carbon copy of a given vector. |
static PVector |
getReverse(PVector vector)
Same as reverse(), but does not modify vector. |
static PVector |
getRotate(PVector vector,
double theta)
Same as rotate() but returns an entirely new vector (does not mutate). |
static boolean |
inCircle(float x,
float y,
float cirX,
float cirY,
float radius)
Determines if a point is inside a circle. |
static boolean |
inCircle(PVector point,
PVector circleCenter,
float radius)
Determines if a point is inside a circle. |
static float |
mag2(PVector vector)
Gets the square of the magnitude of a PVector. |
static PVector |
makeVector(double x,
double y)
|
static PVector |
makeVector(double x,
double y,
double z)
|
static PVector |
makeVector(float x,
float y)
|
static PVector |
makeVector(float x,
float y,
float z)
Factory method for creating PVectors |
static PVector |
reverse(PVector vector)
Reverses the direction of a PVector in the coordinate system, so the signs of each component are inverted; returns a mutated vector. |
static PVector |
rotate(PVector vector,
double theta)
Rotates vector counter-clockwise by an angle theta; mutates the vector and returns it. |
static float |
sign(float x)
Returns the sign of a float, assigns zero a sign of one. |
static PVector |
zeroVector()
Creates a new PVector at (0,0,0). |
static PVector |
zeroVector(PVector vector)
Mutates a vector to the zero vector |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final float INFINITY
public static final float MINUS_INFINITY
Constructor Detail |
---|
public HermesMath()
Method Detail |
---|
public static PVector rotate(PVector vector, double theta)
vector
- the vector to rotatetheta
- the angle to rotate counter-clockwise by
public static PVector getRotate(PVector vector, double theta)
vector
- the vector to rotatetheta
- the angle to rotate counter-clockwise by
rotate(PVector, double)
public static PVector reverse(PVector vector)
Example:
PVector v = new PVector(3,-2);
Math.reverse(v);
// v.x will now be -3, and v.y will be 2
vector
- the vector to invert
public static PVector getReverse(PVector vector)
vector
- the vector to invert
reverse(PVector)
public static PVector zeroVector()
public static PVector zeroVector(PVector vector)
vector
- the vector
public static PVector makeVector(float x, float y, float z)
x
- y
- z
-
public static PVector makeVector(float x, float y)
public static PVector makeVector(double x, double y, double z)
public static PVector makeVector(double x, double y)
public static PVector cloneVector(PVector vector)
vector
- the vector to copy
public static float mag2(PVector vector)
vector
-
public static float sign(float x)
x
- the float
public static float average(float v1, float v2)
v1
- the first valuev2
- the second value
public static float average(float[] values)
values
- the values to average
public static float angle(PVector dir)
(1,0) is 0, (0,1) is PI/2, etc.
dir
- the vector
public static boolean inCircle(float x, float y, float cirX, float cirY, float radius)
x
- x location of pointy
- y location of pointcirX
- x location of center of circlecirY
- y location of center of circleradius
- radius of circle
public static boolean inCircle(PVector point, PVector circleCenter, float radius)
point
- location of pointcircleCenter
- location of center of circleradius
- radius of circle
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |