Advertisement

Scale the length of a line rotating around a Vector

Started by May 20, 2012 01:47 AM
1 comment, last by Muzzy A 12 years, 9 months ago
Hi, I'm making a 2D simulation of the solar system, it works PERFECTLY, but I want to be able to zoom in and out of it, (Make the lines smaller), but i can't figure out how to get it to work right.

I attached a picture to show you what's happening, I want the lines to get smaller when i zoom out and bigger when i zoom in

i tried things like this

float Zoom = 1;

if(KeyDown(DOWN)) Zoom -= .1f;
if(KeyDown(UP)) Zoom += .1f

earth.Draw( Position * Zoom );

// But this just offsets the position and rotation completely, as I somewhat expected

/* How would you decrease the length of a line that is rotating around another point? */
I'm not completely sure about how your coordinates are set up, but you should scale the difference vectors from the Sun to the planets. Let P be the position of the planet, S the position of the Sun and z the zoom factor. Then, the final position of the planet at some zoom factor should be something like S + z(P - S).
Advertisement
OK your algorithm works, but it makes everything draw farther than it's supposed to, maybe it's just where i'm implementing it, i'll keep moving stuff around and figure it out. Thanks for the help!

This topic is closed to new replies.

Advertisement