## hermes Class HermesMath

```java.lang.Object hermes.HermesMath
```

`public class HermesMathextends java.lang.Object`

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

### INFINITY

`public static final float INFINITY`
Constant Field Values

### MINUS_INFINITY

`public static final float MINUS_INFINITY`
Constant Field Values
Constructor Detail

### HermesMath

`public HermesMath()`
Method Detail

### rotate

```public static PVector rotate(PVector vector,
double theta)```
Rotates vector counter-clockwise by an angle theta; mutates the vector and returns it.

Parameters:
`vector` - the vector to rotate
`theta` - the angle to rotate counter-clockwise by
Returns:
the rotated vector (not a new vector, merely a reference to the vector passed in)

### getRotate

```public static PVector getRotate(PVector vector,
double theta)```
Same as rotate() but returns an entirely new vector (does not mutate).

Parameters:
`vector` - the vector to rotate
`theta` - the angle to rotate counter-clockwise by
Returns:
the new rotated vector
`rotate(PVector, double)`

### reverse

`public 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.

Example: ``` PVector v = new PVector(3,-2); Math.reverse(v); // v.x will now be -3, and v.y will be 2 ```

Parameters:
`vector` - the vector to invert
Returns:
the vector (not a new vector, merely a reference to the vector passed in)

### getReverse

`public static PVector getReverse(PVector vector)`
Same as reverse(), but does not modify vector.

Parameters:
`vector` - the vector to invert
Returns:
a new vector that points in the opposite direction of vector
`reverse(PVector)`

### zeroVector

`public static PVector zeroVector()`
Creates a new PVector at (0,0,0).

Returns:
zero vector

### zeroVector

`public static PVector zeroVector(PVector vector)`
Mutates a vector to the zero vector

Parameters:
`vector` - the vector
Returns:
the altered vector

### makeVector

```public static PVector makeVector(float x,
float y,
float z)```
Factory method for creating PVectors

Parameters:
`x` -
`y` -
`z` -
Returns:
PVector

### makeVector

```public static PVector makeVector(float x,
float y)```

### makeVector

```public static PVector makeVector(double x,
double y,
double z)```

### makeVector

```public static PVector makeVector(double x,
double y)```

### cloneVector

`public static PVector cloneVector(PVector vector)`
Instantiates a new vector that is a carbon copy of a given vector.

Parameters:
`vector` - the vector to copy
Returns:
the new copy

### mag2

`public static float mag2(PVector vector)`
Gets the square of the magnitude of a PVector. Useful when taking the square root to find the true magnitude is not important, ie. when trying to identify the largest or smallest PVector in a set (saves time).

Parameters:
`vector` -
Returns:
The square of the magnitude of the vector

### sign

`public static float sign(float x)`
Returns the sign of a float, assigns zero a sign of one.

Parameters:
`x` - the float
Returns:
1 if x is positive or zero, -1 if x is negative

### average

```public static float average(float v1,
float v2)```
Averages two float values.

Parameters:
`v1` - the first value
`v2` - the second value
Returns:
the average

### average

`public static float average(float[] values)`
Averages an array of floats.

Parameters:
`values` - the values to average
Returns:
the average

### angle

`public static float angle(PVector dir)`
Returns the angle of the vector.

(1,0) is 0, (0,1) is PI/2, etc.

Parameters:
`dir` - the vector
Returns:
angle

### inCircle

```public static boolean inCircle(float x,
float y,
float cirX,
float cirY,
Determines if a point is inside a circle.

Parameters:
`x` - x location of point
`y` - y location of point
`cirX` - x location of center of circle
`cirY` - y location of center of circle
`radius` - radius of circle
Returns:
true if point is in circle, false otherwise

### inCircle

```public static boolean inCircle(PVector point,
PVector circleCenter,
`point` - location of point
`circleCenter` - location of center of circle
`radius` - radius of circle