Skip to content
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

Add tangentToEnd stdlib function #4541

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add tangentToEnd stdlib function #4541

wants to merge 7 commits into from

Conversation

jtran
Copy link
Collaborator

@jtran jtran commented Nov 21, 2024

Resolves #4403.

We add a function that gets the angle that's tangent to the end of a given segment. This is useful for making a sketch with an arc followed by a line that smoothly follows the arc.

// Horizontal pill.
pillSketch = startSketchOn('XZ')
  |> startProfileAt([0, 0], %)
  |> line([20, 0], %)
  |> tangentialArcToRelative([0, 10], %, $arc1)
  |> angledLine({
    angle: tangentToEnd(arc1),
    length: 20,
  }, %)
  |> tangentialArcToRelative([0, -10], %)
  |> close(%)

pillExtrude = extrude(10, pillSketch)

Copy link

vercel bot commented Nov 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Nov 22, 2024 11:11pm

Copy link

qa-wolf bot commented Nov 21, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 86.00%. Comparing base (79dc537) to head (49e9a02).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/wasm-lib/kcl/src/std/segment.rs 87.09% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4541      +/-   ##
==========================================
+ Coverage   85.96%   86.00%   +0.03%     
==========================================
  Files          81       81              
  Lines       29506    29551      +45     
==========================================
+ Hits        25366    25416      +50     
+ Misses       4140     4135       -5     
Flag Coverage Δ
wasm-lib 86.00% <95.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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


🚨 Try these New Features:

Copy link
Collaborator

@franknoirot franknoirot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is just one case that this doesn't seem to work for me that we should support I think, since we're going the angle utility route: arcTo doesn't return an accurate result:

sketch001 = startSketchOn("XY")
  |> startProfileAt([0, 0], %)
  |> line([5, 0], %)
  |> tangentialArcToRelative([3.14, 2.14], %, $a)
  |> angledLine([segmentTangentialAngle(a), 5], %)
  |> line([-5, 0], %, $b)
  |> angledLine([segmentTangentialAngle(b), 4.07], %)
  |> arcTo({
    end: [10, 10],
    interior: [5.14, 9.14],
  }, %, $c)
  |> angledLine([segmentTangentialAngle(c), 5], %)

Screenshot 2024-11-21 at 4 24 46 PM

It might be worth documenting that:

  1. For straight segments, there is no difference between segAng and segmentTangentialAngle
  2. For tangential arcs, this is getting the tangency angle coming out of the end of the arc. Maybe that's fine to be implicit because the tangency going in would be a previous segment. But in the future with arcTo I could see a use for getting the tangent angle going into the arc.

src/wasm-lib/kcl/src/std/segment.rs Outdated Show resolved Hide resolved
@jtran jtran changed the title Add segmentTangentialAngle stdlib function Add tangentToEnd stdlib function Nov 22, 2024
@jtran jtran force-pushed the jtran/tangential-angle branch 4 times, most recently from 1fa23a8 to 842211d Compare November 22, 2024 20:48
@jtran jtran marked this pull request as ready for review November 22, 2024 20:52
Copy link
Collaborator

@franknoirot franknoirot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just verified I get the expected behavior in local development. Really cool LFG

@adamchalmers
Copy link
Collaborator

Awesome

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.

Need a way to make line after tangential arc tangent to the arc as well
3 participants