Package evo.search.util
Class MathUtils
- java.lang.Object
-
- evo.search.util.MathUtils
-
public class MathUtils extends Object
Math utility function library.
-
-
Field Summary
Fields Modifier and Type Field Description static doubleTWO_PITwo pi.
-
Constructor Summary
Constructors Constructor Description MathUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubleareaInTriangle(double angle, double lengthA, double lengthB)Calculate the area covered by a triangle defined by an edge's angle and the lengths of the two sides connected to the edge.static doubledistance(double x1, double y1, double x2, double y2)Calculate the euclidean distance between to points given through their coordinates.static doublelawOfCosine(double angle, double distanceA, double distanceB)Applies the law of cosines to a givenanglebetween two line segments with respective lengthsdistanceAanddistanceB.static doublepolarDistance(double angleA, double distanceA, double angleB, double distanceB)Euclidean distance between two polar coordinates.static doublepolarDistance(short positions, short positionA, float distanceA, short positionB, float distanceB)Euclidean distance between twoDiscreteGenes.static doublesectorAngle(int positions)Return the angle of one sector for a given amount of equally distanced rays.
-
-
-
Field Detail
-
TWO_PI
public static final double TWO_PI
Two pi. Nothing more, nothing less.- See Also:
- Constant Field Values
-
-
Method Detail
-
polarDistance
public static double polarDistance(double angleA, double distanceA, double angleB, double distanceB)Euclidean distance between two polar coordinates.- Parameters:
angleA- angle of the first pointdistanceA- distance of the first pointangleB- angle of the second pointdistanceB- distance of the second point- Returns:
- euclidean distance
-
polarDistance
public static double polarDistance(short positions, short positionA, float distanceA, short positionB, float distanceB)Euclidean distance between twoDiscreteGenes.- Parameters:
positions- amount of rayspositionA- first ray indexdistanceA- first gene distancepositionB- second ray indexdistanceB- second gene distance- Returns:
- euclidean distance between two genes
-
sectorAngle
public static double sectorAngle(int positions)
Return the angle of one sector for a given amount of equally distanced rays.- Parameters:
positions- amount of rays- Returns:
- angle between two rays
-
lawOfCosine
public static double lawOfCosine(double angle, double distanceA, double distanceB)Applies the law of cosines to a givenanglebetween two line segments with respective lengthsdistanceAanddistanceB.- Parameters:
angle- angle between the two line segmentsdistanceA- length of one line segmentdistanceB- length of other line segment- Returns:
- length of the third side forming a triangle
-
distance
public static double distance(double x1, double y1, double x2, double y2)Calculate the euclidean distance between to points given through their coordinates.- Parameters:
x1- x-coordinate of point oney1- y-coordinate of point onex2- x-coordinate of point twoy2- y-coordinate of point two- Returns:
- euclidean distance between the points
-
areaInTriangle
public static double areaInTriangle(double angle, double lengthA, double lengthB)Calculate the area covered by a triangle defined by an edge's angle and the lengths of the two sides connected to the edge.- Parameters:
angle- anglelengthA- one side's lengthlengthB- other side's length- Returns:
- area covered by triangle
-
-