+ 1
how to set the angle between the lines?
Hello! In JS, I built three points on a circle in arbitrary places and drew lines from the center to them. How to make sure that the angle between points and lines is exactly 120 degrees?
2 Respostas
+ 1
You can do that with the sine and cosine functions. Simce there is no information about the circle, I'll make up some: the center of the circle is at (100; 200), and the radius of the circle is 20.
So, the position of the point rotated by 120 degrees is (100 + Math.cos(120 / 180 * Math.PI) * 20; 200 + Math.sin(120 / 180 * Math.PI) * 20)
The first number is the position of the circle, the second is:
f(a / 180 * π) * r
r is the radius of the circle, f is the sine or cosine function (returns number between -1 and 1), a is the angle. Dividing by 180 and multiplying by π is important, because it converts the angle to radians, and these functions work with radians in javascript.
+ 1
Thank you very much for the extended answer, I'm sure that everything will work out according to your algorithm