i like to be able to calculate the vector values from object A to destination position. For Example in this image object A to destination B . What will be the x/y positions all the way until it reach distention B. where the x,y origin is in bottom left side enter image description here

  • \$\begingroup\$ Isn't a subtraction of A from B sufficient (Diff = B - A)? Also, the amount of positions between A and B is infinite. What exactly are you trying to do? \$\endgroup\$ – Vaillancourt Jun 3 '17 at 13:12
  • \$\begingroup\$ to calculate the movement from A to B \$\endgroup\$ – user3689 Jun 3 '17 at 14:20
  • 1
    \$\begingroup\$ That's not enough information to give an answer... If you want to move 10% of the distance just scale the vector by 10%. I feel like this question lacks research effort. \$\endgroup\$ – Charanor Jun 3 '17 at 16:02

If you just want the the vector from 'A' to 'B' thats 'C = TargetPos - StartPos = B - A', no matter how they are orientated.

If you want a function to return a position on this line between, that's 'pos(x) = StartPos + (TargetPos - StartPos) * x = A + C * x', where either x is a number between 0 ( lower you would have a point further away from B) or 1 (higher means you went through B and got further).

Most of the time your 'C' gets normalized, so still points in the same direction, but has 'length = 1', so C_n = C / Length of C. . In that case x should be between 0 and 'Lenght of C'.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.