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

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -