I have a few points. I need to put those points on a circle and get their coordinates.
function positionX($numItems,$thisNum){
$alpha = 360/$numItems; //
The cos() and sin() functions expect the argument in radians, not in degrees.
Use the deg2rad() function to convert
EDIT
CODE:
function positionX($numItems,$thisNum){
$alpha = 360/$numItems; // angle between the elements
$r = 1000; // radius
$angle = $alpha * $thisNum; // angle for N element
$x = $r * cos(deg2rad($angle)); // X coordinates
return $x;
}
function positionY($numItems,$thisNum){
$alpha = 360/$numItems; // angle between the elements
$r = 1000; // radius
$angle = $alpha * $thisNum; // angle for N element
$y = $r * sin(deg2rad($angle)); // Y coordinates
return $y;
}
echo round(positionX(4,1))."
";
echo round(positionY(4,1))."
";
echo round(positionX(4,2))."
";
echo round(positionY(4,2))."
";
echo round(positionX(4,3))."
";
echo round(positionY(4,3))."
";
echo round(positionX(4,4))."
";
echo round(positionY(4,4))."
";
RESULTS:
0
1000
-1000
0
-0
-1000
1000
-0