Misplaced Pages

Homogeneous coordinate system: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editContent deleted Content addedVisualWikitext
Revision as of 03:21, 26 July 2008 edit117.198.161.59 (talk)No edit summary← Previous edit Latest revision as of 22:03, 25 November 2022 edit undo1234qwer1234qwer4 (talk | contribs)Extended confirmed users, Page movers197,958 edits Added {{R from duplicated article}} and {{R from related word}} tags to redirectTag: Twinkle 
(9 intermediate revisions by 7 users not shown)
Line 1: Line 1:
#REDIRECT ]
A '''homogeneous coordinate system''' is a ] in which there is an extra ], used most commonly in ] to specify whether the given coordinates represent a ] (if the last coordinate is zero) or a ] (if the last coordinate is non-zero). A homogeneous coordinate system is used by ] for representing position.


{{Redirect category shell|
{{Comp-sci-stub}}
{{R from duplicated article}}
Homogeneous Coordinates
{{R from related word}}

}}
For reasons that hopefully will become clear in a moment, it's useful to represent 3D points in computer graphics using a 4-vector coordinate system, known as homogeneous coordinates.

To represent a point (x,y,z) in homogeneous coordinates, we add a 1 in the fourth column:


1. (x,y,z) -> (x,y,z,1)


To map an arbitrary point (x,y,z,w) in homogenous coordinates back to a 3D point, we divide the first three terms by the fourth (w) term. Thus:


2. (x,y,z,w) -> (x/w, y/w, z/w)


This sort of transformation has a few uses. For example, recall that one equation for determining points on a plane is the equation:


3. A point is on a plane if the point
satifies the relationship

0 == A*x + B*y + C*z + D


We can use this to our advantage by representing a plane L = (A,B,C,D). It is trivial to see that a point is on the plane L if


4. P dot L == 0


What makes this relationship interesting that if we have a "normalized" homogeneous point P and a "normalized" plane L, defined as:


A homogeneous point P = (x,y,z,w) is
normalized iff w == 1.

Likewise, a homogeneous plane L = (A,B,C,D)
is normalized iff sqrt(A*A+B*B+C*C) == 1.


then the dot product is the "signed" distance of the point P from the plane L. This can be a useful relationship for hit detection or collision detection, when we wish to determine where a path from P1 to P2 intersects L. In that case, we can easily calculate the intersection point P by:


a1 = P1 dot L;
a2 = P2 dot L;
a = a1 / (a1 - a2);
P = (1-a)*P1 + a*P2


This is useful when we need to do clipping of lines and polygons to fit inside the screen, as well as in performing collision detection.

Transforming Homogeneous Coordinates

We can represent rotation, scaling, and translation using homogeneous coordinates by using a 4x4 matrix. Note that if we were to simply restrict ourselves to a 3x3 matrix, we could not perform translations-in that case, we would have to explicitly add. But using a full 4x4 matrix, not only can we represent a translation using a 4x4 matrix, but we can derive all sorts of interesting properties, including easily translating back from screen coordinates to world coordinates.

The standard transformation matricies used in computer graphics are:


Translation:

T(x,y,z) = | 1 0 0 0 |
| 0 1 0 0 |
| 0 0 1 0 |
| x y z 1 |



Scaling:

S(x,y,z) = | x 0 0 0 |
| 0 y 0 0 |
| 0 0 z 0 |
| 0 0 0 1 |



Rotation about X axis:

Rx(angle)= | 1 0 0 0 |
| 0 c s 0 |
| 0 -s c 0 |
| 0 0 0 1 |

where c = cosine(angle)
s = sine(angle)



Rotation about Y axis:

Ry(angle)= | c 0 -s 0 |
| 0 1 0 0 |
| s 0 c 0 |
| 0 0 0 1 |

where c = cosine(angle)
s = sine(angle)



Rotation about Z axis:

Rz(angle)= | c s 0 0 |
| -s c 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |

where c = cosine(angle)
s = sine(angle)


To use these matricies, you would post-multiply the homogeneous point P by the matrix. Thus, to rotate the point around all three axises, and then translate to a new location, you would do:

P' = P * Rx * Ry * Rz * T

(Note: to post-multiply, you would perform the following operation:


P * M =
(x y z w) * | a b c d | =
| e f g h |
| i j k l |
| m n p q |
(x' y' z' w')

where x' = x*a + y*e + z*i + w*m
y' = x*b + y*f + z*j + w*n
z' = x*c + y*g + z*k + w*p
w' = x*d + y*h + z*l + w*q


Normally this is implemented using a for loop, and is expanded explicitly just so it's clear in what order the rows and columns are evaluated.)

What makes this an interesting thing to do is that as the multiplication of matricies is associative, instead of performing four matrix multiplies for each point we want to transform, we can instead multiply the four matricies together into a single matrix, and perform one point/matrix multiply for each point we transform. This is especially useful when we don't know apriori the number of translations that need to be performed to a collection of points.

Latest revision as of 22:03, 25 November 2022

Redirect to:

This page is a redirect. The following categories are used to track and monitor this redirect:
  • From a duplicated article: This is a redirect from a page on the same or very similar subject matter that was kept as a redirect to preserve this page's edit history after the content was merged.
    • Please do not delete this redirect nor remove this tag unless the need to recreate this article is demonstrated.
  • From a related word or phrase: This is a redirect from a word or phrase (term) to a page title that is related in some way. This redirect might be a good search term, or it could be a candidate for a Wiktionary link.
    • Redirects from related words are not properly redirects from alternative spellings of the same word. They are also different from redirects that are subtopics or related topics, because unlike those, a related word or phrase probably does not warrant its own subtopic section in the target page or possess the possibility of ever becoming an article, template, project page, and so forth.
When appropriate, protection levels are automatically sensed, described and categorized.