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

Fix arc length cost #962

Merged
merged 2 commits into from
Jan 21, 2022
Merged

Fix arc length cost #962

merged 2 commits into from
Jan 21, 2022

Conversation

adam-urbanczyk
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Jan 18, 2022

Codecov Report

Merging #962 (c7d55b6) into master (4fcada6) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #962   +/-   ##
=======================================
  Coverage   96.08%   96.08%           
=======================================
  Files          40       40           
  Lines        9257     9257           
  Branches     1112     1112           
=======================================
  Hits         8895     8895           
  Misses        209      209           
  Partials      153      153           
Impacted Files Coverage Δ
cadquery/occ_impl/sketch_solver.py 91.14% <100.00%> (ø)
tests/test_sketch.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4fcada6...c7d55b6. Read the comment docs.

@jmwright
Copy link
Member

@lorenzncode I requested your review of this PR since you have been closely involved. You can decline if you would rather not.

Copy link
Member

@jmwright jmwright left a comment

Choose a reason for hiding this comment

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

@adam-urbanczyk
Copy link
Member Author

Yes, please do have a look @lorenzncode . The other issue/PR might be more complicated.

Copy link
Member

@lorenzncode lorenzncode left a comment

Choose a reason for hiding this comment

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

I checked out the branch and ran a few manual tests. I did not find any problem with arc length cost.

There may be an issue related to bounds.

s = (
    cq.Sketch()
    .segment((0.3, 0), (0, 0), "seg1")
    .arc((0.0, 0.0), (-0.25, 0.5), (0.0, 1.0), "arc1")
    .constrain("seg1", "Fixed", None)
    .constrain("seg1", "arc1", "Coincident", None)
    .constrain("arc1", "Length", 60)
    .solve()
)

The above which omits Radius and ArcAngle constraints, and with relatively large Length constraint value returns an "entity" with arc angle > 2*pi.

	[ 5.01675398  6.6817405   8.35544592 -2.49756986  7.18094529] (CIRCLE)

The resulting Edge length is ~45 when expected value is 60.

I tried setting an upper bound of 2*pi to arc angle (where currently only the lower bound for radius is set). The result was an Edge with length 60 and entity:

	[16.70179153 19.90442625 25.9833798  -2.44346111  2.30916842] (CIRCLE)

I think the bounds issue can be handled separately from this PR. Looking forward to see how the sketch solver progresses!

@adam-urbanczyk
Copy link
Member Author

@lorenzncode I tried adding ub and lb but I get failures for some test cases. I think this will be a longer story (different solver, different parametrization, ...). In the meantime I'd propose to merge this to fix the obvious bug. @jmwright if you agree, feel free to go ahead with merging.

@jmwright jmwright merged commit fdc5d0f into master Jan 21, 2022
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.

Sketch arc length constraint result incorrect after solve
3 participants