小马算法 - 获取矩形区域的顶点坐标- 讲解

gen_rectangle2_contour_xld (Rectangle4, Row, Column, Phi, Length1, Length2)
 
tuple_cos (Phi, Cos)
tuple_sin (Phi, Sin)
 
dev_set_color('green')
RT_X := -Length1*Cos - Length2*Sin
RT_Y := -Length1*Sin + Length2*Cos
gen_circle (Circle, Row-RT_Y, Column+RT_X, 10)
 
RB_X := Length1*Cos - Length2*Sin
RB_Y := Length1*Sin + Length2*Cos
gen_circle (Circle, Row-RB_Y, Column+RB_X, 10)
 
LB_X := Length1*Cos + Length2*Sin
LB_Y := Length1*Sin - Length2*Cos
gen_circle (Circle, Row-LB_Y, Column+LB_X, 10)
 
LT_X := -Length1*Cos + Length2*Sin
LT_Y := -Length1*Sin - Length2*Cos
gen_circle (Circle, Row-LT_Y, Column+LT_X, 10)


其中RT_X, RT_Y, RB_X, RB_Y, LB_X, LB_Y, LT_X, LT_Y求出的是距中心点的偏移量
顶点坐标可通过与矩形的中心坐标加减得到
如上面的函数gen_circle 

利用坐标旋转,最终得到想要的结果

个可以通过如下原理的方法来求:
中心为(Row,Col),长半轴为width,短半轴为height。先将矩形顶点坐标换算到水平时候的坐标,中心点位置不变。为A(Row- width,Col-height),B(Row+width,Col-height),C(Rol- width,Col+height),D(Rol+width,Col+height)
然后将A,B,C,D点坐标进行一个theta角度的旋转变换就是你所求的四个顶点的坐标

转载于:https://www.cnblogs.com/tmdsleep/p/5473518.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值