Having trouble modifying a figure using homogeneous coordinates

1 回表示 (過去 30 日間)
Adrian Lomeli Martin
Adrian Lomeli Martin 2021 年 9 月 5 日
Hey everyone! As the title suggests, I'm having trouble modyfing a figure using homogeneous coordinates. I'm using the following code:
theta = linspace(0,2*pi,512);
x = sin(theta);
y = 2*cos(theta);
ellipse1 = [x;y;ones(size(x))];
Scale = [0.4 0 0;0 0.6 0;0 0 1];
Rotate = [cos(pi/4) sin(pi/4) 0 ;-sin(pi/4) cos(pi/4) 0;0 0 1];
Translate = [1 0 1;0 1 1;0 0 1];
transform = Translate * Rotate * Scale;
transformedellipse = transform * ellipse1;
plot(x,y)
hold on
plot(transformedellipse)
hold off
axis([-2 2 -3 3]);
What I'm hoping to do is scale the figure by 0.4 and 0.6 in the x and y dimensions, rotate it and then translate it but when I plot it instead of my desired ellipse a weird glitchy rectanlge shows up (I'm attaching the resulting figure). Any input you could give me as to what I'm doing wrong would be greatly appreciated. Thanks in advance!

採用された回答

Matt J
Matt J 2021 年 9 月 5 日
編集済み: Matt J 2021 年 9 月 5 日
plot(x,y)
hold on
plot(transformedellipse(1,:),transformedellipse(2,:))
hold off
axis([-2 2 -3 3]);
  1 件のコメント
Adrian Lomeli Martin
Adrian Lomeli Martin 2021 年 9 月 5 日
This solved the problem I was having, thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by