1
$\begingroup$

enter image description here

I believe it's an easy math function, but I don't have any idea how to solve it. I have a 2D vector that I want to multiply to a certain length. But I only have the x value of this new location so how do I get the y component of the new location? In other words, I have the vector start and end positions, I also have the new end x value, how to get the y value? Thanks in advance

$\endgroup$

1 Answer 1

1
$\begingroup$

If you're just scaling the length it should just be a "similar triangles" problem. If you have the start and end points, then you can subtract them to get the original x and y vectors. Then if you have the new x, it's all proportional.

x / y = x2 / y2

So rearranging the equation should be

y2 = (x2 * y) / x

$\endgroup$
1
  • $\begingroup$ Thank you Dale, it's working on paper, I'll implement it soon. $\endgroup$
    – Hani Tiby
    Dec 9, 2021 at 18:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .