当前位置: 首页 > Web前端 > HTML

JavaScript数学曲线——互锁螺旋

时间:2023-04-02 16:05:25 HTML

介绍先等距螺旋,再试试互锁螺旋。阿基米德螺线在OriginMyGitHub的介绍中提到的通式,当c=-2时,是一条链式螺线,也称为利图斯曲线。罗杰科特斯在他的书《Harmonia Mensurarum》(1722)中描述了这条曲线。麦克劳林于1722年命名该曲线。极坐标系中的公式说明:公式说明:r:径向距离。一个:常数。θ:极角。绘图使用画布绘制曲线。canvas的坐标系是笛卡尔坐标系,需要进行转换。从上图可以看出,取一个点有如下数学转换关系:x=rcos(θ)y=rsin(θ)θ=arctan(y/x)结合极坐标系公式:这是一个示例,绘制主要逻辑代码:functiondraw(){leta=100,angle=0.1;让x=0,y=0,点数=[];const加速度=0.1,circleNum=20;while(angle<=circleNum*2*Math.PI){constangleSqrt=Math.sqrt(angle);x=(a/angleSqrt)*Math.cos(角度);y=(a/angleSqrt)*Math.sin(角度);points.push([x,y]);角度=角度+加速度;}//实现画点成线的方法line({points:points});}参考LituusWikiLituusWolframMathWorldLituusPlaneCurvesLituus

猜你喜欢