Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find x and y coordinates on a flipped circle using javascript methods

I am trying to find the X, Y points on a circle where 0 degrees starts at the top of the circle and moves clockwise. Typically, to find the x, y coordinates on a circle with a known radius and angle you could simply use the formula x = r(cos(degrees‎°)), y = r(sin(degrees‎°)). The circle would look like this and the degrees would expand counterclockwise from 0‎°. enter image description here

However, I am using a circle where the 0‎° starts at the top and the degrees expand as one moves clockwise around the circle. Supposing that var r = 60; and var degrees = 130; what formula could I use (or javascript methods) to determine the X, Y values. Note: I can assume an origin point of 0, 60 because r = 60. Thanks. enter image description here

like image 491
gwydion93 Avatar asked Apr 26 '17 18:04

gwydion93


People also ask

How do you find the x and y coordinates of a circle?

Typically, to find the x, y coordinates on a circle with a known radius and angle you could simply use the formula x = r(cos(degrees‎°)), y = r(sin(degrees‎°)).


1 Answers

As full circle has 2 radiants so you could calculate point coordinates for your circle with following formula:

x = radius * Math.sin(Math.PI * 2 * angle / 360);

y = radius * Math.cos(Math.PI * 2 * angle / 360);

var radius = 60;
var angle  = 140;
var x = radius * Math.sin(Math.PI * 2 * angle / 360);
var y = radius * Math.cos(Math.PI * 2 * angle / 360);
console.log('Points coors are  x='+ 
   Math.round(x * 100) / 100 +', y=' +
   Math.round(y * 100) / 100)
like image 157
MaxZoom Avatar answered Nov 14 '22 22:11

MaxZoom