Not familiar with the forums, excuse my title. I am trying to calculate an appropriate viewport angle based off an entities position on a sphere. I am attempting to create a game with multiple planets and appropriate gravity simulation for the players interacting with these planets. The simulated gravity is completed, its not a tough task, things work fine. However I can not for the life of me get proper view angles for the clients viewport. I am taking the planets position, the clients position (on this planet), and crossing those two vectors to get the perpendicular angle(which in theory should be the horizon of the planet?) And it works!... to a degree... When I enter different quadrants of this sphere, things start getting wonky. I have no real education in trigonometry, just learned a couple little things here and there for projects. However I feel like this is a (possibly simple)trigonometry issue that I can not overcome. I have tried hours and multiple days trying to research and solve my issue but I just can't manage. Maye you guys can give me a hand. Thanks you!
found you
Well there's certainly some math to figure out here, sorry if I'm not knowledgable in that area but I couldn't exactly find what you were looking for through google. But it would be good to know what language you are trying to do this in, and is it for the computer or one of the calculators?
The client's position relative to the planet (client's absolute position minus planet's position) is perpendicular to the planet's surface. Any vector perpendicular to that is directed along the surface, & these span a plane. If you want a specific such vector, you need some way to narrow it down. Making it a unit vector removes one degree of freedom, but there is still an angular degree of freedom, corresponding to the possibility of the client turning in a circle.

If you already have a direction the client is facing & want to project it onto the sphere, that can be done, but not using a cross product. To project U into the plane perpendicular to V, you want U-((U⋅V)/(|U|*|V|))*V, which is U minus the projection of U onto V.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
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 vote in polls in this forum