Skip to content

Commit

Permalink
v1.5.2: Fix incorrect docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
shBLOCK committed Apr 7, 2024
1 parent bc14e95 commit 77209eb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
15 changes: 12 additions & 3 deletions codegen/templates/transform_2d.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,21 @@ cdef class Transform2D:
return self.tdoty(x, y) + self.oy

def __mul__(self, Vec2 other) -> Vec2:
"""Transform a copy of the vector."""
"""Transform a copy of the vector.

See Also: `Vec2.__mul__()`
"""
cdef Vec2 vec = Vec2.__new__(Vec2)
vec.x = self.mulx(other.x, other.y)
vec.y = self.muly(other.x, other.y)
return vec

#<OVERLOAD>
cdef inline Vec2 __call__(self, Vec2 other):
"""Transform a copy of the vector."""
"""Transform a copy of the vector.
See Also: `Vec2.__mul__()`
"""
cdef Vec2 vec = Vec2.__new__(Vec2)
vec.x = self.mulx(other.x, other.y)
vec.y = self.muly(other.x, other.y)
Expand Down Expand Up @@ -316,7 +322,10 @@ cdef class Transform2D:
return self._determinant()

def __invert__(self) -> Transform2D:
"""Get the invert transform."""
"""Get the invert transform.

See Also: `Vec2.__mul__()`
"""
cdef py_float i_det = 1.0 / self._determinant()
cdef Transform2D t = Transform2D.__new__(Transform2D)
t.xx = self.yy * +i_det
Expand Down
15 changes: 12 additions & 3 deletions codegen/templates/transform_3d.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,10 @@ cdef class Transform3D:
return self.tdotz(x, y, z) + self.oz

def __mul__(self, Vec3 other) -> Vec3:
"""Transform a copy of the vector."""
"""Transform a copy of the vector.

See Also: `Vec3.__mul__()`
"""
cdef Vec3 vec = Vec3.__new__(Vec3)
vec.x = self.mulx(other.x, other.y, other.z)
vec.y = self.muly(other.x, other.y, other.z)
Expand All @@ -374,7 +377,10 @@ cdef class Transform3D:

#<OVERLOAD>
cdef inline Vec3 __call__(self, Vec3 other):
"""Transform a copy of the vector."""
"""Transform a copy of the vector.
See Also: `Vec3.__mul__()`
"""
cdef Vec3 vec = Vec3.__new__(Vec3)
vec.x = self.mulx(other.x, other.y, other.z)
vec.y = self.muly(other.x, other.y, other.z)
Expand Down Expand Up @@ -450,7 +456,10 @@ cdef class Transform3D:
return self._determinant()

def __invert__(self) -> Transform3D:
"""Get the invert transform."""
"""Get the invert transform.

See Also: `Vec3.__mul__()`
"""
cdef py_float cox = self.yy * self.zz - self.yz * self.zy
cdef py_float coy = self.xz * self.zy - self.xy * self.zz
cdef py_float coz = self.xy * self.yz - self.yy * self.xz
Expand Down
16 changes: 14 additions & 2 deletions codegen/templates/vec_class.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ cdef class _VecClassName_:
#<IF>: _Dims_ == 2
#<OVERLOAD>
cdef inline Vec2 __mul__(self, Transform2D t):
"""Transform a copy of this vector using the `Transform2D`."""
"""Transform a copy of this vector using the *INVERSE* of the transform.
Use `transform * vector` or `transform(vector)` for non-inverse transformation.
See Also:
`Transform2D.__mul__()`
`Transform2D.__call__()`
"""
cdef Vec2 vec = Vec2.__new__(Vec2)
cdef py_float x = self.x - t.ox
cdef py_float y = self.y - t.oy
Expand All @@ -132,7 +138,13 @@ cdef class _VecClassName_:
#<IF>: _Dims_ == 3
#<OVERLOAD>
cdef inline Vec3 __mul__(self, Transform3D t):
"""Transform a copy of this vector using the `Transform3D`."""
"""Transform a copy of this vector using the *INVERSE* of the transform.
Use `transform * vector` or `transform(vector)` for non-inverse transformation.
See Also:
`Transform3D.__mul__()`
`Transform3D.__call__()`
"""
cdef Vec3 vec = Vec3.__new__(Vec3)
cdef py_float x = self.x - t.ox
cdef py_float y = self.y - t.oy
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = ["setuptools", "cython"]

[project]
name = "gdmath"
version = "1.5.1"
version = "1.5.2"
description = "GdMath: a fast math library for game development"
readme = "README.md"
requires-python = ">= 3.9"
Expand Down

0 comments on commit 77209eb

Please sign in to comment.