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

Vertices get merged unexpectedly #1312

Open
hrj opened this issue Dec 7, 2023 · 5 comments
Open

Vertices get merged unexpectedly #1312

hrj opened this issue Dec 7, 2023 · 5 comments
Labels

Comments

@hrj
Copy link

hrj commented Dec 7, 2023

Expected Behavior

The rectangular slits should retain their shape.

Actual Behavior

The vertices in some of the slits merge, creating triangles instead of rectangular slits.

Steps to Reproduce the Problem

Open the attached file in online editor V 2.6.5.
jsCadError2.txt

Changing the diameter to 51 will remove the bug.

Specifications

  • Version:2.6.5
  • Platform: Firefox
@z3dev
Copy link
Member

z3dev commented Dec 12, 2023

@hrj thanks for the nice example. hopefully, we can sort out the issues, and get you moving again.

i tried the example, and the results definitely change when setting diameter to 50 and 51. i then added a short circuit, returning the 2D objects, and found out that the cbc() function may have some issues with the calculations. Can you double check?

@z3dev
Copy link
Member

z3dev commented Dec 12, 2023

issue

@hrj
Copy link
Author

hrj commented Dec 12, 2023

Thanks for looking @z3dev

I can't notice any error in the cdc function. Those thin rectangles which are getting truncated abnormally are just a simple array of rectangles. The union of those with the other set of polygons (lfChopped) is somehow converting them into unclosed polygons.

Since all polygons are being created through primitives or through boolean operations, I don't think there can be any error in the supplied code, unless I am misusing the API in some way. For example, if I am using union in an unexpected way. But since the code works for a different diameter, I don't think that would be a suspect.

@z3dev
Copy link
Member

z3dev commented Dec 13, 2023

@hrj strange things are happening with the intersect(), so i changed the code a little to...

  cut = subtract(square({size: 10 * radius}), rectangle({ size: chopSize, center: [rb2 + pb4, -rb2-pb4] }))
  const lfChopped = subtract(
    union(lf), cut
  )
  return [verticals, lfChopped]

@hrj
Copy link
Author

hrj commented Dec 14, 2023

@z3dev Thanks, that workaround works :) I am unblocked for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants