algorithm - Unity Line Vector Calculation -


let's suppose have 2 position vectors a , b, base line:

g: x = + r*d (d being direction of line)

can sure b lies on g due game generation algorithm. question how can find r?

problem seems result being positive, when calculating length , checking how d fits result positive, , therefore partly correct.

other idea calculate a + r * d = b <=> r = (b - a) / d . unity doesn't allow vector division.

thank in advance help, maybe being stupid @ point. sorry

g result, start point.

  r = (g -a ).magnitude; 

use dot(d, (g-a)) know whether positive or negative.


Comments

Popular posts from this blog

php - Autoloader issue not returning Class -

java - How to put two numbers separated by a space into two different arrays -

python - matplotlib equivalent for Ubuntu servers with no GUI? -