필터 지우기
필터 지우기

Reflect a triangle given a mirror line

조회 수: 15 (최근 30일)
DINESH RAMACHANDRAN
DINESH RAMACHANDRAN 2014년 8월 19일
댓글: DINESH RAMACHANDRAN 2014년 8월 19일
please help me to write the program for the above mentioned question.
  댓글 수: 2
David Sanchez
David Sanchez 2014년 8월 19일
How is the triangle given, by three point or three lines?
DINESH RAMACHANDRAN
DINESH RAMACHANDRAN 2014년 8월 19일
its three point triangle....

댓글을 달려면 로그인하십시오.

채택된 답변

David Sanchez
David Sanchez 2014년 8월 19일
Create a m-file with this function:
function S = symetric_P_about_line(P,m,n)
% line of symmetry: y = m*x + n;
Md = zeros(2,1); % Middle point between given point and its symmetric
Md(1) = (P(1) + m*P(2) - m*n)/(m^2 + 1);
Md(2) = m*Md(1) + n;
S = 2*Md - P; % symmetric point of P about given line
And this gives you the symmetric points of your triangle vertices about the symmetry line y=m*x+n:
% triangle (add your points)
A = [1 2];
B = [5 7];
C = [2 9];
M = [A; B; C]; % matrix to hold points
plot(M(:,1),M(:,2),'*')
% line of symmetry (add your m and n)
m = .5;
n = -1;
x = [-100 100];
y = m.*x+n;
hold on
plot(x,y)
hold off
As = symetric_P_about_line(A,m,n);
Bs = symetric_P_about_line(B,m,n);
Cs = symetric_P_about_line(C,m,n);
Ms = [As; Bs; Cs]; % matrix to hold symmetric points
hold on
plot(Ms(:,1),Ms(:,2),'r*')
hold off
axis([-10 20 -10 20])
axis square
  댓글 수: 1
DINESH RAMACHANDRAN
DINESH RAMACHANDRAN 2014년 8월 19일
sir, it shows the first statement as error, i.e. Input argument "P" is undefined.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Ahmet Cecen
Ahmet Cecen 2014년 8월 19일
Look at householder reflectors on wikipedia. The function "flip" might also help.

Roger Stafford
Roger Stafford 2014년 8월 19일
I suggest you look at John D'Errico's advice on this kind or problem at:
https://www.mathworks.com/matlabcentral/newsreader/view_thread/337038

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by