OpenJSCAD.org icon indicating copy to clipboard operation
OpenJSCAD.org copied to clipboard

Vertices get merged unexpectedly

Open hrj opened this issue 2 years ago • 5 comments

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

hrj avatar Dec 07 '23 10:12 hrj

@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 avatar Dec 12 '23 06:12 z3dev

issue

z3dev avatar Dec 12 '23 06:12 z3dev

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.

hrj avatar Dec 12 '23 09:12 hrj

@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]

z3dev avatar Dec 13 '23 06:12 z3dev

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

hrj avatar Dec 14 '23 14:12 hrj