Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2d rotation
#1
Hi and Merry Xmas everybody!
I'm lookin for a tut on how fast 2d sprite rotation works. I know there are diffrent algorithms, but anything you got to get me started is appriciated.
I did find a article on gamedev.net:
http://www.gamedev.net/reference/article...cle811.asp
but on rotation i need it to be a little more explaining.

I hope anyone has what i'm lookin for..

/Basta
ttp://hem.passagen.se/qb.basta
Reply
#2
Well, my suggestion is first learn some Grade 10 or 11 math.
Then...if you're talking about QB, read Vic Luce's tutorials on 2D and 3D rotation. You can find em' at Qbasicnews.com.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#3
The math i know.. I'm 18 don't know what grade i'm in if i was livin' in the states, but anyway i have read all math courses there is.. Math A to Math F.. Vic's i already understand, however I asked for 2d bitmap rotation and that's a diffrent thing..
If you check the link a posted you'll see.. I'm lookin for a tut that takes one of the algorithmes from the link or another algorithm and explains it more thoroughly..
ttp://hem.passagen.se/qb.basta
Reply
#4
Can't help you there, mate. :o
I'm only twelve, I never understood the math, I just used the equations. :wink:
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#5
well, how far do you want it to rotate? if you want it to rotate 90, 180, or 270 degrees, then you cant use matrix rotation (geometry). If you want rotation to any angle, then the only way I know is to create points, rotate the points with sin/cos, and draw the points. can't help you with a bitmap.
url=http://webberboy.no-ip.com]Fine Hand-Crafted Pens[/url]
Pneumonoultramicroscopicsilicovolcanoconiosis: Noun, A hypothetical, invented disease of the lungs, caused by inhaling mineral or metallic dust, such as silicon and quartzite, over a long period.]
Reply
#6
Well, basicly you take each point, convert its coordinates from cartesian (x, y) to polar (radius, angle), rotate them, convert again to cartesian, and draw the pixel in the new position.

This has a problem: some gaps may appear (black points) 'cause pixel positions are integer and the result will always be float. The trick is to do it in reverse order. Knowing the angle, for each pixel to calculate in the destination sprite, you try to "undo" the above sequence until you get to the original, un-rotated location, grab the colour and put it in the destination sprite, this is, for each point in the destination sprite (xd, yd) calculate their polar coordinates (radiusd, angled), substract the rotation angle (this is: rotate in the oposite direction) to get the original pixel polar coordinates (radiusi = radiusd, anglei = angled - rotationAngle) and the obtain its cartesian coordinates (xi, yi). Check the colour in the (xi, yi) position of the original sprite, and write it to (xd, yd) in the destination sprite.

Scalling can be done at the same time: you just multiply "radiusd" by 1/scale, when scale = 1 then no scaling is done.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#7
http://www.ocf.berkeley.edu/~horie/qbrotate.html

Straight from Toshi the uni student, code samples (for qb) and diagrams with in depth description.
Reply
#8
Exactly what i needed Nexinarus! Thx alot :bounce:
ttp://hem.passagen.se/qb.basta
Reply
#9
Nuts... Nexinarus beat me to it! :evil:
Jumping Jahoolipers!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)