1. 程式人生 > >己知點坐標和半徑R,求每隔45度半徑與同心圓交匯的坐標

己知點坐標和半徑R,求每隔45度半徑與同心圓交匯的坐標

src += http head tee image poi -c oct

需求如下圖

技術分享圖片

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>javascript己知點坐標和半徑R,求每隔45度半徑與同心圓交匯的坐標</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"
/> <style> span { position: absolute; color: red; font-weight:bold; } </style> </head> <body> <script> var showCircle = function () { var PI = Math.PI; return { draw:
function (r, _x, _y) { var x, y; var _pt = []; for (var i = 0; i < 360; i += 45) { x = Math.cos(PI / 180 * i) * r + _x; y = Math.sin(PI / 180 * i) * r + _y; var O = document.createElement(
span); O.appendChild(document.createTextNode(.)); document.body.appendChild(O); O.style.left = x + px; O.style.top = y + px; let pt = { x, y }; _pt.push(pt); } Points.push(_pt); } } }(); var Points = []; for (let r = 80; r < 200; r+=20){ showCircle.draw(r, 200, 200); } console.log(Points); </script> </body> </html>

技術分享圖片

己知點坐標和半徑R,求每隔45度半徑與同心圓交匯的坐標