声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2830|回复: 3

[编程技巧] 已知中心,长,宽,角度,画一倾斜矩形

[复制链接]
发表于 2009-10-13 20:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
中心、长、宽均已知,如何画与x轴呈一定角度的倾斜矩形???:@Q
回复
分享到:

使用道具 举报

发表于 2009-10-13 21:26 | 显示全部楼层
width=30;
length=4;
xc=20;yc=30;
RotationgAngle=60; % in degree

% Computing the Relative Position After Rotation
RotationgAngle=RotationgAngle/180*pi;
RotateMatrix=[cos(RotationgAngle),sin(RotationgAngle);-sin(RotationgAngle),cos(RotationgAngle)];
PostRT=RotateMatrix*[width/2,length/2]';
PostRB=RotateMatrix*[width/2,-length/2]';

PostXY=[PostRT,PostRB,-PostRT,-PostRB,PostRT]+repmat([xc,yc]',[1,5]);
plot(PostXY(1,:),PostXY(2,:))
axis image

评分

1

查看全部评分

 楼主| 发表于 2009-10-13 22:33 | 显示全部楼层

谢谢

问题解决了,非常感谢!
发表于 2009-10-13 23:59 | 显示全部楼层
感觉上应该是
RotateMatrix=[cos(RotationgAngle),-sin(RotationgAngle);sin(RotationgAngle),cos(RotationgAngle)];

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-25 14:29 , Processed in 0.104379 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表