Reputation: 35
Say a defined function begins with point (a,b) and ends with point (c,d). How do I flip this function about its vertical center line (described by x = (c-a)/2)?
Thanks in advance!
c = 5.2;
alpha = 0;
R = [cosd(alpha) sind(alpha) 0; -sind(alpha) cosd(alpha) 0; 0 0 1];
l1_vector = [-sqrt(3)*c; 0; 0];
l1_prime = R*l1_vector;
iter = 1;
for i=1:1201
R = [cosd(alpha) sind(alpha) 0; -sind(alpha) cosd(alpha) 0; 0 0 1];
l1_prime = R*l1_vector;
a = l1_prime(1)
b = l1_prime(2);
alpha = alpha+.1;
data1(iter,1:2)=[a,b];
iter=iter+1;
end
a = data1(:,1);
b = data1(:,2);
plot(wrev(a)+a(end)-a(1),b)
axis equal
Upvotes: 1
Views: 1010
Reputation: 8459
Depends how your function is defined really, but if you have a vector of x
values and another with corresponding function values y
, then
plot(x,y)
plots the function normally, and
plot(a,b,2*a(end)-a(1)-cumsum([0;diff(a)]),b)
plots the flipped and translated function.
Upvotes: 1