1
\$\begingroup\$

enter image description here

Considering the image above, I want to manually increase the length of a bezier curve control point (C3 to newC3) by a certain value (say 0.5f) while preserving it’s original direction. How can I do this?

\$\endgroup\$
1

1 Answer 1

2
\$\begingroup\$

You normalize the vector "C4_C3" and multiply it by the new length it should have. Subtracting the coordinates of C4 with the coordinates of C3 (or the other way around) gives you the gradient between those two points. Normalizing it scales this gradient down so its length is 1. Multiplying with the new length results in a new gradient that you can add to your C4 coordinates.

normalization:

l = sqrt(x²+y²)
x = x / l; 
y = y / l;

so in total:

x = c4.x - c3.x;
y = c4.y - c3.y;
l = sqrt(x²+y²)

x = c4.x + (x / l) * newLength; 
y = c4.y + (y / l) * newLength;
\$\endgroup\$
0

You must log in to answer this question.

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