How to 'Mirror Image' my Vectors

Hello friends,
Been struggling with what might be a simple issue but can't seem to figure out. I have two vectors that are a 'mirror image' of themselves when plotted. Can anyone help me reorient them properly? I have tried flipud and fliplr but no success!
Attached the mirror image and the x and y vectors in spreadsheet. Any ideas will be deeply appreciated!
Thanks.

5 Comments

The minimum y value is 3.650514169 but the minimum x value is 6.613740176 so I do not understand why you say they are mirror image.
The values look like they might define grids of coordinates; it looks roughly like there as many different copies of each x value in a row, as there are unique y values, and it looks like the y values might repeat periodically. So it looks like the coordinates might be outputs of meshgrid() that are reshaped to vectors.
... When you talk about "mirror image" are you saying that the coordinates form the shape of a curved lens? The shape pictured would be more likely used to focus light than to be used as a mirror, it looks to me.
It isn't clear to me what the question is.
@Walter Roberson Thanks very much for your reply and insights. I'll try clarify my problem, and sorry for framing my question so poorly.
So the x and y vector values are actually pixel coordinates with corresponding z values for velocity (which I haven't attached). I have written a script (attached) that transforms these pixel coordinates to British National Grid coordinates following which I plot them in QGIS as per the attached image.
The 'problem' here is, when I plot these coordiantes in GIS (the image is attached is actually a screen grab from QGIS) the x and y coordinates are not in their correct location, they are clearly 'mirrored' for some reason. What I'm trying to do is get them in the right location - remove this 'mirror' effect.
Is there a way to resolve this? Thanks so much. Attached my transformation script (which does work and completes the transform, justwith the annoying 'mirroring'.
movingPointsM = [10.28,6.02;19.97,7.29;27.07,7.09;33.75,6.13;7.82,14.63;15.74,15.69;26.90,16.52;34.88,15.56]; %Co-ordinates from PIVlab
% fixedPointsM = [29.8076, 24.5377;21.3091, 30.6566;9.5556, 15.9563;16.958, 24.0496;24.7148 ,37.4257;22.1936, 14.7003;34.0778, 32.4643;15.9756, 8.3569];
% First fixedPointsM are subsampled GCP GPS data - second fixedPointsM are
% real-world coordinates, no edit - and can be used to plot the vels in the
% correct coordinate system.
fixedPointsM = [351134.02,512791.64; 351127.80,512785.29;351120.19,512775.46;351115.92,512767.53;351140.44,512784.04;351133.04,512775.95;351128.69,512769.34;351127.28,512762.57]; % image px for specific video
mytform = fitgeotrans(movingPointsM, fixedPointsM, 'affine');% Reproject the data array so that it is consistent with metric spatial reference used for KLT-PIV
[x, y] = transformPointsForward(mytform, x(:), y(:)); %xdataOrig,ydataOrig
figure();
scatter(fixedPointsM(:,1), fixedPointsM(:,2));hold on; % Check that the GCP transformation works well
%scatter(x(:),y(:));
writematrix([x(:), y(:)],'transformed.txt', 'Delimiter', ',');
To check the obvious: if you are using GIS, then are you making sure you use longitude -> x and latitude -> y, and that latitude corresponds to rows in MATLAB arrays and that longitude corresponds to columns in MATLAB arrays?
@Walter Roberson Those are correct, the x (longitudes) and y (latitudes).

Sign in to comment.

 Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 16 Mar 2021
If your yellow point-markers are supposed to lie on/in/over the stream (river?) then you might have to either rotate their coordinates around the centre of the scene, or perhaps mirror the coordinates on the diagonal. For the latter case I attach a function that mirror points relative to a line.
HTH

7 Comments

@Bjorn Gustavsson Thanks very much Bjorn. Yes, the yellow point markers are supposed to lie over the stream. Thanks for your script, let me give it a shot. Thanks again.
@Bjorn Gustavsson The script didn't achieve my objective, still, many thanks for it. It seems the rotation around the centre of the scene could work. Any few tips on how to achieve this? Thanks.
Well, that's something I'd try to do something like this:
r_C = [x_centre,y_centre];
M180 = @(phi)[cos(phi) -sin(phi);sin(phi) cos(phi)];
r180 = (M180(pi)*(r_in-repmat(r_C,nPoints,1))')'+repmat([r_C,nPoints,1);
where r_in (and r180) should be [nPoints x 2] arrays.
@Bjorn Gustavsson Been struggling to figure this code the whole day, any chance you can break it down for me please? Thanks.
OK, I'll give it a try. x_cenre and y_centre are the point you want to rotate the x and y coordinates of your yellow points around, in whatever units you have plotted them over the image. r_in are supposed to be the coordinates of the yellow points in, the x and y-coordinates for one point on each row. M180 is just a (poorly named) function that creates a rotation-matrix for rotating a 2-D array an angle phi. The next line rotates the point-coordinates by 180 degrees around r_C. These lines were inteded to be applied to the coordinates of the yellow points - I just realized your x.xlsx and y.xlsx are not the coordinates of those points, so maybe you're looking for a solution to a different problem than what I interpreted.
If you want to rotate the background image then you always have the imrotate function.
@Bjorn Gustavsson Works perfectly! Thanks :)
My pleasure!
(Please share/upload the corrected points-overlayed-on-image figure - it would bring me(us?) joy...)

Sign in to comment.

More Answers (0)

Products

Release

R2020b

Community Treasure Hunt

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

Start Hunting!