Class: QgsMathUtils¶
Contains utility functions for mathematical operations.
Added in version 4.0.
List of all members, including inherited members
Static Methods
Converts a double value to a rational fraction. |
|
Expands a range outward to round values, e.g. a range of 1234.5 - 3456.7 is expanded to 1200 - 3500. |
|
Returns a round interval, a power of ten, which splits the given span into at least divisions parts. |
- class qgis.core.QgsMathUtils[source]¶
Bases:
object- static doubleToRational(value: float, tolerance: float = 1e-09, maxIterations: int = 100)[source]¶
Converts a double
valueto a rational fraction.- Parameters:
value (float) – value to convert
tolerance (float = 1e-09) – desired precision. The returned fraction will be at within this tolerance of the original value.
maxIterations (int = 100) – maximum number of iterations. Higher values result in better approximations, but at the cost of additional computation.
- Return type:
(int, int)
- Returns:
numerator: calculated numerator
denominator: calculated denominator
- static roundedRange(range: QgsDoubleRange) QgsDoubleRange[source]¶
Expands a
rangeoutward to round values, e.g. a range of 1234.5 - 3456.7 is expanded to 1200 - 3500.The bounds are rounded to a tenth of the order of magnitude of the range’s size, so that the returned range stays close to the original one.
Infinite and empty ranges are returned unchanged.
Added in version 4.4.
- Parameters:
range (QgsDoubleRange)
- Return type:
- static roundingInterval(span: float, divisions: int = 10) float[source]¶
Returns a round interval, a power of ten, which splits the given
spaninto at leastdivisionsparts. E.g. a span of 2222 returns 100 for 10 divisions and 10 for 100 divisions.Returns 0 if
spanis not finite or is not greater than 0, or ifdivisionsis lower than 1.Added in version 4.4.
- Parameters:
span (float)
divisions (int = 10)
- Return type:
float