-
Notifications
You must be signed in to change notification settings - Fork 510
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
V2 : odd result of measureArea() #570
Comments
Please change translateX([len/2], ...) to translateX(len/2, ...) These functions are... translateX( NUMBER, ...objects ) Hope that helps. |
Thank you for your kind reply.
|
@minatani thanks again. there's an issue with the calculation of area, i.e. measureArea() It seems to be related to the Float32Array values, as the results are inconsistent, even after a small fix.
If I switch to Number values then the results are consistent.
|
UG. The number of polygons is totally different as well. Float32Array : 362 polygons This is going to take some time... UG |
I looked into this further. This is an issue with the reTesselateCoplanarPolygons() function. This function is merging/adding polygons to the geometry, and obviously has MAJOR issues if using Float32Array. |
Good news. I wrote a new function called mergeCoplanarPolygons() to replace reTesselateCoplanarPolygons(). After making the switch...
And there are now 470 polygons. FYI, the subtract will produce 498 polygons without some kind of merge/retesselation. |
Thank you for your immediate investigation and fix. |
@minatani The calculation of volumes should be consistent now. Please try the latest version of V2 branch. If resolved then close this issue. |
Confirmed. |
Expected Behavior
An object with area, bounds and volume is located at the position pointed by translate().
Actual Behavior
In some case, an object's area is disappeared by translate() with certain values.
Steps to Reproduce the Problem
The problem can be reproduced by this script.
// V2
const { cuboid, cylinder } = require('@jscad/modeling').primitives
const { translateX, translateY } = require('@jscad/modeling').transforms
const { subtract } = require('@jscad/modeling').booleans
const { measureArea, measureBounds, measureVolume } = require('@jscad/modeling').measurements
const main = () => {
const plateZ=1;
const len=100;
const holeRad=3;
const holeDis=9.5;
let ret;
let binder=translateX([len/2],
cuboid({size: [len, holeDis, plateZ]}));
for (i=holeDis/2; i <=len-holeDis/2; i+=holeDis ) { // punching loose-leaf notebook's holes
binder=subtract(binder, translateX([i],
cylinder({ startRadius: holeRad, endRadius: holeRad, height: plateZ })));
}
for (y=0; y<=3; y+=0.1) {
ret=translateY([y], binder);
console.log(
y pos: ${y}, Area: ${measureArea(ret)}, Bounds: ${measureBounds(ret)}, Volume: ${measureVolume(ret)}\n
)}
return [ ret ]
}
module.exports = { main }
Specifications
The text was updated successfully, but these errors were encountered: