2
\$\begingroup\$

I'm not very familiar with libgdx vectors. I want to create my own joystick-controller and I want to know how can I find the coordinates of B by using Vectors. I can calculate the radius and I have the center. enter image description here

Thank you.

\$\endgroup\$
2
\$\begingroup\$

Imagine the radius is one. That means every point around the circle is exactly one unit away from the center. Now what kind of vectors always have a length of one? Unit vectors of course. You can get a unit vector by normalizing a non-unit vector.

Take the vector CA (center to A). Next, normalize CA to make it a unit vector, then scale it by the radius of your circle, to get vector CB. Finally, add CB to your center coordinates to get the coordinates of B.

B = Normalize(APos - CenterPos) * Radius
BPos = CenterPos + B
\$\endgroup\$

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.