修改角度

main
suixy 2 months ago
parent b272cb9106
commit c22db40b17

@ -36,7 +36,10 @@ function calcRectangleFromPoints(points) {
const height = trapezoid ? (left + right) / 2 : right; const height = trapezoid ? (left + right) / 2 : right;
const bottomAngleRad = Math.atan2(p1.y - p4.y, p1.x - p4.x); const bottomAngleRad = Math.atan2(p1.y - p4.y, p1.x - p4.x);
const leftAngleRad = Math.atan2(p1.x - p2.x, p1.y - p2.y);
const angleDeg = bottomAngleRad * 180 / Math.PI; const angleDeg = bottomAngleRad * 180 / Math.PI;
console.log(leftAngleRad * 180 / Math.PI;
)
return { return {
width: Number(width.toFixed(2)), height: Number(height.toFixed(2)), angle: Number(angleDeg.toFixed(6)) width: Number(width.toFixed(2)), height: Number(height.toFixed(2)), angle: Number(angleDeg.toFixed(6))
}; };
@ -62,7 +65,6 @@ function getLocalPositionRelativeToP4(point, rectPoints, rectInfo) {
const y_local = dx * Math.sin(rad) + dy * Math.cos(rad); const y_local = dx * Math.sin(rad) + dy * Math.cos(rad);
const rotate_local = ((point.rotate ?? 0) + rectInfo.angle + 360) % 360; const rotate_local = ((point.rotate ?? 0) + rectInfo.angle + 360) % 360;
console.log(rotate_local)
return { return {
x: Number(x_local.toFixed(2)), y: Number(y_local.toFixed(2)), rotate: Number(rotate_local.toFixed(2)) x: Number(x_local.toFixed(2)), y: Number(y_local.toFixed(2)), rotate: Number(rotate_local.toFixed(2))
}; };

Loading…
Cancel
Save