• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

How to calculate how many X/Y pixels to move object around a circle?

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
When a user presses left or right, I would like to have an object move left or right around a circle (not rotating, but actually following the path of a circle). I need to figure out how many pixels on the X and Y axis to move on each step to move around a circle. Is their an easy way to calculate this? The radius of the circle is 50 pixels.
Thanks!
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way would be to keep track of the angle that defines where the user is along the circle. From this angle and the radius of the circle, you can use some trigonometry and algebra to figure out the (x, y) coordinates.

HTH

Layne
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did something in Pascal once to rotate an entire line drawing picture. To calculate the new position for each pixel I converted x,y coordinates to polar, added or subtracted some degrees, and converted back. There were some tricky cases for negatives as I recall. (I was a music major but my dad taught college math for 32 years and got me through some of it.) If you don't want to rotate your image you could use the same technique just to compute a new position for one corner of the image.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic