<meta charset="utf-8" />
<script src="http://spelprogrammering.nu/simple.js">
function start()
{
theAngle = 0;
}
function update()
{
fill("white");
math.axes();
math.unitCircle();
if (theAngle > 2*pi)
theAngle = 0;
niceXLabel = cos(theAngle)>0 ?
ceil(cos(theAngle)*100.0)/100.0 :
floor(cos(theAngle)*100.0)/100.0;
niceYLabel = sin(theAngle)>0 ?
ceil(sin(theAngle)*100.0)/100.0 :
floor(sin(theAngle)*100.0)/100.0;
niceLabelX = "x = " + niceXLabel;
niceLabelY = "y = " + niceYLabel;
math.line(0 ,0, cos(theAngle), sin(theAngle), "#dd2222");
math.arcRadians(0.2, theAngle, 1, "brown");
math.point(cos(theAngle), sin(theAngle), 4, "black");
math.point(cos(theAngle), sin(theAngle)+0.2, 0, "black", niceLabelX);
math.point(cos(theAngle), sin(theAngle), 0, "black", niceLabelY);
theAngle += 0.01;
deg = floor(theAngle*180/pi*100)/100;
rad = floor(theAngle*100/pi)/100;
math.text(1, 2, 30, "Radianer: "+rad+"π", "black");
math.text(1, 1.5, 30, "Grader: "+deg+"°", "black");
math.text(-3, 2, 30, "x = cos("+rad+"π)", "black");
math.text(-3, 1.5, 30, "y = sin("+rad+"π)", "black");
}
</script>
Gå tillbaka