<< Chapter < Page Chapter >> Page >
This module is part of the collection, A First Course in Electrical and Computer Engineering . The LaTeX source files for this collection were created using an optical character recognition technology, and because of this process there may be more errors than usual. Please contact us if you discover any errors.

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 G T =

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 A , we have defaulted to looking down on the x - y plane from z = (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 R y ( θ ) as an example. The function to build it looks like

Enter and saveas given. Then write functions for hry.m

R x ( θ ) v h r x . m R z ( θ ) v h r z . m S ( s x , s y , s z ) v h s . m T ( t x , t y , t z ) v h t . m M ( d ) v h m . m

Useful MATLAB functions for this task include,, and. diag

Now build and use a perspective projection with viewpoint Earth and projection plane at z = 1000 behind the dippers:

  1. translate Earth to z = - 1000 so that the projection plane coincides with the x - y plane: T ( O , 0 , - 1000 ) ;
  2. use the fundamental perspective projection: M ( - 1000 ) ; and
  3. translate back: T ( O , 0 , 1000 ) .

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 x and y 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

  1. translate the viewpoint to the origin;
  2. rotate the centroid (direction to look) to the z-axis–note that the centroid will have new coordinates after step (1); and
  3. apply the composite(as used to view from Earth). 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

Table 1 is a six-row and four-column table with the first row as a header, the first column describing different stars, and the values in the second through fourth columns describing the corresponding right ascension, declination, and distance for each star.
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.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, A first course in electrical and computer engineering. OpenStax CNX. Sep 14, 2009 Download for free at http://cnx.org/content/col10685/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'A first course in electrical and computer engineering' conversation and receive update notifications?

Ask