'React - calculate dots position in a circle
Solution 1:[1]
You could use the following functions to get X and Y coords
Example for a circle with 100 px radius:
function getCircleY(radians, radius) {
return Math.sin(radians) * radius;
}
function getCircleX(radians, radius) {
return Math.cos(radians) * radius;
}
console.log("Y coord at 0 degree", getCircleY(0, 100));
console.log("X coord at 0 degree", getCircleX(0, 100));
console.log("Y coord at 180 degree", getCircleY(Math.PI, 100));
console.log("X coord at 180 degree", getCircleX(Math.PI, 100));
Check this out https://en.wikipedia.org/wiki/Radian
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

