Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trig thing with QB: drawing a line with specified angle
#31
Who actually cares if Nath confuses me? Right now I don't know the definition of "Complex number", and I don't think it's necessary to explain it, but when I post about the fact that there are no intrinsic functions to sort arrays to a newbie, how do I know that the only 5 words in his post are the ones he understands, and that I'm wasting my time? Nath posted a perfectly legitimate post.

Anyway, I get the polar coord thing now. But why would I need to convert cartesians to polars and then back again in order to plot the points of a rotated sprite?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#32
You have a set of points in your 2D array. You can easily build a cartesian system for that array, just giving coordinates to each pixel using its array indexes. For example, pixel at sprite%(5,5) will (for example) be x=5, y=5, depending on the "center of rotation" you select (this center (coordinates origin) can be anywhere: that depends on what you want, if you just wanna make the sprite rotate upon itself this "origin" would be in the middle of the sprite).

Now you want to rotate that pixel. So you imagine a coordinates origin somewhere and you need to know the distance to that point and the angle it makes with the horizontal, so you can add your rotation angle and get where the rotated pixel should be. Cartesians -> polars gives you this distance and this angle. To rotate, you just add or substract the rotation angle to the obtained angle. Now you have the distance and a new angle. To know where the new pixel should be, you need to convert from polar to cartesians to get the new x,y so you can actually plot the pixel in its new location.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)