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

[geom] fitIntoBounds3 #202

Closed
nkint opened this issue Feb 15, 2020 · 2 comments
Closed

[geom] fitIntoBounds3 #202

nkint opened this issue Feb 15, 2020 · 2 comments

Comments

@nkint
Copy link
Contributor

nkint commented Feb 15, 2020

Hi!
This is a kind of feature request, I'd like to have fitIntoBounds3 as we have fitIntoBounds2 for 2d IShape but for 3d Vec[].

I've tried to implement it by myself and it seems to work well with some 3d random mesh (an icosahedron) but not working for some dumb test points.

Here is the gist. Any help/hint is really appreciated.

@postspectacular
Copy link
Member

@nkint I've taken your gist and put it in a codesandbox here. Also fixed it and added some comments. The main issue is a division-by-zero case when all input points are planar (i.e. at least one dimension of the source bounding box size is zero). I've added a safeDiv() helper fn, which should be added to thi.ng/math and the same fix should also be applied to the existing 2d version... The other comment left in the code is about your result assumption and hope it makes sense...

@postspectacular
Copy link
Member

Just for future reference: Fixed now and added notes here: #206 (comment)

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

Successfully merging a pull request may close this issue.

2 participants