Jump to content
  • Advertisement
Sign in to follow this  
BeneC

Calculating a vertex along a line of known length

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

Hopefully this should be a simple problem to solve! I have two verticies v1 & v2 which define a 3D line (a line-of-sight). I want the length of the line be constant; so when (for example) the vertex v1 changes, I want to adjust v2 so that the lines length is back to its default value. I can think of a couple of ways of doing this (using the delta value of the line-slope to move the a vertex along it`s length, etc), but this seems very in-elegant, and I`m sure that there is a much better (& simpler!) way of achieving this. I`m sure that I`ll be kicking myself when someone points out the solution, (and folly!), but hey, what are forums for, eh?! Thanks in advance, BenE.

Share this post


Link to post
Share on other sites
Advertisement
Just update v2 by the same quantity you update v1 by.

if v2-v1 = R then (v2+A)-(v1+A)=v2-v1+A-A=v2-v1=R

So:
v1 += some_vector;
v2 += some_vector;

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!