Skip to content

bug in simple "substract() #1439

@hrgdavor

Description

@hrgdavor

Initially reported at: hrgdavor/jscadui#142

code example shows a cylinder "c" and a cuboid with skew borders "d" with nonempty intersection:

const jscad = require('@jscad/modeling')
const { polygon } = jscad.primitives
const { cylinder } = jscad.primitives
const { translate, mirror, rotate } = require('@jscad/modeling').transforms
const { extrudeLinear } = require('@jscad/modeling').extrusions
const { subtract } = require('@jscad/modeling').booleans

const d1=86
const d2=87
const h=2

function main() {
  const p=polygon({points: [[0,0],[d1/2,0],[d2/2,h],[0,h]]})
  const e=extrudeLinear({height:d1},p)
  const et=translate([0,0,-d1/2],e)
  const P=[et,mirror({normal:[1,0,0]}, et)]
  const d=[P,rotate([0,Math.PI/2,0],P)]
  const c=translate([0,h/2,0],rotate([Math.PI/2,0,0],cylinder({height:2*h, radius:0.4*d1})))
  
  return [
    //d,c 
    subtract(d,c)
  ]
}

module.exports = { main }
Image

Now subtracting "d" from "c" gives expected results:

Image

But subtracting "c" from "d" does not result in the intended "d" with circular hole:

Image

Until now "subtract()" was very reliable over the past years ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions