Skip to content

Commit 68e08fa

Browse files
committed
Add function to sketch arc given end point and radius
1 parent a175cb8 commit 68e08fa

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

cadquery/sketch.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
overload,
1616
)
1717

18-
from math import tan, sin, cos, pi, radians, remainder
18+
from math import tan, sin, cos, pi, radians, remainder, sqrt
1919
from itertools import product, chain
2020
from multimethod import multimethod
2121
from typish import instance_of, get_type
@@ -875,6 +875,26 @@ def arc(
875875

876876
return self.edge(val, tag, forConstruction)
877877

878+
@arc.register
879+
def arc(
880+
self: T,
881+
p3: Point,
882+
r: Real,
883+
ccw: bool = False,
884+
tag: Optional[str] = None,
885+
forConstruction: bool = False,
886+
) -> T:
887+
888+
p1 = self._endPoint()
889+
z = Vector(0, 0, -1) if ccw else Vector(0, 0, 1)
890+
cord = -Vector(p1) + Vector(p3)
891+
sagitta = r - sqrt(r ** 2 - (cord.Length / 2) ** 2)
892+
p2 = (Vector(p1) + Vector(p3)) / 2 + sagitta * cord.cross(z).normalized()
893+
894+
val = Edge.makeThreePointArc(Vector(p1), Vector(p2), Vector(p3))
895+
896+
return self.edge(val, tag, forConstruction)
897+
878898
@arc.register
879899
def arc(
880900
self: T,

0 commit comments

Comments
 (0)