Skip to content

Add Tangent objects for Point and Arc #947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 16, 2025
Merged

Conversation

jwagenet
Copy link
Contributor

Adding a batch of tangent objects to create tangent arcs and lines between arcs and arcs and points. Please scrutinize my style and the tests I added (which are fairly extensive).

New Objects

PointArcTangentLine
PointArcTangentArc
ArcArcTangnetLine
ArcArcTangentArc

image

Shortcomings

  • The arc objects should be able to find tangents when the start point/arc is overlapping or inside, but I neglected to consider these cases until recently, so they are NotImplemented for now
  • I suspect py solvespace could probably replace the internals of these objects, but that is out of scope for now.

Open questions

  • Is there a preference for whether a tangent object should be found anywhere on a complete arc or only if the tangent is coincident with the supplied, trimmed arc(s)?
  • Although they are 1d objects, I wonder if these objects should be defined/tested/documented separately for organization since they work differently than other 1d objects. This would include DoubleTangentArc and other tangent objects Id like to make based on lines.
  • Any changes to naming

Side vs Keep

  • As incompletely discussed on discord, I am using Side.LEFT/RIGHT to pick starting side for all objects, and using Keep.INSIDE/OUTSIDE for the ArcArc objects.
  • Using Side is a departure from `Keep.TOP/BOTTOM' in DoubleTangentArc, so I am open to discussing alternatives.
  • Extending ArcArcTangentArc for overlapping arcs would increase the possible tangents to 8 so some solution will be necessary

Sympy

  • I am using sympy to find intersections due to OCP intersection methods not working well as implemented.
  • Only ArcArcTangentArc uses sympy as committed. Finds circle intersections.
  • I ditched sympy and increased the minimize max_size on PointArcTangentArc (based on DoubleTangentArc). For some reason sympy is 4 - 10 times slower than using the minimizer, even if the minimizer fails at a larger size. Would use circle and line intersections
  • Something I hadn't considered until writing this up is to precalculate intersections symbolically and substitute at runtime. Based on light testing this would be about 10x faster, but to be determined how to store symbolic solutions.
  • I do want to be cognizant about adding a new dependency in light of Use lazy imports in topology to speed up library import. #942.

These are pretty extensive, but not exhaustive. Testing once in algebraic mode with a tangency/coincident checks, testing on at a few different start points, comparing lengths to first test and L/R INSIDE/OUTSIDE output, finally do error checks locally.
Copy link

codecov bot commented Mar 23, 2025

Codecov Report

Attention: Patch coverage is 95.42857% with 8 lines in your changes missing coverage. Please review.

Project coverage is 96.91%. Comparing base (518d773) to head (0d5aa13).
Report is 36 commits behind head on dev.

Files with missing lines Patch % Lines
src/build123d/objects_curve.py 95.42% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #947      +/-   ##
==========================================
- Coverage   96.93%   96.91%   -0.03%     
==========================================
  Files          32       32              
  Lines        9470     9656     +186     
==========================================
+ Hits         9180     9358     +178     
- Misses        290      298       +8     

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jwagenet
Copy link
Contributor Author

Merging with dev + mypy/pyline/black still needs to be done.

@jwagenet jwagenet changed the title Add Tangent objects for PointAt Add Tangent objects for Point and Arc Mar 26, 2025
@gumyr
Copy link
Owner

gumyr commented Mar 27, 2025

At first glance these look great but it will be a few days before I have the time to review them in detail.

@jwagenet
Copy link
Contributor Author

No problem (I think) this is a complicated addition and I'd want to make sure it fits with the project goals.

@gumyr
Copy link
Owner

gumyr commented Apr 9, 2025

This looks like some excellent work and welcome additions to build123d. I don't really have any substantial input to what you've done here other than to fix up the type checking and code coverage failures.

As for naming and design choices like Side vs. Keep how about we get some feedback from the community on this after it has been merged? I don't think we have enough content to do a release for a little while so we have some time to explore what is best - even if that is changing DoubleTangentArc to align with the new direction.

Thanks again!

@jwagenet jwagenet marked this pull request as ready for review April 15, 2025 18:18
@jwagenet
Copy link
Contributor Author

I've marked this for review, but there are codecov errors I don't understand (at least the ones highlighting comments).

@gumyr
Copy link
Owner

gumyr commented Apr 15, 2025

The code coverage errors don't make sense; there is at least one comment that doesn't have coverage. How about we merge this code and see what's what?

@jwagenet
Copy link
Contributor Author

Sure, that's fine with me.

@gumyr gumyr merged commit b03fa9a into gumyr:dev Apr 16, 2025
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants