Class Mathematics


  • public class Mathematics
    extends java.lang.Object
    This class contains the needed functions not included in the J2SE standard Math-class
    • Constructor Summary

      Constructors 
      Constructor Description
      Mathematics()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double acosD​(double angle)
      Returns the arc cosine of an angle, in the range of 0.0 through pi.
      static double angle​(double x1, double y1, double x2, double y2)
      Finds the angle between two points
      static double asinD​(double x)
      Returns the arc sine of an angle, in the range of -pi/2 through pi/2.
      static double atan2D​(double x, double y)
      Converts rectangular coordinates (x, y) to polar (r, theta).
      static double atanD​(double angle)
      Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.
      static Bounds bandwidthBoundsFromEmissionMask​(MaskFunction mask, double receptionBandwidth)
      consider first the reference bandwidth of the wanted range.
      in case the wanted range exceeds the reference bandwidth, calculate upper and lower bounds of the bandwidth
      in case the mask is not flat, it takes the lower and upper values at an attenuation of 23 dB
      relative to the centre of the mask as Bounds
      static double bandwidthFromEmissionMask​(MaskFunction mask, double receptionBandwidth)
      get bandwidth derived from the emission mask
      it uses the method bandwidthBoundsFromEmissionMask() which reports the lower and upper edges as Bounds
      static double calculateAvgPercentage​(VectorResultType vector1, VectorResultType vector2)  
      static double calculateCorrelation​(double[] a, double[] b)
      Pearson Correlation
      static double calculateElevation​(Point2D from, double fromHeight, Point2D to, double toHeight)
      Calculate the elevation angle between points.
      static double calculateElevation​(AntennaResult from, AntennaResult to)  
      static double calculateKartesianAngle​(Point2D to)
      Calculate the Kartesian angle between (0,0) and point.
      static double calculateKartesianAngle​(Point2D to, Point2D from)
      Calculate the Kartesian angle between points.
      static double convertAngleToConfineToHorizontalDefinedRange​(double angle)
      Generic conversion of the horizontal angle so that it remains within the [0,360] range definition
      static double convertAngleToConfineToVerticalDefinedRange​(double angle)
      Generic conversion of the vertical angle so that it remains within the [-90,+90] range definition
      static double cosD​(double angle)
      Returns the trigonometric cosine of an angle
      static double cosh​(double x)
      Hyberbolic Cosine function
      static double dB2Linear​(double value)  
      static double distance​(Point2D to)
      Calculates the distance from (0,0) to the given point
      static double distance​(Point2D from, Point2D to)
      Calculates the distance between two points
      static AntennaResult electricalTiltCorrection​(AntennaResult antenna)
      performs the co-ordinate correction according the the formulas given by ITU-R F.1336-4
      for antennas applying electrical tilt
      static boolean equals​(double a, double b, double tolerance)  
      static double fromdBm2Watt​(double dbm)  
      static double fromWatt2dBm​(double watt)  
      static double getAverage​(double[] p)
      Return average value of an array of double values.
      static double getAverage​(double[] p, double minValue, double maxValue)
      Return average value of an array of double values, for length length of array.
      static double getAverage​(double[] p, int length, boolean ignoreZeros)
      Return average value of an array of double values, for length length of array.
      static double getAverage​(double[] p, int length, double minValue, double maxValue, boolean ignoreZeros)
      Return average value of an array of double values, for length length of array.
      static double getMedian​(double[] p, int length, boolean ignoreZeros)  
      static double getMinimumLogDomainValue​(double minimumDistribution, double minRange)
      Get the smallest number that can be used a range start for the logarithmic graphs
      static double getRefBW_of_EmissionMask​(MaskFunction emissionMask)
      compares the values at an offset of zero of the origin mask against the value of the mask normalized to 1 MHz reference bandwidth
      and derives from this ratio the underlying reference bandwidth of the origin mask
      static double getStdDev​(double[] p)
      Return Standard Deviation of array
      static double getStdDev​(double[] p, double ave)
      Return Standard Deviation of array with given average.
      static double getStdDev​(double[] p, double ave, int length)
      Return Standard Deviation of array with given average and length
      static double getStdDev​(double[] p, double ave, int length, boolean ignoreZeros)
      Return Standard Deviation of array with given average and length
      static double getStdDev​(double[] p, double ave, int length, double minValue, double maxValue)
      Return Standard Deviation of array with given average and length
      static double getStdDev​(double[] p, double ave, int length, double minValue, double maxValue, boolean ignoreZeros)
      Return Standard Deviation of array with given average and length
      static double linear2dB​(double value)  
      static double linearInterpolate​(double wantedX, Point2D first, Point2D second)
      Does a linear interpolation of points first and second to calculate the wanted function value of wantedX
      static double max​(double[] p)
      Return maximum value of double array
      static double max​(double[] p, double minValue, double maxValue)
      Return maximum value of double array
      static AntennaResult mechanicalTiltCorrection​(AntennaResult antenna)
      performs the co-ordinate correction according the the formulas given by ITU-R F.1336-4
      static double min​(double[] p)
      Return minimum value of double array
      static double min​(double[] p, double minValue, double maxValue)
      Return minimum value of double array
      static double powerSubtract​(double value, double sub)  
      static double powerSummation​(double... powers)  
      static double Qi​(double x)  
      static double round​(double d)
      Rounds a double to 3 digits
      static double sinD​(double angle)
      Returns the trigonometric sine of an angle
      static double sinh​(double x)
      Hyberbolic Sine function
      static <T> T[] sortBest​(T[] elements)  
      static double[] stripZeros​(double[] array)  
      static double tanD​(double angle)
      Returns the trigonometric tangent of an angle
      static double tanh​(double x)
      Hyberbolic trigonometric tangent function
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Mathematics

        public Mathematics()
    • Method Detail

      • distance

        public static double distance​(Point2D from,
                                      Point2D to)
        Calculates the distance between two points
        Parameters:
        from - from this point
        to - to this point
        Returns:
        distance
      • distance

        public static double distance​(Point2D to)
        Calculates the distance from (0,0) to the given point
        Parameters:
        to - from zero to this point
        Returns:
        distance
      • dB2Linear

        public static double dB2Linear​(double value)
      • linear2dB

        public static double linear2dB​(double value)
      • fromdBm2Watt

        public static double fromdBm2Watt​(double dbm)
      • fromWatt2dBm

        public static double fromWatt2dBm​(double watt)
      • getMinimumLogDomainValue

        public static double getMinimumLogDomainValue​(double minimumDistribution,
                                                      double minRange)
        Get the smallest number that can be used a range start for the logarithmic graphs
        Parameters:
        minimumDistribution - the smallest distribution
        minRange - the range minimum
      • powerSummation

        public static double powerSummation​(double... powers)
      • powerSubtract

        public static double powerSubtract​(double value,
                                           double sub)
      • round

        public static double round​(double d)
        Rounds a double to 3 digits
        Parameters:
        d -
      • acosD

        public static double acosD​(double angle)
        Returns the arc cosine of an angle, in the range of 0.0 through pi.
        Parameters:
        angle - given in degrees
        Returns:
        The arc cosine of an angle given in degrees, in the range of 0.0 through pi.
      • asinD

        public static double asinD​(double x)
        Returns the arc sine of an angle, in the range of -pi/2 through pi/2.
        Parameters:
        x - angle given in degrees
        Returns:
        The arc sine of an angle given in degrees, in the range of -pi/2 through pi/2.
      • atan2D

        public static double atan2D​(double x,
                                    double y)
        Converts rectangular coordinates (x, y) to polar (r, theta).
        Returns:
        The arc tangent of an angle in degrees specified by rectangular coordinates.
      • angle

        public static double angle​(double x1,
                                   double y1,
                                   double x2,
                                   double y2)
        Finds the angle between two points
      • atanD

        public static double atanD​(double angle)
        Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.
        Parameters:
        angle - given in degrees
        Returns:
        The arc tangent of an angle given degrees, in the range of -pi/2 through pi/2.
      • cosD

        public static double cosD​(double angle)
        Returns the trigonometric cosine of an angle
        Parameters:
        angle - in degrees
        Returns:
        The trigonometric cosine of an angle in degrees
      • cosh

        public static double cosh​(double x)
        Hyberbolic Cosine function
        Parameters:
        x -
        Returns:
        The hyberbolic cosine value of given argument
      • getAverage

        public static double getAverage​(double[] p)
        Return average value of an array of double values.
        Parameters:
        p - Array of double values
        Returns:
        The average value of array range from 0 - p.length
      • getAverage

        public static double getAverage​(double[] p,
                                        int length,
                                        boolean ignoreZeros)
        Return average value of an array of double values, for length length of array.
        Parameters:
        p - Array of double values
        length - The number of array entries to average over
        Returns:
        The average value of array range from 0 - length
      • getMedian

        public static double getMedian​(double[] p,
                                       int length,
                                       boolean ignoreZeros)
      • stripZeros

        public static double[] stripZeros​(double[] array)
      • getAverage

        public static double getAverage​(double[] p,
                                        double minValue,
                                        double maxValue)
        Return average value of an array of double values, for length length of array.
        Parameters:
        p - Array of double values
        Returns:
        The average value of array range from 0 - length
      • getAverage

        public static double getAverage​(double[] p,
                                        int length,
                                        double minValue,
                                        double maxValue,
                                        boolean ignoreZeros)
        Return average value of an array of double values, for length length of array.
        Parameters:
        p - Array of double values
        length - The number of array entries to average over
        Returns:
        The average value of array range from 0 - length
      • getStdDev

        public static double getStdDev​(double[] p)
        Return Standard Deviation of array
        Parameters:
        p - Array of double values
        Returns:
        getStdDev(p,ave,p.length)
      • getStdDev

        public static double getStdDev​(double[] p,
                                       double ave)
        Return Standard Deviation of array with given average.
        Parameters:
        p - Array of double values
        ave - Average value of p
        Returns:
        getStdDev(p,ave,p.length)
      • getStdDev

        public static double getStdDev​(double[] p,
                                       double ave,
                                       int length,
                                       double minValue,
                                       double maxValue)
        Return Standard Deviation of array with given average and length
        Parameters:
        p - Array of double values
        ave - Average value of p
        length - The number of array which has been averaged over
        Returns:
        Standard deviation of array values ranging from 0 - length
      • getStdDev

        public static double getStdDev​(double[] p,
                                       double ave,
                                       int length,
                                       double minValue,
                                       double maxValue,
                                       boolean ignoreZeros)
        Return Standard Deviation of array with given average and length
        Parameters:
        p - Array of double values
        ave - Average value of p
        length - The number of array which has been averaged over
        Returns:
        Standard deviation of array values ranging from 0 - length
      • getStdDev

        public static double getStdDev​(double[] p,
                                       double ave,
                                       int length,
                                       boolean ignoreZeros)
        Return Standard Deviation of array with given average and length
        Parameters:
        p - Array of double values
        ave - Average value of p
        length - The number of array which has been averaged over
        Returns:
        Standard deviation of array values ranging from 0 - length
      • getStdDev

        public static double getStdDev​(double[] p,
                                       double ave,
                                       int length)
        Return Standard Deviation of array with given average and length
        Parameters:
        p - Array of double values
        ave - Average value of p
        length - The number of array which has been averaged over
        Returns:
        Standard deviation of array values ranging from 0 - length
      • max

        public static double max​(double[] p)
        Return maximum value of double array
        Parameters:
        p - Array of double values
        Returns:
        highest entry value.
      • min

        public static double min​(double[] p)
        Return minimum value of double array
        Parameters:
        p - Array of double values
        Returns:
        lowest entry value
      • max

        public static double max​(double[] p,
                                 double minValue,
                                 double maxValue)
        Return maximum value of double array
        Parameters:
        p - Array of double values
        Returns:
        highest entry value.
      • min

        public static double min​(double[] p,
                                 double minValue,
                                 double maxValue)
        Return minimum value of double array
        Parameters:
        p - Array of double values
        Returns:
        lowest entry value
      • sinD

        public static double sinD​(double angle)
        Returns the trigonometric sine of an angle
        Parameters:
        angle - in degrees
        Returns:
        The trigonometric sine of an angle in degrees
      • sinh

        public static double sinh​(double x)
        Hyberbolic Sine function
        Parameters:
        x -
        Returns:
        The hyberbolic sine value of given argument
      • tanD

        public static double tanD​(double angle)
        Returns the trigonometric tangent of an angle
        Parameters:
        angle - in degrees
        Returns:
        The trigonometric tangent of an angle in degrees
      • tanh

        public static double tanh​(double x)
        Hyberbolic trigonometric tangent function
        Parameters:
        x -
        Returns:
        The hyberbolic trigonometric tangent value of given argument
      • calculateCorrelation

        public static double calculateCorrelation​(double[] a,
                                                  double[] b)
        Pearson Correlation
      • sortBest

        public static <T> T[] sortBest​(T[] elements)
      • linearInterpolate

        public static double linearInterpolate​(double wantedX,
                                               Point2D first,
                                               Point2D second)
        Does a linear interpolation of points first and second to calculate the wanted function value of wantedX
        Parameters:
        wantedX -
        first -
        second -
      • equals

        public static boolean equals​(double a,
                                     double b,
                                     double tolerance)
      • Qi

        public static double Qi​(double x)
      • calculateKartesianAngle

        public static double calculateKartesianAngle​(Point2D to,
                                                     Point2D from)
        Calculate the Kartesian angle between points.
        1. Calculate distance between points: linearyDistance = distance(to, from);
        2. Project y difference to form triangle: yProjection = Math.abs(from.getY() - to.getY());
        3. calculate the relative angle: angle = Mathematics.asinD(yProjection / linearyDistance);

        and then convert to an angle in the first Quadrant.
        Parameters:
        to -
        from -
        Returns:
        angle between two points in Degree
      • convertAngleToConfineToHorizontalDefinedRange

        public static double convertAngleToConfineToHorizontalDefinedRange​(double angle)
        Generic conversion of the horizontal angle so that it remains within the [0,360] range definition
        Parameters:
        angle - any angle in degree
        Returns:
        angle within [0,360]
      • calculateKartesianAngle

        public static double calculateKartesianAngle​(Point2D to)
        Calculate the Kartesian angle between (0,0) and point.

        equivalent to: calculateKartesianAngle( Point2D to, 0)

        See calculateKartesianAngle( Point2D to, Point2D from) for more details.

        Parameters:
        to -
        Returns:
        angle in degree between (0,0) and a point
      • calculateElevation

        public static double calculateElevation​(Point2D from,
                                                double fromHeight,
                                                Point2D to,
                                                double toHeight)
        Calculate the elevation angle between points.

        the fundamental equation is as follow:

        elevation = atanD((toHeight - fromHeight) / (distance * KM_TO_METERS))

        Parameters:
        from -
        fromHeight -
        to -
        toHeight -
        Returns:
        angle in Degree
      • convertAngleToConfineToVerticalDefinedRange

        public static double convertAngleToConfineToVerticalDefinedRange​(double angle)
        Generic conversion of the vertical angle so that it remains within the [-90,+90] range definition
        Parameters:
        angle - any angle in degree
        Returns:
        angle within [-90,+90]
      • bandwidthFromEmissionMask

        public static double bandwidthFromEmissionMask​(MaskFunction mask,
                                                       double receptionBandwidth)
        get bandwidth derived from the emission mask
        it uses the method bandwidthBoundsFromEmissionMask() which reports the lower and upper edges as Bounds
        Parameters:
        mask - emission mask
        receptionBandwidth - system bandwidth
        Returns:
        bandwidth
      • bandwidthBoundsFromEmissionMask

        public static Bounds bandwidthBoundsFromEmissionMask​(MaskFunction mask,
                                                             double receptionBandwidth)
        consider first the reference bandwidth of the wanted range.
        in case the wanted range exceeds the reference bandwidth, calculate upper and lower bounds of the bandwidth
        in case the mask is not flat, it takes the lower and upper values at an attenuation of 23 dB
        relative to the centre of the mask as Bounds
        Parameters:
        mask - emission mask
        receptionBandwidth - system bandwidth
        Returns:
        bounds of the bandwidth
      • getRefBW_of_EmissionMask

        public static double getRefBW_of_EmissionMask​(MaskFunction emissionMask)
        compares the values at an offset of zero of the origin mask against the value of the mask normalized to 1 MHz reference bandwidth
        and derives from this ratio the underlying reference bandwidth of the origin mask
        Parameters:
        emissionMask - of the transmitter
        Returns:
        reference bandwidth at zero offset
      • mechanicalTiltCorrection

        public static AntennaResult mechanicalTiltCorrection​(AntennaResult antenna)
        performs the co-ordinate correction according the the formulas given by ITU-R F.1336-4
        Parameters:
        antenna - of which angles shall be translated
        Returns:
        translated antenna
      • electricalTiltCorrection

        public static AntennaResult electricalTiltCorrection​(AntennaResult antenna)
        performs the co-ordinate correction according the the formulas given by ITU-R F.1336-4
        for antennas applying electrical tilt
        Parameters:
        antenna - of which angles shall be translated
        Returns:
        translated antenna