Mirror Rectangles/Polygons in a Figure/Plot function

조회 수: 3 (최근 30일)
Chris Dan
Chris Dan 2020년 2월 26일
답변: Chris Dan 2020년 2월 27일
hello, I have this data
I am using the following code to draw the rectangles from the data, the first column is the length and the height is the second column - third column.
drawingfunction(BodyData);
function [] = drawingfunction(BodyData)
figure('Name','BodyView');
hold on
for i =1:1
MD = BodyData{i,1};
MD(:,1) = MD(:,1);
a = size(MD,1);
for j =1:(a-1)
coord = MD(j:j+1,:);
r = rectangle('Position',[coord(1,1) coord(1,3) coord(2,1)-coord(1,1) coord(1,2)-coord(1,3)])
axis([0 0.2 -0.1 0.2])
hold on
end
end
end
The code is running okay here is the result attached:
Now I want to mirror this image using x axis as the axis of mirror
does anyone has an idea how to do it?

채택된 답변

Chris Dan
Chris Dan 2020년 2월 27일
I solved it
drawingfunction(BodyData);
function [] = drawingfunction(BodyData)
figure('Name','BodyView');
hold on
for i =1:1
MD = BodyData{i,1};
MD(:,1) = MD(:,1);
a = size(MD,1);
for j =1:(a-1)
coord = MD(j:j+1,:);
r = rectangle('Position',[coord(1,1) coord(1,3) coord(2,1)-coord(1,1) coord(1,2)-coord(1,3)])
axis([0 0.2 -0.1 0.2])
hold on
% magic Line hich solves the problem
rectangle('Position',[coord(1,1) -coord(1,2) coord(2,1)-coord(1,1) coord(1,2)-coord(1,3)])
axis([0 0.2 -0.1 0.2])
hold on
end
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by