Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

## Over-the-Horizon 3-D Views Using Camera Positioning Functions

You can create dramatic 3-D views using the Globe display. The `camtargm` and `camposm` functions (Mapping Toolbox functions corresponding to `camtarget` and `campos`) enable you to position focal point and a viewpoint, respectively, in geographic coordinates, so you do not need to deal with 3-D Cartesian figure coordinates.

In this exercise, you display coastlines from the `landareas` shapefile over topographic relief, and then view the globe from above Washington, D.C., looking toward Moscow, Russia.

Set up a Globe display and obtain topographic data for the map. Hide the map background.

```figure axesm globe load topo hidem(gca)```

Display `topo` without the vertical component (by omitting the fourth argument to `meshm`). The default view is from above the North Pole with the central meridian running parallel to the x-axis.

```meshm(topo,topolegend,size(topo)); demcmap(topo);```

Add world coastlines from the global `landareas` shapefile and plot them in light gray.

```coastlines = shaperead('landareas',... 'UseGeoCoords', true, 'Attributes', {}); plotm([coastlines.Lat], [coastlines.Lon], 'Color', [.7 .7 .7])```

Read the coordinate locations for Moscow and Washington from the `worldcities` shapefile.

```moscow = shaperead('worldcities',... 'UseGeoCoords',true,... 'Selector',{@(name) strcmpi(name,'Moscow'),'Name'}); washington = shaperead('worldcities',... 'UseGeoCoords',true,... 'Selector',{@(name) strcmpi(name,'Washington D.C.'),... 'Name'});```

Create a great circle track to connect Washington with Moscow and plot it in red.

```[latc,lonc] = track2('gc',... moscow.Lat, moscow.Lon, washington.Lat, washington.Lon); plotm(latc,lonc,'r')```

Point the camera at Moscow. Wherever the camera is subsequently moved, it always looks toward `[moscow.Lat moscow.Lon]`.

`camtargm(moscow.Lat, moscow.Lon, 0)`

Station the camera above Washington. The third argument is an altitude in Earth radii.

`camposm(washington.Lat, washington.Lon, 3)`

Establish the camera up vector with the camera target's coordinates. The great circle joining Washington and Moscow now runs vertically.

`camupm(moscow.Lat,moscow.Lon)`

Set the field of view for the camera to 20°.

`camva(20)`

Add a light and specify a relatively nonreflective surface material. This is the final view.

`camlight; material(0.6*[ 1 1 1])`