Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

anonymous_coward

distance percentage

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

given 3 points, A B and N : we know that N lies upon a straight line between A and B. how do i calculate the percent-distance between A B that N lies (i.e., halfway is 50%)?

Share this post


Link to post
Share on other sites
Advertisement
If you know N lies on the line, calculate
v1 = B-A
v2 = N-A

if (v1.x != 0) percentage = v2.x/v1.x;
else if (v1.y != 0) percentage = v2.y/v1.y;
else percentage = v2.z/v1.z;


Visit our homepage: www.rarebyte.de.st

GA

Share this post


Link to post
Share on other sites
Given

A--N------B

The percentage would be (AN/AB)*100

-------------------
Revolver, aka Brian Smith
MIS Programmer Analyst
brian.smith@realpage.com
RealPage >> www.realpage.com

My views aren't even mine, much less my employers. =)

Share this post


Link to post
Share on other sites

  • 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!