New Pattern: Geometry Morphing Demo 2D

Nah, you’ve over complicated it.

As I pulled out in Rotation functions?, you just need two lines.

If you modify the function to be
f(x,y,size,theta aka angle of rotation),
You still have to compute the sin/cos of the same angle repeatedly. So cache those two sin(theta) and cos(theta) in the shape array?

Make a SDFrotate(shapearray pointer, theta)
And add precomputes there.

Added: turns out to be even easier, see code below. No changes to SDF functions needed. I added a theta to the shape array details, so each is unique…

(Or elsewhere). Or maybe do just compute it if that’s faster than pulling from an array or whatever you else use to store it. Whatever’s the least work.

You don’t need to recalc it back.

You are looking thru all points and deciding for each point, “are you a member of shape N”?

Feeding in those X,Y coords to each shape function… You are passing px,py,size…ox,oy are the shapes center which you have. Either store theta of the shape, or sin+cos, and you have it all.
Now you have to just add the point rotation lines above to your SDF which gives you new X,Ys relative to center, and then you run the rest of your SDF. And normal there after.
No need to reverse at all. You’ve not changed a thing permanently.

done: Rotation functions? - #4 by Scruffynerf

1 Like