Class MathUtils


  • public class MathUtils
    extends Object
    Math utility function library.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double TWO_PI
      Two pi.
    • Constructor Summary

      Constructors 
      Constructor Description
      MathUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      static double distance​(double x1, double y1, double x2, double y2)
      Calculate the euclidean distance between to points given through their coordinates.
      static double lawOfCosine​(double angle, double distanceA, double distanceB)
      Applies the law of cosines to a given angle between two line segments with respective lengths distanceA and distanceB.
      static double polarDistance​(double angleA, double distanceA, double angleB, double distanceB)
      Euclidean distance between two polar coordinates.
      static double polarDistance​(short positions, short positionA, float distanceA, short positionB, float distanceB)
      Euclidean distance between two DiscreteGenes.
      static double sectorAngle​(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
    • Constructor Detail

      • MathUtils

        public MathUtils()
    • 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 point
        distanceA - distance of the first point
        angleB - angle of the second point
        distanceB - 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 two DiscreteGenes.
        Parameters:
        positions - amount of rays
        positionA - first ray index
        distanceA - first gene distance
        positionB - second ray index
        distanceB - 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 given angle between two line segments with respective lengths distanceA and distanceB.
        Parameters:
        angle - angle between the two line segments
        distanceA - length of one line segment
        distanceB - 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 one
        y1 - y-coordinate of point one
        x2 - x-coordinate of point two
        y2 - 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 - angle
        lengthA - one side's length
        lengthB - other side's length
        Returns:
        area covered by triangle