Archived

This topic is now archived and is closed to further replies.

Swirl

This topic is 5040 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to make a swirl that "swirls". Thing is I don''t know what the formula is for a swirl! By swirl I mean http://www.umszki.hu/~leczb/Graphics/Backgrounds/swirl.jpg . Can''t seem to find a formula for one on google...

Share this post


Link to post
Share on other sites
yeah, but he wants it to swirl, and if he wants it to swirl, it is much simpler (I'm assuming the swirl is going to be in 2D) to just paint a swirl, make 8 or more copies eacy being rotated a little bit, and then just load them into directX and run through each one of the bitmaps on a timer.

EDIT:
Otherwise, if he just wants a function, you will have to take into consideration time, not just 'x'.

[edited by - Dendei on February 20, 2004 3:25:05 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by O_o
f(x)=x(sin(x)^2+cos(x)^2) in polar coordinates.



Well I want to generate that swirl with an algorithm, it actually turning isn''t needed. But that formula always equals x?
sin(x)² + cos(x)² = 1
so f(x) = x( 1 ) = x

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes your right I wasn''t thinking the formula is just f(x)=x in polar coordinates. You have to remember this is polar coordinates. Maybe it would look better if i said r=theta. You then increase theta so you go around in a circle and your radius increases thus you get a ''swirl''. If you want cartisian coordinates x=r*cos(theta) and y=r*sin(theta) but in this case r=theta so x=theta*cos(theta) and y=theta*sin(theta). So to draw a swirl you could done something like this.

Algorthm drawSwirl(xOrigin, yOrigin)
prevX <- xOrigin
prevY <- yOrigin
for theta = 1 to 100 do
x <- theta * cos(theta) + xOrigin
y <- theta * sin(theta) + yOrigin
drawLine(prevX, prevY, x, y)
end do
end

Share this post


Link to post
Share on other sites
Err I messed that last part up.

Algorthm drawSwirl(xOrigin, yOrigin)
prevX <- xOrigin
prevY <- yOrigin
for theta = 1 to 100 do
x <- -(theta * cos(theta)) + xOrigin
y <- -(theta * sin(theta)) + yOrigin
drawLine(prevX, prevY, x, y)
prevX <- x
prevY <- y
end do
end

[edited by - O_o on February 21, 2004 1:05:24 PM]

Share this post


Link to post
Share on other sites
A filter is simply a 2D array that contains specific values. YOu use a math function to somehow combine the filter with the original image to produce an effect; e.g. emboss filter, edge filter, etc. Check out the following: http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=image+filters

Share this post


Link to post
Share on other sites
Swirl is easy. As the angle increases the distance from the origin increases.

for Q = 0 to 359
RADIUS = Q
x = RADIUS*cos(Q)
y = RADIUS*sin(Q)
drawline(x_old, y_old, x, y)
x_old = x
y_old = y
end for

You can play around with this basic algorithm to produce different results. You can have two different radii for x and y. You can make the swirl open up faster by increasing the radius velocity, etc.

--Viktor

Share this post


Link to post
Share on other sites
x = cos(float(time * mK)) * WIDTH_RADIUS;
y = sin(float(time * mK)) * HEIGHT_RADIUS;


something like that might work

mK == varaible to deteramin shape of circle..

[edited by - DevLiquidKnight on February 23, 2004 8:30:04 PM]

Share this post


Link to post
Share on other sites
Looks to me like that image was generated using an accumulation technique, something like the famous "Geiss" visualization for Winamp, etc. In other words, they started with a blank canvas, drew two "swirl"-looking splines on it, blurred it, and then drew another on top, slightly rotated, and in a slightly different color, repeating this for a thousand or so iterations.

Actually, they probably used straight lines (not splines, like I just said) and a "swirl" distortion filter on the image each step... If you look at the corners, the pattern is simply radial.

Share this post


Link to post
Share on other sites
>>A filter is simply a 2D array that contains specific
>>values. YOu use a math function to somehow combine the
>>filter with the original image to produce an effect;
>>e.g. emboss filter, edge filter, etc.

But this kind of "kernel filtering" won''t give you swirls.

To swirl a bitmap, a completely different technique is applied. Dunno if it can be called a filter, because I don''t really know the exact definition of an image filter.

- Mikko

Share this post


Link to post
Share on other sites