#### Archived

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

# sine curve motion

This topic is 5412 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello! I need some help in a program I am making. I want to fix a carousel - you know the kids game with the horses going up and down. My problem is how am I suposed to make the horses move like a sine curve. In the code I''ve writen so far z is the vertical axis ,x tha horizontal kai y the one with direction from me to the screen. Something like that. ^ z | __ y | /| | / | / |/ ------------|---------> x | | |

##### Share on other sites
really all you need to do is calculate the sine for a given angle then apply those coords to your y value.

y = y + ((sin(angle) * radius) - (sin(previousangle) * radius));

previousangle = angle

taking the sin of the current angle minus the sin of the previous angle so handles the ''change over'' of direction

the first time through just set previous angle to the same as angle or handle a 0 & 359 condition.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 11
• 15
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633352
• Total Posts
3011483
• ### Who's Online (See full list)

There are no registered users currently online

×