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 533 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!