Open In App

Computer Graphics Homogeneous Coordinates

Improve
Improve
Like Article
Like
Save
Share
Report

Many computer graphics face issues in displaying three-dimensional objects on a two-dimensional screen. We would like to rotate, translate and scale our objects to view them from arbitrary points of view, view as per our perspective. We would like to display our objects in a coordinate system which the system is convenient for us and we can able to reuse them whenever it is required.

Homogeneous coordinates will have some neutral applications in computer graphics, they form the basis for geometry which is used extensively to display three-dimensional objects on two-dimensional image planes. Homogeneous coordinate provides a standard to perform certain standard operations on points in euclidean space means matrix multiplication.

Homogeneous coordinate systems are used in two ways in computer graphics. One of them is by taking an extra value(for example taking the third element in two dimensions and the fourth element in three dimensions) extra element can be any value that will be the divisor of other components which is used occasionally. The restricted form of homogeneous coordinate is also valuable in computer graphics it solves problems in representing and implementing transformations of geometric objects. Most graphics are represented by matrices, and applied for vectors in cartesian form, by taking vectors as column vectors and multiplying them by the transformation’s matrix.

Homogeneous coordinate systems mean expressing each coordinate as a homogeneous coordinate to represent all geometric transformation equations as matrix multiplication. The transformed matrix can be expressed in general matrix form.

   a'=b1.a+b2    

a and a’ are column vectors b1 is a 2 by 2 array containing multiplicative factor and b2 is a two-element column matrix containing translation terms.

converting old second coordinate into homogeneous coordinate:

old coordinate=(x,y) to 3d

xh=x.h, yh=y.h    new 3d coordinate is (xh,yh,h), and we can convert the new 3d coordinate into old coordinate by dividing with h.

new coordinate=(xh,yh,h) x=xh/h y=yh/h, old coordinate(x,y)

Now take an example for convert (3,4) into a homogeneous coordinate if h=2.

new coordinate=(3*2,4*2,h)

                                =(6,8,h)

Converting two-dimensional into three-dimensional vectors, these are used in design and construction applications in these we use translation, rotation, and scaling to transform then and to fit an image in the proper position.

Translation:

It will shift the object from one position to another position, with the given translation in the x or y axis to translate a point from coordinate position (x,y) to another (x,y) we add algebraically the translation distances tx and ty to the original coordinates  x1= x + tx, y1 = y +ty.

\begin{bmatrix} & x' \\ &  y'\\ \end{bmatrix} = \begin{bmatrix} x \\ y \end{bmatrix} + \begin{bmatrix} dx \\ dy \end{bmatrix}

Example:  a(2,2), b(10,2), c(5,5) translate the triangle with dx=5 dy=6.

   a’=a+ t 

\begin{bmatrix} & 2 \\ & 2 \\ \end{bmatrix} + \begin{bmatrix} 5 \\ 6 \end{bmatrix} = \begin{bmatrix} 7 \\ 8 \end{bmatrix}

b’=b +t    

c’=c +t 

\begin{bmatrix} & 5 \\ & 5 \\ \end{bmatrix} + \begin{bmatrix} 5 \\ 6 \end{bmatrix} = \begin{bmatrix} 10\\ 11 \end{bmatrix}

Rotation:

Rotating of an object will be always respective with an angle in the plane. Suppose initial coordinates p(x,y,z), initial angle= sie and rotation angle = theta, then  we can perform three types of rotations i.e x-axis, y-axis, & z-axis.

x-axis
x'=x
y'=ycos(theta) - zsin(theta)
z'=ysin(theta) + zcos(theta)

\begin{bmatrix} & x' \\ & y'\\ & z'\\ & 1 \end{bmatrix} = \begin{bmatrix} 1 &  0 & 0  &  0 \\ 0 &  cos \Theta  & -sin \Theta & 0 \\ 0 &  sin \Theta &  cos \Theta &  0\\ 0 &  0 &  0 &  1\\ \end{bmatrix} * \begin{bmatrix} x \\ y \\ z\\ 1 \end{bmatrix}

y-axis
x'= zsin(theta) + xcos(theta)
y' = y
z' = zcos(theta) - xsin(theta)

\begin{bmatrix} & x' \\ & y'\\ & z'\\ & 1 \end{bmatrix} = \begin{bmatrix} cos \Theta &  0 & sin \Theta &  0 \\ 0 &  1  &  0 & 0 \\ -sin \Theta & 0  &  cos \Theta &  0\\ 0 &  0 &  0 &  1\\ \end{bmatrix} * \begin{bmatrix} x \\ y \\ z\\ 1 \end{bmatrix}

z-axis
x'= xcos(theta) - ysin(theta)
y' = xsin(theta) + ycos(theta)
z'= z

\begin{bmatrix} & x' \\ & y'\\ & z'\\ & 1 \end{bmatrix} = \begin{bmatrix} cos \Theta &  -sin \Theta & 0 &  0 \\ sin \Theta &  cos \Theta  & 0 & 0\\ 0 &  0  &  1 & 0 \\ 0 &  0 &  0 &  1\\ \end{bmatrix} * \begin{bmatrix} x \\ y \\ z\\ 1 \end{bmatrix}

Example : p(1,2,3) theta=90

x'=x=1
y'=ycos(theta)-zsin(theta) 
=> 2cos90-3sin90 
=>  -3
z' = ysin(theta)+zcos(theta) 

=> 2sin90+3cos90 => 2

Scaling:

Scaling is the transformation that will change the object size, based on scaling factors sx, sy, sz along the x-axis, y-axis, and z-axis 

p' = s*p

\begin{bmatrix} & x' \\ & y'\\ & z'\\ & 1 \end{bmatrix} = \begin{bmatrix} sx &  0 & 0 &  0 \\ 0 &  sy  & 0 & 0\\ 0 &  0  &  sz & 0 \\ 0 &  0 &  0 &  0\\ \end{bmatrix} * \begin{bmatrix} x \\ y \\ z\\ 1 \end{bmatrix}

if s.f=1, object size will not change.
s.f>1, object size enlarges.
s.f<1,object size will reduce.         

Scaling of an object with respect to a fixed point (a,b,c)

  • scale the object relative to the origin
  • translate fixed point to the origin
  • translate object back to its original position 

Advantages:

Points at infinity can be represented by finite coordinates used extensively in graphics because they perform translation, scaling, and rotation to implement matrix operations in some cases, homogeneous coordinates handle points at infinity.

Disadvantages:

Effect on efficiency requires more space for 4 tuples than 3 4X4 matrix requires more multiplications and additions. 



Last Updated : 25 Jan, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads