[Pather / planner / ports] improve trace_into connection accuracy
This commit is contained in:
parent
e397b3f96e
commit
2b6782c93e
4 changed files with 35 additions and 8 deletions
|
|
@ -32,7 +32,6 @@ from __future__ import annotations
|
|||
from collections.abc import Iterable, Mapping, Sequence
|
||||
from dataclasses import dataclass, replace
|
||||
from itertools import combinations
|
||||
from math import cos, sin
|
||||
from typing import Any, Literal
|
||||
|
||||
import numpy
|
||||
|
|
@ -41,7 +40,7 @@ from numpy.typing import ArrayLike
|
|||
|
||||
from ...error import BuildError, PortError
|
||||
from ...ports import Port
|
||||
from ...utils import PTypeMatch, SupportsBool, ptype_match, ptypes_compatible
|
||||
from ...utils import PTypeMatch, SupportsBool, ptype_match, ptypes_compatible, rotation_matrix_2d
|
||||
from ..tools import (
|
||||
BendOffer,
|
||||
PrimitiveKind,
|
||||
|
|
@ -579,10 +578,11 @@ class Solver:
|
|||
out_port = step.out_port
|
||||
if out_port.rotation is None:
|
||||
raise ToolContractError('Primitive endpoints must have rotation')
|
||||
angle_cos = cos(angle)
|
||||
angle_sin = sin(angle)
|
||||
x += angle_cos * float(out_port.x) - angle_sin * float(out_port.y)
|
||||
y += angle_sin * float(out_port.x) + angle_cos * float(out_port.y)
|
||||
rotation = rotation_matrix_2d(angle)
|
||||
out_x = float(out_port.x)
|
||||
out_y = float(out_port.y)
|
||||
x += rotation[0, 0] * out_x + rotation[0, 1] * out_y
|
||||
y += rotation[1, 0] * out_x + rotation[1, 1] * out_y
|
||||
angle += out_port.rotation + pi
|
||||
ptype = out_port.ptype
|
||||
return Port((x, y), rotation=angle - pi, ptype=ptype)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue