Skip to content

Commit

Permalink
Add function to sketch arc given end point and radius
Browse files Browse the repository at this point in the history
  • Loading branch information
spike77453 committed Nov 17, 2024
1 parent a175cb8 commit 40cae35
Showing 1 changed file with 21 additions and 1 deletion.
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 @@ def arc(

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()

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

return self.edge(val, tag, forConstruction)

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

0 comments on commit 40cae35

Please sign in to comment.