Ser ut som att det jag slängde ihop igår kväll fungerar
Kod:
<html>
<head>
<title>Test</title>
</head>
<body>
<script>
function rotateX(x, y, degrees) {
r = Math.sqrt(x*x + y*y);
radians = degrees * Math.PI / 180;
theta = Math.atan2(x, y) + radians;
return r * Math.cos(theta);
}
function rotateY(x, y, degrees) {
r = Math.sqrt(x*x + y*y);
radians = degrees * Math.PI / 180;
theta = Math.atan2(x, y) + radians;
return r * Math.sin(theta);
}
angle = 30;
offset = 300;
document.write('<div style="position: absolute; top: ' + offset + 'px; left: ' + offset + 'px; color: gray;">*</div>');
top1 = offset + 100;
left1 = offset;
top2 = rotateY(left1 - offset, top1 - offset, angle) + offset;
left2 = rotateX(left1 - offset, top1 - offset, angle) + offset;
document.write('<div style="position: absolute; top: ' + top1 + 'px; left: ' + left1 + 'px; color: gray;">*</div>');
document.write('<div style="position: absolute; top: ' + top2 + 'px; left: ' + left2 + 'px; color: red;">*</div>');
top1 = offset - 100;
left1 = offset;
top2 = rotateY(left1 - offset, top1 - offset, angle) + offset;
left2 = rotateX(left1 - offset, top1 - offset, angle) + offset;
document.write('<div style="position: absolute; top: ' + top1 + 'px; left: ' + left1 + 'px; color: gray;">*</div>');
document.write('<div style="position: absolute; top: ' + top2 + 'px; left: ' + left2 + 'px; color: green;">*</div>');
top1 = offset;
left1 = offset + 100;
top2 = rotateY(left1 - offset, top1 - offset, angle) + offset;
left2 = rotateX(left1 - offset, top1 - offset, angle) + offset;
document.write('<div style="position: absolute; top: ' + top1 + 'px; left: ' + left1 + 'px; color: gray;">*</div>');
document.write('<div style="position: absolute; top: ' + top2 + 'px; left: ' + left2 + 'px; color: yellow;">*</div>');
top1 = offset;
left1 = offset - 100;
top2 = rotateY(left1 - offset, top1 - offset, angle) + offset;
left2 = rotateX(left1 - offset, top1 - offset, angle) + offset;
document.write('<div style="position: absolute; top: ' + top1 + 'px; left: ' + left1 + 'px; color: gray;">*</div>');
document.write('<div style="position: absolute; top: ' + top2 + 'px; left: ' + left2 + 'px; color: blue;">*</div>');
</script>
</body>
</html>