Welcome to Fractal Forums

Fractal Software => Fragmentarium => Topic started by: Patryk Kizny on November 14, 2015, 03:36:00 PM




Title: Revolve a 2D XY function around Z?
Post by: Patryk Kizny on November 14, 2015, 03:36:00 PM
Hey,

I got a simple maths problem, but can't seem to have brainpower to solve it quickly.

Let's assume we have some function like IQ impulse or so.
(http://iquilezles.org/www/articles/functions/gfx02.png)

Now I want to use it to create a 3D function by revolving the shape around Z (vertical) axis.
So essentially I want to use it as a shape for a lathe object.
(http://help.autodesk.com/cloudhelp/2016/ENU/3DSMax/images/GUID-B50EB946-132D-400C-9831-C0A272C2713F.png)

That should be simple.
Any hints?


Title: Re: Revolve a 2D XY function around Z?
Post by: Patryk Kizny on November 14, 2015, 04:46:00 PM
Nevermind - easier than I thought.
Code:
// Cubic pulse 1D 
float cubicPulse( float c, float w, float x ){
x = abs(x - c);
if(x>w) return 0.0;
x /= w;
return 1.0 - x*x*(3.0-2.0*x);
}

// Cubic pulse 2D
float cubicPulse2D(vec2 z, vec2 c, float w, float o){
z = abs(z+c);
float r = length(z);
float h = cubicPulse(o, w, r);
return h;
}


Title: Re: Revolve a 2D XY function around Z?
Post by: Patryk Kizny on November 14, 2015, 07:01:39 PM
So the above works, but I have no idea how can I scale it non-uniformly, so that it gives me an elongated shape based on the vec2 w scales.