Skip to content Skip to navigation

Connexions

You are here: Home » Content » Vector Graphics: Three-Dimensional Homogeneous Coordinates

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Endorsed by Endorsed (What does "Endorsed by" mean?)

This content has been endorsed by the organizations listed. Click each link for a list of all content endorsed by the organization.
  • IEEE-SPS

    This module is included inLens: IEEE Signal Processing Society Lens
    By: IEEE Signal Processing SocietyAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Click the "IEEE-SPS" link to see all content they endorse.

  • College Open Textbooks display tagshide tags

    This module is included inLens: Community College Open Textbook Collaborative
    By: CC Open Textbook CollaborativeAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Comments:

    "Reviewer's Comments: 'I recommend this book as a "required primary textbook." This text attempts to lower the barriers for students that take courses such as Principles of Electrical Engineering, […]"

    Click the "College Open Textbooks" link to see all content they endorse.

    Click the tag icon tag icon to display tags associated with this content.

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • Bookshare

    This module is included inLens: Bookshare's Lens
    By: Bookshare - A Benetech InitiativeAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Comments:

    "Accessible versions of this collection are available at Bookshare. DAISY and BRF provided."

    Click the "Bookshare" link to see all content affiliated with them.

  • NSF Partnership display tagshide tags

    This module is included inLens: NSF Partnership in Signal Processing
    By: Sidney BurrusAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Click the "NSF Partnership" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

  • Featured Content display tagshide tags

    This module is included inLens: Connexions Featured Content
    By: ConnexionsAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Comments:

    "A First Course in Electrical and Computer Engineering provides readers with a comprehensive, introductory look at the world of electrical engineering. It was originally written by Louis Scharf […]"

    Click the "Featured Content" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Also in these lenses

  • UniqU content

    This module is included inLens: UniqU's lens
    By: UniqU, LLCAs a part of collection: "A First Course in Electrical and Computer Engineering"

    Click the "UniqU content" link to see all content selected in this lens.

  • Lens for Engineering

    This module is included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Vector Graphics: Three-Dimensional Homogeneous Coordinates

Module by: Louis Scharf. E-mail the author

Note:

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.

We now consider the storage and manipulation of three-dimensional objects. We will continue to use homogeneous coordinates so that translation can be included in composite operators. Homogeneous coordinates in three dimensions will also allow us to do perspective projections so that we can view a three-dimensional object from any point in space.

Image Representation. The three-dimensional form of the point matrix in homogeneous coordinates is

G = x 1 x 2 x 3 ... x n y l y 2 y 3 ... y n z 1 z 2 z 3 ... z n 1 1 1 ... 1 R 4 × n . G = x 1 x 2 x 3 ... x n y l y 2 y 3 ... y n z 1 z 2 z 3 ... z n 1 1 1 ... 1 R 4 × n .
(1)

The line matrix H H is exactly as before, pointing to pairs of columns in G G to connect with lines. Any other grouping matrices for objects, etc., are also unchanged.

Image manipulations are done by a 4×44×4 matrix A. To ensure that the fourth coordinate remains a 1, the operator A must have the structure

A=a11a12a13a14a21a22a23a24a31a32a33a340001. A=a11a12a13a14a21a22a23a24a31a32a33a340001.
(2)

The new image has point matrix

G n e w = A G . G n e w = A G .
(3)

Exercise 1

If the coordinates of the ithith point in G are (xi,yi,zi,1)(xi,yi,zi,1), what are the coordinates of the ithith point in Gnew=Gnew= AG when A is as given in Equation 2?

Exercise 2

Write down the point matrix G G for the unit cube (the cube with sides of length 1, with one corner at the origin and extending in the positive direction along each axis). Draw a sketch of the cube, numbering the vertices according to their order in your point matrix. Now write down the line matrix H H to complete the representation of the cube.

Left- and Right-Handed Coordinate Systems. In this book we work exclusively with right-handed coordinate systems. However, it is worth pointing out that there are two ways to arrange the axes in three dimensions. Figure 1(a) shows the usual right-handed coordinates, and the left-handed variation is shown in Figure 1(b). All possible choices of labels x,yx,y, and z z for the three coordinate axes can be rotated to fit one of these two figures, but no rotation will go from one to the other.

Figure 1: Three-Dimensional Coordinate Systems; (a) Right-handed, and (b) Left-handed
(a) (b)
Figure one contains two three-dimensional coordinate systems, showing the difference between the right-handed and left-handed methods of representing objects in three dimensional space. Part a, or the right-handed method, shows an axis pointing towards the reader labeled, x, an axis pointing to the right labeled y, and an axis pointing up labeled z. Part b, or the left-handed method, shows an axis pointing towards the reader labeled y, an axis pointing to the right labeled x, and an axis pointing up labeled z.Figure 1(b) (pic005.png)

Be careful to sketch a right-handed coordinate system when you are solving problems in this chapter. Some answers will not be the same for a left-handed system.

Image Transformation. Three-dimensional operations are a little more complicated than their two-dimensional counterparts. For scaling and translation we now have three independent directions, so we generalize the operators of Equation 10 from "Vector Graphics: Homogeneous Coordinates" as

S ( s x , s y , s z ) = s x 0 0 0 0 s y 0 0 0 0 s z 0 0 0 0 1 T ( t x , t y , t z ) = 1 0 0 t x 0 1 0 t y 0 0 1 t z 0 0 0 1 . S ( s x , s y , s z ) = s x 0 0 0 0 s y 0 0 0 0 s z 0 0 0 0 1 T ( t x , t y , t z ) = 1 0 0 t x 0 1 0 t y 0 0 1 t z 0 0 0 1 .
(4)

Exercise 3

Show that T(-tx,-ty,-tz)T(-tx,-ty,-tz) is the inverse of T(tx,ty,tz).T-1T(tx,ty,tz).T-1 undoes the work of T T.

Rotation may be done about any arbitrary line in three dimensions. We will build up to the general case by first presenting the operators that rotate about the three coordinate axes. Rx(θ)Rx(θ) rotates by angle θ θ about the x-axis, with positive θ θ going from the y-axis to the z-axis, as shown in Figure 2. In a similar fashion, positive rotation about the y-axis using Ry(θ)Ry(θ) goes from z z to x x, and positive rotation about the z-axis goes from x x to y y, just as in two dimensions. We have the fundamental rotations

R x ( θ ) = 1 0 0 0 0 c o s θ - s i n θ 0 0 s i n θ c o s θ 0 0 0 0 1 R y ( θ ) = c o s θ 0 s i n θ 0 0 1 0 0 - s i n θ 0 c o s θ 0 0 0 0 1 R z ( θ ) = c o s θ - s i n θ 0 0 s i n θ c o s θ 0 0 0 0 1 0 0 0 0 1 . R x ( θ ) = 1 0 0 0 0 c o s θ - s i n θ 0 0 s i n θ c o s θ 0 0 0 0 1 R y ( θ ) = c o s θ 0 s i n θ 0 0 1 0 0 - s i n θ 0 c o s θ 0 0 0 0 1 R z ( θ ) = c o s θ - s i n θ 0 0 s i n θ c o s θ 0 0 0 0 1 0 0 0 0 1 .
(5)

A more general rotation about any line through the origin can be constructed by composition of the three fundamental rotations. Finally, by composing translation with the fundamental rotations, we can build an operator that rotates about any arbitrary line in space.

Figure 2: Directions of Positive Rotation
Figure two shows three right-handed three-dimensional graphs showing possible directions of positive rotation. The first shows an arc rotating the y-axis towards the z-axis in a counter-clockwise direction. The arc is labeled R_x (θ). the second shows an arc rotating the z-axis towards the x-axis, moving towards the reader, or looking from the right, in a counter-clockwise direction. The arc is labeled R_y (θ). The third shows an arc rotating the x-axis towards the y-axis, which, looking from above, would be in a counter-clockwise direction. The arc is labeled R_z (θ).

Example 1

To rotate by angle φ φ about the line LL, which lies in the x - y x-y plane in Figure 3, we would

  1. rotate LL to the x-axis with Rz(-θ)Rz(-θ);
  2. rotate by φ φ about the x-axis with Rx(φ)Rx(φ); and
  3. rotate back to LL with Rz(θ)Rz(θ).

The composite operation would be

A ( θ , φ ) = R z ( θ ) R x ( φ ) R z ( - θ ) . A ( θ , φ ) = R z ( θ ) R x ( φ ) R z ( - θ ) .
(6)
Figure 3: Composition of Rotations
Figure three shows a right-handed three-dimensional graph that contains a line L pointing below the x-y plane. The angle from L to the positive x-axis is measured and labeled θ. Around the line L is an arrow describing rotation about the line, and it is labeled Φ.

Direction Cosines. As discussed in the chapter on Linear Algebra, a vector v v may be specified by its coordinates (x,y,z)(x,y,z) or by its length and direction. The length of v v is ||v||||v||, and the direction can be specified in terms of the three direction cosines ( cosθxcosθx, cosθycosθy, cosθzcosθz). The angle θ x θ x is measured between the vector v v and the x-axis or, equivalently, between the vector v v and the vector ex=ex=[100]T[100]T. We have

cos θ x = ( v , e x ) | | v | | | | e x | | = x | | v | | cos θ x = ( v , e x ) | | v | | | | e x | | = x | | v | |
(7)

Likewise, θ y θ y is measured between v v and ey=[010]Tey=[010]T, and θ z θ z is measured between v v and ez=[001]Tez=[001]T. Thus

cos θ y = y | | v | | cos θ z = z | | v | | cos θ y = y | | v | | cos θ z = z | | v | |
(8)

The vector

u = cos θ x cos θ y cos θ z u = cos θ x cos θ y cos θ z
(9)

is a unit vector in the direction of v v, so we have

v=||v||u=||v||cosθxcosθycosθz.v=||v||u=||v||cosθxcosθycosθz.
(10)

Exercise 4

Show that u u is a unit vector (i.e. 1 u||=1u||=1).

The direction cosines are useful for specifying a line in space. Instead of giving two points P 1 P 1 and P 2 P 2 on the line, we can give one point P 1 P 1 plus the direction cosines of any vector that points along the line. One such vector is the vector from P 1 P 1 to P 2 P 2 .

Arc tangents. Consider a vector v=xyv=xy in two dimensions. We know that

tan θ = y x tan θ = y x
(11)

for the angle θ θ shown in Figure 4. If we know x x and y y, we can find θ θ using the arc tangent function

θ=tan-1(yx).θ=tan-1(yx).
(12)
Figure 4: Tangent and Arc Tangent
Figure four displays a two-dimensional cartesian graph with labeled quadrants I, II, III, and IV, and a line segment pointing from the origin to a point V in the first quadrant. The angle from the line segment to the x-axis is labeled θ. A dashed line drawn horizontally from point V to its vertical value on the y-axis is labeled y, and a dashed line drawn vertically from point V to its horizontal value on the x-axis is labeled x.

In MATLAB,

theta = atan(y/x)

Unfortunately, the arc tangent always gives answers between -π2-π2 and π2π2 corresponding to points v v in quadrants I and IV. The problem is that the ratio - y - x - y - x is the same as the ratio ---xA---xA so quadrant III cannot be distinguished from quadrant I by the ratio y x y x Likewise, quadrants II and IV are indistinguishable.

The solution is the two-argument arc tangent function. In MATLAB,

theta = atan2(y,x)

will give the true angle θθ -π-π and π π in any of the four quadrants.

Example 2

Consider the direction vector u=cosθxcosθycosθzu=cosθxcosθycosθz, as shown in Figure 5. What is the angle φ y φ y between the projection of u u into the x-yx-y plane and the y-axis? This is important because it is Rz(φy)Rz(φy) that will put u u in the y-zy-z plane, and we need to know the angle φ y φ y in order to carry out this rotation. First note that it is not the same as θ y θ y . From the geometry of the figure, we can write

tanφy=cosθxcosθytanφy=cosθxcosθy
(13)

This gives us a formula for φ y φ y in terms of the direction cosines of u u. With the two-argument arc tangent, we can write

φy=tan-1(cosθx,cosθy).φy=tan-1(cosθx,cosθy).
(14)
Figure 5: Angles in Three Dimensions
Figure five shows a right-handed three-dimensional graph with one arrow labeled u pointed towards the reader in a positive x, y, and z direction. there are four dashed line segments. The first is a line directly downward from u's highest point to a spot below on the x-y plane. The second is a projection of u onto the x-y plane, or in other words, a dashed line from the origin to the spot on the x-y plane directly below u's highest point. The third and fourth come from that same spot and make a rectangle on the x-y plane by connecting this spot directly to the y-axis and perpendicularly to the x-axis. The ends of these two line segments are labeled cos θ_y and cos θ_x on their respective axes. There are also numerous arcs measuring angles from u to the axes and some of the dashed line segments. One arc from u to the x-axis is labeled θ_x. Another measures the angle projected line segment under u to the y-axis, and is labeled Φ_y. A third measures the angle from u to the positive z-axis and is labeled θ_z. A final arc measures from the y-axis to u and is labeled θ_y.

Exercise 5

  1. Suppose point p ' p' is in the y - z y-z plane in three dimensions, p'=(0,y','',1)p'=(0,y','',1). Find θ θ so that Rx(θ)Rx(θ) will rotate p ' p' to the positive z-axis. (Hint: Use the two-argument arc tangent. θ θ will be a function of y'y' and z'.z'.)
  2. Let p p be any point in three-dimensional space, p=(x,y,z,1)p=(x,y,z,1). Find ψ ψ so that Rz(ψ)Rz(ψ) rotates p p into the y - z y-z plane. (Hint: Sketch the situation in three-dimensions, then sketch a two-dimensional view looking down at the x - y x-y plane from the positive z-axis. Compare with Example 2.) Your answers to parts (a) and (b) can be composed into an operator Z(p)Z(p) that rotates a given point p p to the positive z-axis, Z(p)=Rx(θ)Rz(ψ)Z(p)=Rx(θ)Rz(ψ).
  3. Let LL be a line in three-dimensional space specified by a point 1 ==(x,y,z,1)(x,y,z,1) and the direction cosines ( cosθxcosθx, cosθycosθy, cosθzcosθz). Use the following procedure to derive a composite operator R(φ,L)R(φ,L) that rotates by angle φ about the line LL:
    1. translate 1 to the origin;
    2. let u=u=( cosθxcosθx, cosθycosθy, cosθz,1cosθz,1) and use Z(u)Z(u) to align LL with the z-axis;
    3. rotate by φ φ about the z-axis;
    4. undo step (ii); and
    5. undo step (i).

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks