0
我想计算圆周的坐标。 我无法得到它打印的坐标,我不确定它是否计算它们。 我的代码:用JQuery迭代和打印坐标
HTML:
<p>Here is the coordinates: </p>
JS:
#screen size will use screen.width and screen.height later
var sW = 1920;
var sH = 1080;
#Two arrays with the coordinates stored in them
var XcircleCoordinates;
var YcircleCoordinates;
#rows should be rows in database. I will use php to get the information, but assume 4 for now.
var rows = 4;
#radius and center of circle.
var radius = 200;
var center = [sW/2,sH/2];
function xCord(i){
XcircleCoordinates[i] = radius*Math.cos((2.0*Math.PI*i)/rows)+center[0];
return XcircleCoordinates[i];
}
function yCord(i){
YcircleCoordinates[i] = radius*Math.sin((2.0*Math.PI*i)/rows)+center[1];
return YcircleCoordinates[i];
}
for (var i = 0; i < 10; i++){
$('p').prepend(xCord(i));
}
它仍然不会写任何东西。 对jQuery来说太复杂了吗? 我是否需要将xCord(i)作为字符串传递? – Artmole 2014-11-04 09:26:29
我将其更改为代码段。这行得通。 – 2014-11-04 09:34:28