Package org.seamcat.model.mathematics
Class Mathematics
- java.lang.Object
-
- org.seamcat.model.mathematics.Mathematics
-
public class Mathematics extends java.lang.Object
This class contains the needed functions not included in the J2SE standard Math-class
-
-
Field Summary
Fields Modifier and Type Field Description static double
BPS_TO_KBPS
static double
DEFAULT_DELOG
static double
DEFAULT_LOG_START_RANGE
static double
DEGRAD
static int
KM_TO_METERS
static double
MHZ_TO_HZ
static int
PID
static double
RADEG
static double
SQRT3
-
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 pointsstatic 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 Boundsstatic 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 Boundsstatic double
calculateAvgPercentage(VectorResultType vector1, VectorResultType vector2)
static double
calculateCorrelation(double[] a, double[] b)
Pearson Correlationstatic 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 definitionstatic double
convertAngleToConfineToVerticalDefinedRange(double angle)
Generic conversion of the vertical angle so that it remains within the [-90,+90] range definitionstatic double
cosD(double angle)
Returns the trigonometric cosine of an anglestatic double
cosh(double x)
Hyberbolic Cosine functionstatic double
dB2Linear(double value)
static double
distance(Point2D to)
Calculates the distance from (0,0) to the given pointstatic double
distance(Point2D from, Point2D to)
Calculates the distance between two pointsstatic AntennaResult
electricalTiltCorrection(AntennaResult antenna)
performs the co-ordinate correction according the the formulas given by ITU-R F.1336-4
for antennas applying electrical tiltstatic 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 ofdouble
values.static double
getAverage(double[] p, double minValue, double maxValue)
Return average value of an array ofdouble
values, forlength
length of array.static double
getAverage(double[] p, int length, boolean ignoreZeros)
Return average value of an array ofdouble
values, forlength
length of array.static double
getAverage(double[] p, int length, double minValue, double maxValue, boolean ignoreZeros)
Return average value of an array ofdouble
values, forlength
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 graphsstatic 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 maskstatic double
getStdDev(double[] p)
Return Standard Deviation of arraystatic 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 lengthstatic double
getStdDev(double[] p, double ave, int length, boolean ignoreZeros)
Return Standard Deviation of array with given average and lengthstatic double
getStdDev(double[] p, double ave, int length, double minValue, double maxValue)
Return Standard Deviation of array with given average and lengthstatic double
getStdDev(double[] p, double ave, int length, double minValue, double maxValue, boolean ignoreZeros)
Return Standard Deviation of array with given average and lengthstatic 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 wantedXstatic double
max(double[] p)
Return maximum value of double arraystatic double
max(double[] p, double minValue, double maxValue)
Return maximum value of double arraystatic AntennaResult
mechanicalTiltCorrection(AntennaResult antenna)
performs the co-ordinate correction according the the formulas given by ITU-R F.1336-4static double
min(double[] p)
Return minimum value of double arraystatic double
min(double[] p, double minValue, double maxValue)
Return minimum value of double arraystatic 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 digitsstatic double
sinD(double angle)
Returns the trigonometric sine of an anglestatic double
sinh(double x)
Hyberbolic Sine functionstatic <T> T[]
sortBest(T[] elements)
static double[]
stripZeros(double[] array)
static double
tanD(double angle)
Returns the trigonometric tangent of an anglestatic double
tanh(double x)
Hyberbolic trigonometric tangent function
-
-
-
Field Detail
-
KM_TO_METERS
public static final int KM_TO_METERS
- See Also:
- Constant Field Values
-
BPS_TO_KBPS
public static final double BPS_TO_KBPS
- See Also:
- Constant Field Values
-
MHZ_TO_HZ
public static final double MHZ_TO_HZ
- See Also:
- Constant Field Values
-
DEGRAD
public static final double DEGRAD
- See Also:
- Constant Field Values
-
RADEG
public static final double RADEG
- See Also:
- Constant Field Values
-
DEFAULT_DELOG
public static final double DEFAULT_DELOG
- See Also:
- Constant Field Values
-
DEFAULT_LOG_START_RANGE
public static final double DEFAULT_LOG_START_RANGE
- See Also:
- Constant Field Values
-
SQRT3
public static final double SQRT3
-
PID
public static final int PID
- See Also:
- Constant Field Values
-
-
Method Detail
-
distance
public static double distance(Point2D from, Point2D to)
Calculates the distance between two points- Parameters:
from
- from this pointto
- 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 distributionminRange
- 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 ofdouble
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 ofdouble
values, forlength
length of array.- Parameters:
p
- Array of double valueslength
- 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 ofdouble
values, forlength
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 ofdouble
values, forlength
length of array.- Parameters:
p
- Array of double valueslength
- 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 valuesave
- 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 valuesave
- Average value of plength
- 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 valuesave
- Average value of plength
- 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 valuesave
- Average value of plength
- 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 valuesave
- Average value of plength
- 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.- Calculate distance between points: linearyDistance = distance(to, from);
- Project y difference to form triangle: yProjection = Math.abs(from.getY() - to.getY());
- 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
-
calculateElevation
public static double calculateElevation(AntennaResult from, AntennaResult to)
-
calculateAvgPercentage
public static double calculateAvgPercentage(VectorResultType vector1, VectorResultType vector2)
-
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 maskreceptionBandwidth
- 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 maskreceptionBandwidth
- 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
-
-