wip
This commit is contained in:
parent
f7902fa517
commit
d9ae8dd6e3
3 changed files with 149 additions and 443 deletions
|
|
@ -11,6 +11,6 @@ from .bitwise import get_bit, set_bit
|
|||
from .vertices import (
|
||||
remove_duplicate_vertices, remove_colinear_vertices, poly_contains_points
|
||||
)
|
||||
from .transform import rotation_matrix_2d, normalize_mirror
|
||||
from .transform import rotation_matrix_2d, normalize_mirror, rotate_offsets_around
|
||||
|
||||
#from . import pack2d
|
||||
|
|
|
|||
|
|
@ -38,3 +38,17 @@ def normalize_mirror(mirrored: Sequence[bool]) -> Tuple[bool, float]:
|
|||
mirror_x = (mirrored_x != mirrored_y) # XOR
|
||||
angle = numpy.pi if mirrored_y else 0
|
||||
return mirror_x, angle
|
||||
|
||||
|
||||
def rotate_offsets_around(
|
||||
offsets: NDArray[numpy.float64],
|
||||
pivot: NDArray[numpy.float64],
|
||||
angle: float,
|
||||
) -> NDArray[numpy.float64]:
|
||||
"""
|
||||
Rotates offsets around a pivot point.
|
||||
"""
|
||||
offsets -= pivot
|
||||
offsets[:] = (rotation_matrix_2d(angle) @ offsets.T).T
|
||||
offsets += pivot
|
||||
return offsets
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ def poly_contains_points(
|
|||
vertices = numpy.array(vertices, copy=False)
|
||||
|
||||
if points.size == 0:
|
||||
return numpy.zeros(0)
|
||||
return numpy.zeros(0, dtype=numpy.int8)
|
||||
|
||||
min_bounds = numpy.min(vertices, axis=0)[None, :]
|
||||
max_bounds = numpy.max(vertices, axis=0)[None, :]
|
||||
|
|
|
|||
Loading…
Reference in a new issue