Computer Graphics Homogeneous Coordinates
Last Updated :
25 Jan, 2023
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.
Similar Reads
Clipping in Homogeneous Coordinates Clipping in homogeneous coordinates is a method used in computer graphics to remove any part of a 3D object that is outside of the viewing frustum (the visible area of the 3D scene). This is done by transforming the 3D object into homogeneous coordinates and then applying a series of clipping planes
8 min read
Computer Graphics Rotation Rotation is one of the part of computer graphic's transformation, Transformation means to change some graphics into something else with the help of rules. There are various types of transformations like translation, scaling, rotation, shearing, reflection etc. it helps to change the object's positio
3 min read
Geometric Computing in Computer Graphics Geometry is also called the Mathematics of the universe. Everything in the universe exhibits alignment with various geometric forms. Similarly, it is used in various fields to create video games, films, and even design software rooted in geometric computing. if you have a good knowledge of fundament
6 min read
Projections in Computer Graphics Representing an n-dimensional object into an n-1 dimension is known as projection. It is process of converting a 3D object into 2D object, we represent a 3D object on a 2D plane {(x,y,z)->(x,y)}. It is also defined as mapping or transforming of the object in projection plane or view plane. When g
5 min read
Computer Graphics Curve in Computer Graphics In computer graphics, we often need to draw different types of objects onto the screen. Objects are not flat all time and we need to draw curves many times to draw an object. Types of Curves:The curve is an infinitely large set of points. Each point has two neighbors except endpoints. Implicit curve
7 min read
Computer Graphics - 3D Composite Transformation 3-D Transformation is the process of manipulating the view of a three-D object with respect to its original position by modifying its physical attributes through various methods of transformation like Translation, Scaling, Rotation, Shear, etc. Types of Transformation: Translation TransformationScal
6 min read