Skip to content

Add arc, bezier and helix free functions - #2131

Open
DavidMStraub wants to merge 1 commit into
CadQuery:masterfrom
DavidMStraub:free-func-curves
Open

DavidMStraub wants to merge 1 commit into
CadQuery:masterfrom
DavidMStraub:free-func-curves

Conversation

@DavidMStraub

Copy link
Copy Markdown
Contributor

Adds free functions for curves that were previously only available as Edge/Wire classmethods, as discussed in #2126.

arc(p1, p2, p3)                    # through three points
arc(p1, p2, tangent=t)             # tangent at p1
circle(r, start=0, end=360)        # full circle or arc (degrees)
bezier(*pts)
helix(pitch, height, radius, lefthand=False)

Why this differs from the discussion

The discussion proposed arc(r, a1, a2) as a third arc overload. multimethod only dispatches on positional types, so keyword calls (arc(r=1, ...)) and missing arguments failed with an opaque DispatchError. Instead, arc is a plain function for the point-based arcs, and arcs from radius and angles go to circle(r, start, end), mirroring Edge.makeCircle(radius, angle1=, angle2=).

Decisions to review

  • arc(p1, p2, p3) and arc(p1, p2, tangent=t) as one plain function; exactly one of p3/tangent is required
  • circle(r, start=0, end=360): degrees, counterclockwise, start < end <= start + 360
  • helix(pitch, height, radius, lefthand=False): radius (like circle), not diameter (like cylinder); full-word argument names; returns an Edge, not a Wire
  • No conical helix yet
  • Inputs are validated with explicit ValueError/TypeError (collinear or coincident points, zero or parallel tangent, non-positive sizes, invalid angle ranges). circle(0) now raises instead of returning a degenerate edge
  • ellipse is unchanged: its angles would be parametric rather than polar, so partial ellipses are left out for now

- arc(p1, p2, p3) and arc(p1, p2, tangent=t)
- circle(r, start, end) for arcs from angles
- bezier(*pts)
- helix(pitch, height, radius, lefthand=False)
- validate inputs with explicit ValueError/TypeError
@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.85%. Comparing base (477d87d) to head (397d2f2).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2131      +/-   ##
==========================================
+ Coverage   95.81%   95.85%   +0.03%     
==========================================
  Files          30       30              
  Lines        9605     9642      +37     
  Branches     1443     1456      +13     
==========================================
+ Hits         9203     9242      +39     
+ Misses        247      246       -1     
+ Partials      155      154       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants