Skip to content
Advertisement

Tag: trigonometry

D3js find closest point on circle

what I’m trying to achieve is to take the current coordinates of a mousemove event and match them with the coordinates of the closest location on a circle. I’ve managed to get this partially working using a for loop which iterates over each possible point in the circle and compares the coordinates in order to find the closest point: the

How to calculate rotation in 2D in Javascript

I am not so familiar trigonometry, but I have only two points to rotate in 2D: cx, cy = rotation center x,y = current x,y nx, ny = new coordinates How to calculate new points in a certain angle? Answer The first two parameters are the X and Y coordinates of the central point (the origin around which the second

Advertisement