# Shape of the Milky Way

This is a reference for you to see if you did everything correctly, what should be on your screen. Note that some commands in this page are blocked (using ...) for you to figure out by yourself.

## Read and organize the data

We would like to plot the positions of the open clusters in a Cartesian coordinate system, so that we can see the shape and scale of the distribution. Combining the Galactic Longitude, Galactic Latitude, and distance to each cluster, we can convert to x,y,z.

First, load the data and save them to a variable, e.g., galOC:

```galOC = load('clusters_relevantGAL.txt');
```

The first column gives longitude in degrees, the second latitude in degrees, and the third distance in pc.

We must change from degrees to radians since we will use cos and sin functions to transform from galactic (i.e. polar) to cartesian coordinates:

```lonOC = galOC(:,1).*pi/180.0;
latOC = ... ;
```

Then we can calculate the , , and coordinates of each galaxy:

```xoc = galOC(:,3).*cos(latOC).*cos(lonOC);
yoc = ... ;
zoc = ... ;
```

## Distribution of the clusters

Now let's plot the projection of the open clusters onto the x-y plane (distribution as viewed from above galaxy):

```figure(1); clf
plot(xoc,yoc, 'b.')
xlabel(' ... ')
... ...
axis equal
```

Note that you can use axis command to control axis scaling and appearance. The option equal sets the aspect ratio so that equal tick mark increments on the x-, y- and z-axis are equal in size.

Also the projection onto the other two planes intersecting the galactic center, one perpendicular to the line of sight from earth and one parallel:

```figure(2); clf
plot(xoc,zoc, 'b.')
... ...
figure(3); clf
... ...
```

## 3-D distribution

Or, you can use plot3 function to make a 3-D plot showing the distribution of open clusters in the space, again using axis equal to prevent distortion of the shape:

```figure(4); clf
plot3(xoc, yoc, zoc, 'bo')
grid on
... ...
```

Then use the Rotate 3D icon to change the angle of view: