quads icon indicating copy to clipboard operation
quads copied to clipboard

Add fromFunction

Open rreusser opened this issue 9 years ago • 4 comments

I'm not sure if this function logically fits with the rest of the module, but so far 99% of my quad usage is just creating a grid. Sometimes polar, sometimes rectangular, always a pain. This function just plugs [0, 1] x [0, 1] into a function you provide and spits out a simplicial complex with (optional) normals.

Sample usage:

quads.fromFunction((u, v) => [u, u + v], 10, 20)
// => grid with 10x20 quads and corners [0, 0], [1, 1], [0, 1], [1, 2]

No hard feelings if this is best left to a separate module!

rreusser avatar Feb 03 '17 00:02 rreusser

Oops! I meant to include a flag for periodicity in the normal calculation (which is also common and a pain). A bit elaborate, but I think that's the extent of the features needed here. Again, can move elsewhere if desired :)

✅ done!

rreusser avatar Feb 03 '17 01:02 rreusser

I'm starting to think this might be better as a standalone module (if it doesn't exist already). Additional big feature is the ability to compute attributes at the corresponding points or the normal analytically, both of which are a pain in the butt to work out after the fact. Could add that easily, but it starts to feel bloated in its current home.

rreusser avatar Feb 03 '17 02:02 rreusser

Philosophically I want this module to be a collection of useful quad tools, so I don't mind if it grows a bit with some interesting things. I'm having a bit of trouble getting beyond the math speak, but it looks like this would be generating a parametric surface, which is exactly something I want to support. So even if you rip this out and put it in another module, I would probably provide an API entry point to use it.

gregtatum avatar Feb 03 '17 21:02 gregtatum

Sample usage here, just to make things more tangible. u and v both just go from 0 to 1. You plug in a function and get out a quad surface.

screen shot 2017-02-03 at 17 19 22

rreusser avatar Feb 03 '17 22:02 rreusser