Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cadquery/occ_impl/nurbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def isoline(self, param: float, dir: Literal["u", "v"] = "u") -> Curve:
@njiti
def _preprocess(
u: Array, order: int, knots: Array, periodic: bool
) -> Tuple[Array, Array, Optional[int], Optional[int], int]:
) -> Tuple[Array, Array, int, int, int]:
"""
Helper for handling periodicity. This function extends the knot vector,
wraps the parameters and calculates the delta span.
Expand Down
5 changes: 4 additions & 1 deletion cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2357,7 +2357,10 @@ def normal(self: Mixin1DProtocol) -> Vector:

if isinstance(surf, Geom_Plane):
pln = surf.Pln()
rv = Vector(pln.Axis().Direction())
direction = (
pln.Axis().Direction().Transformed(fs.Location().Transformation())
)
rv = Vector(direction)
else:
raise ValueError("Normal not defined")

Expand Down
14 changes: 14 additions & 0 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4934,6 +4934,20 @@ def testNormal(self):

self.assertTupleAlmostEquals(n.toTuple(), (0, 0, 1), 6)

located_circle = face(circle(1)).wire().move(y=3, ry=90)

assert located_circle.normal().toTuple() == approx((1, 0, 0))
assert located_circle.edge().normal().toTuple() == approx((1, 0, 0))

located_ellipse = face(ellipse(2, 1)).wire().move(y=3, ry=90)

assert located_ellipse.normal().toTuple() == approx((1, 0, 0))
assert located_ellipse.edge().normal().toTuple() == approx((1, 0, 0))

located_rectangle = plane(2, 2).wire().move(y=3, ry=90)

assert located_rectangle.normal().toTuple() == approx((1, 0, 0))

with self.assertRaises(ValueError):
edge = Workplane().rect(1, 2).edges().val()
n = edge.normal()
Expand Down