Hello there, I am a student in Geodesy (2nd year) and few days ago one of my teachers recommended me to start learning MatLab. For beggining he adviced me to start doing projects that we have done in Excel in MatLab, projects using: The Least Squares Method, determinating coordinates with various topography methods(Delambre, Collins, Cassini-Martinian etc). Being new to programming language I know this won't be easy for me but I really want to learn. Thank you
MATLAB: Is there any Geodetic engineer that knows MatLab
geodesy
Related Solutions
Hello Benedict, (revised)
The four points do form a pretty good rectangle, but it doesn't look like it because the x and y axis scaling on the plot are different. Try 'axis equal' just after the plot command, which should show you a rectangle, hopefully. The following
pd = Pitch_dimensions % in meters
norm(pd(1,:)-pd(2,:)) % width
norm(pd(3,:)-pd(4,:)) % width norm(pd(1,:)-pd(3,:)) % length
norm(pd(2,:)-pd(4,:)) % length norm(pd(1,:)-pd(4,:)) % diag
norm(pd(2,:)-pd(3,:)) % diag
shows that there is a bit of inaccuracy in the coordinates, on the order of 1 m, but the diagonals agree within about 2 m so it's a rectangle. (I have to say that I don't have the geodetic2enu function so I had to make my own simplified version, but I think it works acceptably for this purpose).
Pretty long touch lines.
At this point I will assume that you have gone through the same geodetic2enu process for players as for the corners. The result is a 4x2 array for the corners and 11x2 arrays for the teams, plus maybe a 1x2 for the ball, all in meters. Some demo code for that is
% demo code for players and ball, unrotated, in meters
pd = Pitch_dimensions; % in metersp42 = pd(4,:)-pd(2,:); % touch line
p12 = pd(1,:)-pd(2,:); % goal line
team1 = rand(11,1)*p42+ rand(11,1)*p12;team2 = rand(11,1)*p42+ rand(11,1)*p12;ball = rand*p42 + rand*p12;
Here is an example of rotation and plotting. I used plot instead of scatter because I think it is more versatile. Lots of possibilities for a plot. You will see that the boundary is a bit off due to 1 m inaccuracies but you could always make one manually.
% start of real code
pd = Pitch_dimensions;bound = pd([2 4 3 1 2],:); % boundary points in ccw order for plotting
p42 = pd(4,:) - pd(2,:); % touch line
theta = atan2(p42(2),p42(1)); % theta is in radians
R = [cos(theta) -sin(theta); sin(theta) cos(theta)]; % rotation matrix
team1R = team1*R; team2R = team2*R; % rotation
ballR = ball*R; boundR = bound*R;figure(1)plot(boundR(:,1),boundR(:,2),'o-');hold onplot(team1R(:,1),team1R(:,2),'sb','MarkerFaceColor','b') % everton
plot(team2R(:,1),team2R(:,2),'sr','MarkerFaceColor','r') % liverpool
plot(ballR(:,1),ballR(:,2),'ok');axis equalhold off
I maybe went on too long but it's an interesting topic. Looking at the random player positions reminds me a lot of our intramural soccer team from college.
You don't actually need Mapping TB to find boundaries. You can do it with convhull or, if you have 14b, boundary.
But perhaps you want something even simpler than that. To get the points on the North edge, you could just do
idxNorth = (latitude == max(latitude));northLat = latitude(idxNorth);northLon = longitude(idxNorth);
This gets only the points that have the exact same latitude as the northernmost point. Use some other condition if that's too exacting (such as latitude > threshhold_latitude).
Best Answer