# Reflect a triangle given a mirror line

48 Ansichten (letzte 30 Tage)
DINESH RAMACHANDRAN am 19 Aug. 2014
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
DINESH RAMACHANDRAN am 19 Aug. 2014
its three point triangle....

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

David Sanchez am 19 Aug. 2014
Create a m-file with this function:
% 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:
A = [1 2];
B = [5 7];
C = [2 9];
M = [A; B; C]; % matrix to hold points
plot(M(:,1),M(:,2),'*')
m = .5;
n = -1;
x = [-100 100];
y = m.*x+n;
hold on
plot(x,y)
hold off
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 KommentarKeine anzeigenKeine ausblenden
DINESH RAMACHANDRAN am 19 Aug. 2014
sir, it shows the first statement as error, i.e. Input argument "P" is undefined.

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (2)

Ahmet Cecen am 19 Aug. 2014
Look at householder reflectors on wikipedia. The function "flip" might also help.
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Roger Stafford am 19 Aug. 2014
I suggest you look at John D'Errico's advice on this kind or problem at:
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Numerical Integration and Differentiation in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!