Jump to content
  • Advertisement
Sign in to follow this  
caymanbruce

Algorithm What is the mathematical explanation behind this implementation of simulating eyeballs roll in eyes?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to simulate eyeballs roll in eyes and I have found and forked this implementation in codepen.io. This is exactly what I need.

 

Smart way but I don't understand why it needs to work like this way. Why is it using `ratioX` and `ratioY` which are calculated from dividing `mouseX` and `mouseY` with their sum?  Is there a simpler or even cleverer way to do similar simulation?

Edited by caymanbruce

Share this post


Link to post
Share on other sites
Advertisement

I think they are using the x/y ratio as a cheap way to do fake trigonometry. If the mouse is far away from the eyes, they should rotate slower. If the mouse is close to the eyes, it will rotate faster. That would happen naturally with sin/cos. So I think what they have is already pretty simple and clever.

Edited by missionctrl

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!