Skip to content

Commit 8d122e3

Browse files
authored
Merge pull request #2902 from pygame-community/ankith26-math-fixes
Minor docs/stubs improvements in `invlerp`/`remap`
2 parents 011f7ff + 1361426 commit 8d122e3

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

buildconfig/stubs/pygame/math.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ class Vector3(_GenericVector):
333333
def update(self, x: int, y: int, z: int) -> None: ...
334334

335335

336-
def lerp(a: float, b: float, weight: float, do_clamp: bool = True, /) -> float: ...
337-
def invlerp(a: float, b: float, weight: float, /) -> float: ...
336+
def lerp(a: float, b: float, value: float, do_clamp: bool = True, /) -> float: ...
337+
def invlerp(a: float, b: float, value: float, /) -> float: ...
338338
def remap(i_min: float, i_max: float, o_min: float, o_max: float, value: float, /) -> float: ...
339339
def smoothstep(a: float, b: float, weight: float, /) -> float: ...
340340

docs/reST/ref/math.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Multiple coordinates can be set using slices or swizzling
8888
and ``b``. The third parameter ``value`` is the result of the linear interpolation
8989
between a and b with a certain coefficient. In other words, this coefficient
9090
will be the result of this function.
91-
If ``b - a`` is equal to 0, it raises a ``ZeroDivisionError``.
91+
If ``b`` and ``a`` are equal, it raises a ``ValueError``.
9292

9393
The formula is:
9494

@@ -135,12 +135,12 @@ Multiple coordinates can be set using slices or swizzling
135135
136136
.. function:: remap
137137

138-
| :sl:`remaps value from i_range to o_range`
138+
| :sl:`remaps value from given input range to given output range`
139139
| :sg:`remap(i_min, i_max, o_min, o_max, value, /) -> float`
140140
141-
Returns a number which is the value remapped from ``i_range`` to
142-
``o_range``.
143-
If ``i_max - i_min`` is equal to 0, it raises a ``ZeroDivisionError``.
141+
Returns a number which is the value remapped from ``[i_min, i_max]`` range to
142+
``[o_min, o_max]`` range.
143+
If ``i_min`` and ``i_max`` are equal, it raises a ``ValueError``.
144144

145145
Example:
146146

src_c/doc/math_doc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#define DOC_MATH_LERP "lerp(a, b, value, do_clamp=True, /) -> float\nreturns value linearly interpolated between a and b"
55
#define DOC_MATH_INVLERP "invlerp(a, b, value, /) -> float\nreturns value inverse interpolated between a and b"
66
#define DOC_MATH_SMOOTHSTEP "smoothstep(a, b, value, /) -> float\nreturns value smoothly interpolated between a and b."
7-
#define DOC_MATH_REMAP "remap(i_min, i_max, o_min, o_max, value, /) -> float\nremaps value from i_range to o_range"
7+
#define DOC_MATH_REMAP "remap(i_min, i_max, o_min, o_max, value, /) -> float\nremaps value from given input range to given output range"
88
#define DOC_MATH_VECTOR2 "Vector2() -> Vector2(0, 0)\nVector2(int) -> Vector2\nVector2(float) -> Vector2\nVector2(Vector2) -> Vector2\nVector2(x, y) -> Vector2\nVector2((x, y)) -> Vector2\na 2-Dimensional Vector"
99
#define DOC_MATH_VECTOR2_DOT "dot(Vector2, /) -> float\ncalculates the dot- or scalar-product with the other vector"
1010
#define DOC_MATH_VECTOR2_CROSS "cross(Vector2, /) -> float\ncalculates the cross- or vector-product"

0 commit comments

Comments
 (0)