首页 > 其他 > 详细

己知点坐标和半径R,求每隔45度半径与同心圆交汇的坐标

时间:2018-04-14 00:26:09      阅读:303      评论:0      收藏:0      [点我收藏+]

需求如下图

技术分享图片

<!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度半径与同心圆交汇的坐标

原文:https://www.cnblogs.com/zzws/p/8824783.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!