Skip to content
Open
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
22 changes: 21 additions & 1 deletion cadquery/sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
overload,
)

from math import tan, sin, cos, pi, radians, remainder
from math import tan, sin, cos, pi, radians, remainder, sqrt
from itertools import product, chain
from multimethod import multimethod
from typish import instance_of, get_type
Expand Down Expand Up @@ -875,6 +875,26 @@

return self.edge(val, tag, forConstruction)

@arc.register
def arc(
self: T,
p3: Point,
r: Real,
ccw: bool = False,
tag: Optional[str] = None,
forConstruction: bool = False,
) -> T:

p1 = self._endPoint()
z = Vector(0, 0, -1) if ccw else Vector(0, 0, 1)
cord = -Vector(p1) + Vector(p3)
sagitta = r - sqrt(r ** 2 - (cord.Length / 2) ** 2)
p2 = (Vector(p1) + Vector(p3)) / 2 + sagitta * cord.cross(z).normalized()

Check warning on line 892 in cadquery/sketch.py

View check run for this annotation

Codecov / codecov/patch

cadquery/sketch.py#L888-L892

Added lines #L888 - L892 were not covered by tests

val = Edge.makeThreePointArc(Vector(p1), Vector(p2), Vector(p3))

Check warning on line 894 in cadquery/sketch.py

View check run for this annotation

Codecov / codecov/patch

cadquery/sketch.py#L894

Added line #L894 was not covered by tests

return self.edge(val, tag, forConstruction)

Check warning on line 896 in cadquery/sketch.py

View check run for this annotation

Codecov / codecov/patch

cadquery/sketch.py#L896

Added line #L896 was not covered by tests

@arc.register
def arc(
self: T,
Expand Down