Jump to content
  • Advertisement

Archived

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

m_e_my_self

Swirl

This topic is 5384 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
Advertisement
f(x)=x(sin(x)^2+cos(x)^2) in polar coordinates.





[edited by - O_o on February 20, 2004 2:35:14 PM]

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
I suspect the best method is to render the original to a bitmap, and then run a digital filter on it.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!