JS根据A点旋转指定角度后B点的坐标位置
作者:
源大侠 | 来源:发表于
2022-08-30 14:28 被阅读0次// ptSrc: 圆上某点(初始点);
// ptRotationCenter: 圆心点;
// angle: 旋转角度° -- [angle * M_PI / 180]:将角度换算为弧度
// 【注意】angle 逆时针为正,顺时针为负
function rotatePoint(ptSrc,ptRotationCenter,angle){
var a = ptRotationCenter.x
var b = ptRotationCenter.y
var x0 = ptSrc.x
var y0 = ptSrc.y
var rx = a + (x0-a) * Math.cos(angle * Math.PI / 180) - (y0-b) * Math.sin(angle * Math.PI / 180);
var ry = b + (x0-a) * Math.sin(angle * Math.PI / 180) + (y0-b) * Math.cos(angle * Math.PI / 180);
var json = {x:rx,y:ry}
return json;
}
本文标题:JS根据A点旋转指定角度后B点的坐标位置
本文链接:https://www.haomeiwen.com/subject/pfblnrtx.html
网友评论