<< Chapter < Page | Chapter >> Page > |
With Earth at the origin, we may specify the star positions for the Big and Little Dippers in three-dimensional homogeneous coordinates. With lightyears as our units, we have
To make use of this data, we need a function to display it. Enter and save
the following generalization of the function from
Demo 1 in "Vector Graphics: Two Dimensional Image Representation" . Call it.
vhgraph.m
Enter the point matrix given at rhe beginning of this section (and take its transpose to put it in the usual form). Also enter the line matrix from Demo 1 in "Vector Graphics: Two Dimensional Image Representation" . Save these two matrices and try looking at the image
No dippers in sight, right? Without specifying a transformation matrix , we have defaulted to looking down on the plane from (a parallel projection). This is how the constellations would look from a distant galaxy(say, a billion light years north of here) through an enormous telescope. We need a perspective view from the origin (Earth), but first we need a set offunctions to give us the fundamental operators with which we can build the desired projection.
Take as an example. The function to build it looks like
Enter and saveas given. Then write functions for
hry.m
Useful MATLAB functions for this task include,, and.
diag
Now build and use a perspective projection with viewpoint Earth and projection plane at behind the dippers:
Oops! Now the image is too big; it's mostly off the screen. Scale it down and have another look:
Now the view should look familiar. Leave A as it is now:
Experiment with scale and rotation about the z-axis. For example, try
The two-dimensional star positions given in Demo 1 in "Vector Graphics: Two Dimensional Image Representation" were obtained from the three-dimensional positions with the composite operator A you are nowusing. To compare the two, type
and compare the and coordinates with those of Demo 1 in "Vector Graphics: Two Dimensional Image Representation" .
Astronomers give star positions in equatorial coordinates using right ascension, declination, and distance. The following function converts equatorial coordinates, which are spherical, to Cartesian coordinates with the z-axis pointing north, the x-axis pointing at the vernal (Spring) equinox in the constellation Pisces, and the y-axis pointing toward the Winter solstice in the constellation Opheuchus.
Have you ever wondered what the constellations would look like from other places in the galaxy? We will soon see the answer. First we will viewthe dippers from Alpha Centauri, the nearest star, whose coordinates are
We will look toward the centroid of the fourteen stars in the dippers, located at
To get the desired view, we must
A=S(.06,.06,.06)*T(0,0,1000)*M(-1000)*T(0,0,-1000)
Write a functionbased on
Exercise 5 from "Vector Graphics: Three-Dimensional Homogeneous Coordinates" to accomplish step (2). Test it on several random points to make sure it works right. Now write a general perspective projection function called. The functionshould
accept as inputs two vectors, the first specifying the viewpoint and the secondthe point to look toward. Its output should be a composite operator that
performs all three of the preceding steps.
vhview
Now we want to look toward the centroid of the dippers from Alpha Centauri. To do so, enter the vectors for the two points of interest and construct the view like this:
The farther we move from Earth, the more distorted the dippers will look
in general. It should be easy now to view them from any desired location.Just choose a viewpoint, recalculate the composite operator for that viewpoint
using, and use. Follow this procedure to view the dippers
from each of the stars in the following list. You will need to usefirst
to convert their coordinates.
starxyz
Star | Right Ascension | Declination | Distance (ly) |
---|---|---|---|
Alpha Centauri | 14h 40m | -60° 50' | 4.2 |
Sirius | 6h 45m | -16°43' | 9.5 |
Arcturus | 14h 16m | 19°11' | 16.6 |
Pollux | 7h 45m | 28°02' | 35.9 |
Betelgeuse | 5h 55m | 7°24' | 313.5 |
Of course, star viewing is not the only application of vector graphics. Do some experiments with the unit cube ( see Exercise 2 from "Vector Graphics: Three-Dimensional Homogeneous Coordinates" ). View the cube from location (4,3,2) looking toward the origin using the procedure just outlinedfor stars. You may need to adjust the scaling to get a meaningful view.
Notification Switch
Would you like to follow the 'A first course in electrical and computer engineering' conversation and receive update notifications?