All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
  Print view

Calculating angle of rotation
Author Message
PostPosted: Mon Oct 20, 2008 11:12 am 
Offline
Site Admin

Joined: Tue Sep 09, 2008 5:29 pm
Posts: 52
Simple task I did years ago in another language but cannot find the code for it any more :(

when left arrow is pressed I need to reduce the angle so if we start at 0 degree's then pressing left arrow will work back from 359 358 etc and if i press the right arrow it increases the angle so starting at 0 i go 1 2 3 etc.

sounds simple but i'll be damned if i can work it out.

_________________
CDOSYS & CDONTS auto detecting mail function: Mail Function
500.100.asp debug page: Debug Script


Top
 Profile E-mail  
 

Re: Calculating angle of rotation
PostPosted: Mon Oct 20, 2008 12:02 pm 
Offline
New Coder

Joined: Wed Sep 10, 2008 7:35 am
Posts: 2
Code:
const float ROT_PER_STEP_DEGREES = 0.05f;
float m_currentAngle = 0f;

// Whatever left-arrow event handler:
m_currentAngle = ( m_currentAngle - ROT_PER_STEP_DEGREES ) % 360;

// Whatever right-arrow event handler:
m_currentAngle = ( m_currentAngle + ROT_PER_STEP_DEGREES ) % 360;


?


Top
 Profile E-mail  
 

Re: Calculating angle of rotation
PostPosted: Mon Oct 20, 2008 12:08 pm 
Offline
Site Admin

Joined: Tue Sep 09, 2008 5:29 pm
Posts: 52
may work will have to look at it later i'm also considering building in a rotation acceleration routine so short press is short degree move long press is faster/larger movement in same time.

_________________
CDOSYS & CDONTS auto detecting mail function: Mail Function
500.100.asp debug page: Debug Script


Top
 Profile E-mail  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron