-
Notifications
You must be signed in to change notification settings - Fork 520
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
Allow hull() to process listOfPoints3 in addition to path2, geom2 and geom3 #1343
Conversation
New testcase is for "n=5" and "≤ n" in this JSCAD app: |
@Hermann-SW Thanks again. There are many ways to make a cake. I'm thinking that we could offer users more recipes if we reorganize the hull functions slightly. Something like this...
Today, only hull() is available in the API, but I'm thinking that all of these can exposed in the API. And we do the same for 2D hulls as well. @platypii Is this what you were thinking? |
My thought was to leave Personally, my preferred design for this API would actually be something like That being said, this change looks fine, and I appreciate the test @Hermann-SW! I am happy to have this change in whatever form people prefer. |
OK.
I need help then, as I tried to implement that function and dev server stops working.
Test script for "npm run dev":
|
I would do something like this. Also @z3dev what do you think about the name const quickhull = require('../../operations/hulls/quickhull')
const create = require('./create')
const poly3 = require('../poly3')
/**
* Construct a new convex 3D geometry from a list of points.
* @param {Array} listofpoints - list of points to construct convex 3D geometry
* @returns {geom3} a new geometry
* @alias module:modeling/geometries/geom3.createConvex
*/
const fromPointsConvex = (listofpoints) => {
if (!Array.isArray(listofpoints)) {
throw new Error('the given points must be an array')
}
const faces = quickhull(listofpoints, { skipTriangulation: true })
const polygons = faces.map((face) => {
const vertices = face.map((index) => listofpoints[index])
return poly3.create(vertices)
})
return create(polygons)
}
module.exports = createConvex |
All Submissions:
Thank you for your help in advance, much appreciated !