开发者

How to plot a 3d representation of a GPS track

开发者 https://www.devze.com 2023-03-07 08:05 出处:网络
I have 3 vectors, x, y, z. Three different vectors\' elements represent the position of point in space (e.g. x(1), y(1), z(1) contains info about the first point\'s position).

I have 3 vectors, x, y, z. Three different vectors' elements represent the position of point in space (e.g. x(1), y(1), z(1) contains info about the first point's position).

Now I need to realize a 3D r开发者_JS百科epresentation of the entire set of points, and it should look like this:

How to plot a 3d representation of a GPS track

Can someone help me? What function will be useful?


You can use the following functions:

  • PLOT3 - to draw 3D line.
  • STEM3 - to draw lines to XY projection. I would probably use not all the data points, but every other 5th, 10th etc, depending on points density.
  • Optionally you can use CLINE from FileExchange (this or this) instead of PLOT3 to color the line by its elevation.

Don't forget to set hold on and hold off.

Here is an example:

%# Generate random data
x = sin(0:0.01:2*pi);
y = cos(0:0.01:2*pi);
n = numel(x);
z = x + rand(1,n)*0.05 + 1;
%# Plot track line
plot3(x,y,z,'LineWidth',2)
%# Plot lines to XY projection for every 5th point
hold on
stem3(x(1:5:end),y(1:5:end),z(1:5:end),'Marker','none','color','c')
hold off
%# Set axes invisible
set(gca,'Visible','off')

How to plot a 3d representation of a GPS track


You need to create a projection transformation from your 3D world (x,y,z) to your image (X,Y). This may either be a plane projection or a perspective projection.

Once you have the projection you can do something like the following:

  1. Find the point that is furthest away from you.
  2. Carry out the sequences below for the left and the right branches from the furthest point.
  3. For each branch create a polygon out of each of the four points:

    T(x[n],y[n],z[n])

    T(x[n],y[n],0)

    T(x[n+1],y[n+1],0)

    T(x[n+1],y[n+1],z[n+1])

  4. Color the polygons by a gradient changing by z to get the effect above.

  5. Add a blue line from T(x[n],y[n],z[n]), T(x[n+1],y[n+1],z[n+1])
  6. Redo for increasing n until you reach the point "closest" to you.

Hopefully this will get you started.

0

精彩评论

暂无评论...
验证码 换一张
取 消