How to calculate translate x and y value when resize after rotate..?(旋转后调整大小时如何计算平移x和y值..?)
问题描述
我正在使用 HTML div 元素 javascript 中基于角的调整大小.
I am working with HTML div element corner based resize in javascript.
基于角的调整大小在选择框 div 未旋转(即 rotate(0 deg))时完美运行.
Corner based resize working perfect when selection box div is unrotated (i.e. rotate(0 deg)).
旋转后,当左上角需要保持在同一位置时,我使用右下角作为手柄来调整选择框div的大小.p>
就像有四个手柄一样,调整大小时对角需要保持在同一位置.
After rotate, i am using bottom-right corner as handle to resize the selection box div, when top-left corner needs to remain in same position.
但问题是,选择框左上角角不保持在同一位置.
As like having four handles, with opposite corner needs to remain in same position when resize.
我需要为旋转后基于角的调整大小计算平移 x 和 y 值.
But the problem is, the selection box top-left corner not remains in same position.
scale
, center_x
, center_y
, previous_x
, previous_y
, width
, height
, previous_width
, previous_height
, diff_width
, diff_height
, radian_angle
, rotated_degree
.
I need to calculate translate x and y value for corner based resize after rotate.
scale
,center_x
,center_y
,previous_x
,previous_y
,width
,height
,previous_width
,previous_height
,diff_width
,diff_height
,radian_angle
,rotated_degree
.
用于旋转后调整大小的示例代码:
switch (handle) {
case 'bottom-right':
x = previous_x - ? ; //logic behind after rotated some angles..?
y = previous_y + ? ;
break;
case 'bottom-left':
x = ? ;
y = ? ;
break;
case 'top-left':
x = ? ;
y = ? ;
break;
case 'top-right':
x = ? ;
y = ? ;
break;
default:
}
当使用未旋转的 div (rotate(0 deg)
) 调整大小时,基于角的调整大小代码可以完美运行:
Below corner based resize code works perfect when resize with unrotated div (rotate(0 deg)
):
case 'bottom-right':
x = previous_x;
y = previous_y;
break;
case 'bottom-left':
x = previous_x - diff_width;
y = previous_y;
break;
如何计算 translate x &调整大小时旋转后的y值以获得固定角.?
How to calculate translate x & y value after rotate to get fixed corner when resize.?
推荐答案
不知道你是否还需要帮助.但我认为你可以用三角函数(余弦、正弦和你的旋转角度)来达到它,因为你的旋转画了一个圆.
I don't know if you still need help. But I think you can reach it with Trigonometry (cosinus, sinus and your rotation angle) because your rotation draw a circle.
这篇关于旋转后调整大小时如何计算平移x和y值..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:旋转后调整大小时如何计算平移x和y值..?


- addEventListener 在 IE 11 中不起作用 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01