Jump to content
  • Advertisement
Sign in to follow this  
giugio

simple length reduction

This topic is 3078 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

HY.
I'm using opengl for drawing a line and I have a line from point 1(0,0,0) to point 2(10,2,1) i would decrease the length of the line to the 50% .
where i move the second point?
thanks.

Share this post


Link to post
Share on other sites
Advertisement
You move it to the midpoint between the two points, which is the point that has in each coordinate the average of the corresponding numbers in the two points, (5,1,0.5).

Share this post


Link to post
Share on other sites
is the same if i would get the 33 % in a line of two points:
1)10,2,2
2)156,11,3

thanks.
sorry for my math

Share this post


Link to post
Share on other sites

p1 = (0,0,0);
p2 = (10,10,5);

v = p2 - p1;

v = v * 0.5; // <---- 50 %

n = p1 + v; // new position (5,5,2.5)

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!