已知条件:圆点坐标(x0,y0),半径r,角度degree
计算:
Math.sin(x) x的正弦值,返回值在-1.0到1.0之间;
Math.cos(x) x的余弦值,返回值在-1.0到1.0之间;
x弧度的计算公式为,2*PI/360*degree
小球圆形运动轨迹:
计算:
Math.sin(x) x的正弦值,返回值在-1.0到1.0之间;
Math.cos(x) x的余弦值,返回值在-1.0到1.0之间;
x弧度的计算公式为,2*PI/360*degree
小球圆形运动轨迹:
<style>
#wrap{position: relative;margin:40px auto;width: 400px;height: 400px;border:1px solid #eee;border-radius: 50%;}
.ball{position: absolute;top:191px;left:-9px;width:6px;height: 6px;border:6px solid #f60;border-radius:50%;background:#f60;}
</style>
<div id="wrap">
<div class="ball"></div>
</div>
<script>
var ball = document.querySelector(".ball");
var timer ;
var x0=191,y0=191,r=200,degree=0;
timer = setInterval(function () {
degree++;
var hudu = 2*Math.PI/360*degree;
var x1 = x0 + Math.sin(hudu)*r;
var y1 = y0 - Math.cos(hudu)*r;
ball.style.left = x1 +"px";
ball.style.top = y1 + "px";
},50)
</script>
秒针轨迹生成:
<div id="wrap">
<p class="seconds"></p>
</div>
<script>
var ball = document.querySelector(".ball");
var timer ;
var seconds = document.querySelector(".seconds");
var x0=191,y0=191,r=200,degree=0,str = "";
function create() {
for(var times=0;times<60;times++){
var hudu = 2*Math.PI/360*6*times;
var x1 = x0 + Math.sin(hudu)*r;
var y1 = y0 - Math.cos(hudu)*r;
str +="<span style='left:"+x1+"px;top:"+y1+"px;'></span>";
}
seconds.innerHTML = str;
}
create();
</script>
发散:如果有两个或三个圆,已知各圆点坐标、半径,求交叉点坐标??