Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
The electron beam passes through focusing and deflection systems that
direct it towards specified positions on the phosphor-coated screen.
When the beam hits the screen, the phosphor emits a small spot of light
at each position contacted by the electron beam.
It redraws the picture by directing the electron beam back over the same
screen points quickly.
There are two ways (Random scan and Raster scan) by which we can
display an object on the screen.
Raster Scan
In a raster scan system, the electron beam is swept across the
screen, one row at a time from top to bottom. As the electron beam
moves across each row, the beam intensity is turned on and off to
create a pattern of illuminated spots.
Picture definition is stored in memory area called the Refresh
Buffer or Frame Buffer. This memory area holds the set of intensity
values for all the screen points. Stored intensity values are then
retrieved from the refresh buffer and painted on the screen one row
(scan line) at a time as shown in the following illustration.
Each screen point is referred to as a pixel (picture element) or pel.
At the end of each scan line, the electron beam returns to the left side
of the screen to begin displaying the next scan line.
Computer graphics user interfaces (GUIs) A graphic, mouseoriented paradigm which allows the user to interact with a computer.
Simulation
and
modeling
Replacing
physical
modeling
and
enactments
DDA Algorithm
Digital Differential Analyzer (DDA) algorithm is the simple line
generation algorithm which is explained step by step here.
Step 1 Get the input of two end points (X0,Y0)(X0,Y0) and (X1,Y1)
(X1,Y1).
dlower=yykdlower=yyk
=m(Xk+1)+bYk=m(Xk+1)+bYk
and
dupper=(yk+1)ydupper=(yk+1)y
=Yk+1m(Xk+1)b=Yk+1m(Xk+1)b
You can use these to make a simple decision about which pixel is
closer to the mathematical line. This simple decision is based on the
difference between the two pixel positions.
dlowerdupper=2m(xk+1)2yk+2b1dlowerdupper=2m(xk+1)2yk+2b1
Let us substitute m with dy/dx where dx and dy are the differences
between the end-points.
dx(dlowerdupper)=dx(2dydx(xk+1)2yk+2b1)dx(dlowerdupper)=dx(2
dydx(xk+1)2yk+2b1)
=2dy.xk2dx.yk+2dy+2dx(2b1)=2dy.xk2dx.yk+2dy+2dx(2b1)
=2dy.xk2dx.yk+C=2dy.xk2dx.yk+C
So, a decision parameter PkPk for the kth step along a line is given by
pk=dx(dlowerdupper)pk=dx(dlowerdupper)
=2dy.xk2dx.yk+C=2dy.xk2dx.yk+C
The sign of the decision parameter PkPk is the same as that
of dlowerdupperdlowerdupper.
If pkpk is negative, then choose the lower pixel, otherwise choose the
upper pixel.
Remember, the coordinate changes occur along the x axis in unit
steps, so you can do everything with integer calculations. At step
k+1, the decision parameter is given as
pk+1=2dy.xk+12dx.yk+1+Cpk+1=2dy.xk+12dx.yk+1+C
Subtracting pkpk from this we get
pk+1pk=2dy(xk+1xk)2dx(yk+1yk)pk+1pk=2dy(xk+1xk)
2dx(yk+1yk)
pk+1=pk+2dy2dx(yk+1yk)pk+1=pk+2dy2dx(yk+1yk)
Where, Yk+1YkYk+1Yk is either 0 or 1 depending on the sign
of PkPk.
The first decision parameter p0p0 is evaluated at (x0,y0)(x0,y0) is
given as
p0=2dydxp0=2dydx
Now, keeping in mind all the above points and calculations, here is
the Bresenham algorithm for slope m < 1
Step 1 Input the two end-points of line, storing the left end-point
in (x0,y0)(x0,y0).
Step 2 Plot the point (x0,y0)(x0,y0).
Step 3 Calculate the constants dx, dy, 2dy, and (2dy 2dx) and
get the first value for the decision parameter as
p0=2dydxp0=2dydx
Step 4 At each XkXk along the line, starting at k = 0, perform the
following test
If pkpk < 0, the next point to plot is (xk+1,yk)(xk+1,yk) and
pk+1=pk+2dypk+1=pk+2dy
Otherwise,
pk+1=pk+2dy2dxpk+1=pk+2dy2dx
Step 5 Repeat step 4 (dx 1) times.
For m > 1, find out whether you need to increment x while
incrementing y each time.
After solving, the equation for decision parameter PkPk will be very
similar, just the x and y in the equation gets interchanged.
Mid-Point Algorithm
Mid-point algorithm is due to Bresenham which was modified by
Pitteway and Van Aken. Assume that you have already put the point P
Bresenhams Algorithm
We cannot display a continuous arc on the raster display. Instead, we
have to choose the nearest pixel position to complete the arc.
From the following illustration, you can see that we have put the pixel
at (X, Y) location and now need to decide where to put the next pixel
at N (X+1, Y) or at S (X+1, Y-1).
Algorithm
Step 1 Get the coordinates of the center of the circle and radius,
and store them in x, y, and R respectively. Set P=0 and Q=R.
Step 2 Set decision parameter D = 3 2R.
Step 3 Repeat through step-8 while X < Y.
Step 4 Call Draw Circle (X, Y, P, Q).
Step 5 Increment the value of P.
Step 6 If D < 0 then D = D + 4x + 6.
Step 7 Else Set Y = Y + 1, D = D + 4(X-Y) + 10.
Step 8 Call Draw Circle (X, Y, P, Q).
Draw Circle Method(X, Y, P, Q).
f(xi - 1/2 + e, yi + 1)
= (xi - 1/2 + e)2 + (yi + 1)2 - r2
= (xi- 1/2)2 + (yi + 1)2 - r2 + 2(xi - 1/2)e + e2
= f(xi - 1/2, yi + 1) + 2(xi - 1/2)e + e2 = 0
4-Connected Polygon
In this technique 4-connected pixels are used as shown in the figure.
We are putting the pixels above, below, to the right, and to the left
side of the current pixels and this process will continue until we find a
boundary with different color.
Algorithm
Step 1 Initialize the value of seed point (seedx, seedy), fcolor and
dcol.
Step 2 Define the boundary values of the polygon.
Step 3 Check if the current seed point is of default color, then
repeat the steps 4 and 5 till the boundary pixels reached.
If getpixel(x, y) = dcol then repeat step 4 and 5
Step 4 Change the default color with the fill color at the seed point.
Step 6 Exit
There is a problem with this technique. Consider the case as shown
below where we tried to fill the entire region. Here, the image is filled
only partially. In such cases, 4-connected pixels technique cannot be
used.
8-Connected Polygon
In this technique 8-connected pixels are used as shown in the figure.
We are putting pixels above, below, right and left side of the current
pixels as we were doing in 4-connected technique.
In addition to this, we are also putting pixels in diagonals so that
entire area of the current pixel is covered. This process will continue
until we find a boundary with different color.
Algorithm
Step 1 Initialize the value of seed point (seedx, seedy), fcolor and
dcol.
Step 2 Define the boundary values of the polygon.
Step 3 Check if the current seed point is of default color then
repeat the steps 4 and 5 till the boundary pixels reached
If getpixel(x,y) = dcol then repeat step 4 and 5
Step 4 Change the default color with the fill color at the seed point.
setPixel(seedx, seedy, fcol)
Step 6 Exit
The 4-connected pixel technique failed to fill the area as marked in
the following figure which wont happen with the 8-connected
technique.
Inside-outside Test
This method is also known as counting number method. While
filling an object, we often need to identify whether particular point is
inside the object or outside it. There are two methods by which we
can identify whether particular point is inside an object or outside.
Odd-Even Rule
Odd-Even Rule
In this technique, we count the edge crossing along the line from any
point (x, y) to infinity. If the number of interactions is odd then the
point (x, y) is an interior point. If the number of interactions is even
then point (x, y) is an exterior point. Here is the example to give you
the clear idea
From the above figure, we can see that from the point (x, y), the
number of interactions point on the left side is 5 and on the right side
is 3. So the total number of interaction point is 8, which is odd.
Hence, the point is considered within the object.
Give the value 1 to all the edges which are going to upward direction and
all other -1 as direction values.
Check the edge direction values from which the scan line is passing and
sum up them.
If the total sum of this direction value is non-zero, then this point to be
tested is an interior point, otherwise it is an exterior point.
In the above figure, we sum up the direction values from which the scan
line is passing then the total is 1 1 + 1 = 1; which is non-zero. So the
point is said to be an interior point.
Point Clipping
Clipping a point from a given window is very easy. Consider the
following figure, where the rectangle indicates the window. Point
clipping tells us whether the given point (X, Y) is within the given
window or not; and decides whether we will use the minimum and
maximum coordinates of the window.
The X-coordinate of the given point is inside the window, if X lies in
between Wx1 X Wx2. Same way, Y coordinate of the given point
is inside the window, if Y lies in between Wy1 Y Wy2.
Line Clipping
The concept of line clipping is same as point clipping. In line clipping,
we will cut the portion of line which is outside of window and keep
only the portion that is inside the window.
We will use 4-bits to divide the entire region. These 4 bits represent
the Top, Bottom, Right, and Left of the region as shown in the
following figure. Here, theTOP and LEFT bit is set to 1 because it is
the TOP-LEFT corner.
Line can be completely inside the window (This line will be completely
removed from the region).
Line can be completely outside of the window (This line will be completely
removed from the region).
Line can be partially inside the window (We will find intersection point and
draw only that portion of line that is inside region).
Algorithm
Step 1 Assign a region code for each endpoints.
Step 2 If both endpoints have a region code 0000 then accept this
line.
Step 3 Else, perform the logical ANDoperation for both region
codes.
Step 3.1 If the result is not 0000, then reject the line.
Step 3.2 Else you need clipping.
Step 3.2.1 Choose an endpoint of the line that is outside the
window.
Step 3.2.2 Find the intersection point at the window boundary
(base on region code).
Step 3.2.3 Replace endpoint with the intersection point and update
the region code.
Step 3.2.4 Repeat step 2 until we find a clipped line either trivially
accepted or trivially rejected.
Step 4 Repeat step 1 for other lines.
Let Ni be the outward normal edge Ei. Now pick any arbitrary point
PEi on edge Ei then the dot product Ni[P(t) PEi] determines whether
the point P(t) is inside the clip edge or outside the clip edge or
on the clip edge.
The point P(t) is inside if Ni.[P(t) PEi] < 0
The point P(t) is outside if Ni.[P(t) PEi] > 0
The point P(t) is on the edge if Ni.[P(t) PEi] = 0 (Intersection point)
Ni.[P(t) PEi] = 0
Ni.[ P0 + t(P1-P0) PEi] = 0 (Replacing P(t) with P0 + t(P1-P0))
Ni.[P0 PEi] + Ni.t[P1-P0] = 0
Ni.[P0 PEi] + NitD = 0 (substituting D for [P1-P0])
Ni.[P0 PEi] = - NitD
t=Ni.[PoPEi]Ni.Dt=Ni.[PoPEi]Ni.D
It is valid for the following conditions
D 0 (P1 P0)
Text Clipping
Various techniques are used to provide text clipping in a computer
graphics. It depends on the methods used to generate characters and
the requirements of a particular application. There are three methods
for text clipping which are listed below
Text clipping
In all or none string clipping method, either we keep the entire string
or we reject entire string based on the clipping window. As shown in
the above figure, STRING2 is entirely inside the clipping window so
we keep it and STRING1 being only partially inside the window, we
reject.
The following figure shows all or none character clipping
Bitmap Graphics
A bitmap is a collection of pixels that describes an image. It is a type
of computer graphics that the computer uses to store and display
pictures. In this type of graphics, images are stored bit by bit and
hence it is named Bit-map graphics. For better understanding let us
Now we will see how this smiley face is stored bit by bit in computer
graphics.
By observing the original smiley face closely, we can see that there
are two blue lines which are represented as B1, B2 and E1, E2 in the
above figure.
In the same way, the smiley is represented using the combination bits
of A4, B5, C6, D6, E5, and F4 respectively.
The main disadvantages of bitmap graphics are
We cannot resize the bitmap image. If you try to resize, the pixels get
blurred.
2D Transformation
Transformation means changing some graphics into something else by
applying rules. We can have various types of transformations such as
translation, scaling up or down, rotation, shearing, etc. When a
transformation takes place on a 2D plane, it is called 2D
transformation.
Transformations play an important role in computer graphics to
reposition the graphics on the screen and change their size or
orientation.
Homogenous Coordinates
To perform a sequence of transformation such as translation followed
by rotation and scaling, we need to follow a sequential process
Translation
A translation moves an object to a different position on the screen.
You can translate a point in 2D by adding translation coordinate (t x, ty)
to the original coordinate (X, Y) to get the new coordinate (X, Y).
Rotation
In rotation, we rotate the object at particular angle (theta) from its
origin. From the following figure, we can see that the point P(X, Y) is
located at angle from the horizontal X coordinate with distance r
from the origin.
Let us suppose you want to rotate it at the angle . After rotating it to
a new location, you will get a new point P (X, Y).
X=rcos......(1)X=rcos......(1)
Y=rsin......(2)Y=rsin......(2)
Same way we can represent the point P (X, Y) as
x=rcos(+)=rcoscosrsinsin.......(3)x
=rcos(+)=rcoscosrsinsin.......(3)
y=rsin(+)=rcossin+rsincos.......(4)y
=rsin(+)=rcossin+rsincos.......(4)
Substituting equation (1) & (2) in (3) & (4) respectively, we will get
x=xcosysinx=xcosysin
y=xsin+ycosy=xsin+ycos
Representing the above equation in matrix form,
[XY]=[XY][cossinsincos]OR[XY]=[XY][cossinsincos]OR
P = P R
R=[cossinsincos]R=[cossinsincos]
The rotation angle can be positive and negative.
For positive rotation angle, we can use the above rotation matrix.
However, for negative angle rotation, the matrix will change as shown
below
R=[cos()sin()sin()cos()]R=[cos()sin()sin()cos()]
=[cossinsincos]
(cos()=cosandsin()=sin)=[cossinsincos]
(cos()=cosandsin()=sin)
Scaling
To change the size of an object, scaling transformation is used. In the
scaling process, you either expand or compress the dimensions of the
object. Scaling can be achieved by multiplying the original coordinates
of the object with the scaling factor to get the desired result.
Let us assume that the original coordinates are (X, Y), the scaling
factors are (SX, SY), and the produced coordinates are (X, Y). This
can be mathematically represented as shown below
X' = X . SX and Y' = Y . SY
The scaling factor SX, SY scales the object in X and Y direction
respectively. The above equations can also be represented in matrix
form as below
(XY)=(XY)[Sx00Sy](XY)=(XY)[Sx00Sy]
OR
P = P . S
Where S is the scaling matrix. The scaling process is shown in the
following figure.
Reflection
Shear
A transformation that slants the shape of an object is called the shear
transformation. There are two shear transformations X-Shear and Y-
X-Shear
The X-Shear preserves the Y coordinate and changes are made to X
coordinates, which causes the vertical lines to tilt right or left as
shown in below figure.
Xsh=1shx0010001Xsh=[100shx10001]
X' = X + Shx . Y
Y = Y
Y-Shear
The Y-Shear preserves the X coordinates and changes the Y
coordinates which causes the horizontal lines to transform into lines
which slopes up or down as shown in the following figure.
Ysh100shy10001Ysh[1shy0010001]
Y = Y + Shy . X
X = X
Composite Transformation
If a transformation of the plane T1 is followed by a second plane
transformation T2, then the result itself may be represented by a
single transformation T which is the composition of T1 and T2 taken in
that order. This is written as T = T1T2.
Composite transformation can be achieved by concatenation of
transformation matrices to obtain a combined transformation matrix.
A combined matrix
[T][X] = [X] [T1] [T2] [T3] [T4] . [Tn]
Where [Ti] is any combination of
Translation
Scaling
Shearing
Rotation
Reflection
3D Computer Graphics
In the 2D system, we use only two coordinates X and Y but in 3D, an
extra coordinate Z is added. 3D graphics techniques and their
application are fundamental to the entertainment, games, and
computer-aided design industries. It is a continuing area of research
in scientific visualization.
Furthermore, 3D graphics components are now a part of almost every
personal computer and, although traditionally intended for graphicsintensive software such as games, they are increasingly being used by
other applications.
Parallel Projection
Parallel projection discards z-coordinate and parallel lines from each
vertex on the object are extended until they intersect the view plane.
In parallel projection, we specify a direction of projection instead of
center of projection.
In parallel projection, the distance from the center of projection to
project plane is infinite. In this type of projection, we connect the
projected vertices by line segments which correspond to connections
on the original object.
Parallel projections are less realistic, but they are good for exact
measurements. In this type of projections, parallel lines remain
parallel and angles are not preserved. Various types of parallel
projections are shown in the following hierarchy.
Orthographic Projection
In orthographic projection the direction of projection is normal to the
projection of the plane. There are three types of orthographic
projections
Front Projection
Top Projection
Side Projection
Oblique Projection
In orthographic projection, the direction of projection is not normal to
the projection of plane. In oblique projection, we can view the object
better than orthographic projection.
There are two types of oblique projections Cavalier and Cabinet.
The Cavalier projection makes 45 angle with the projection plane.
The projection of a line perpendicular to the view plane has the same
length as the line itself in Cavalier projection. In a cavalier projection,
the foreshortening factors for all three principal directions are equal.
The Cabinet projection makes 63.4 angle with the projection plane.
In Cabinet projection, lines perpendicular to the viewing surface are
projected at their actual length. Both the projections are shown in
the following figure
Isometric Projections
Orthographic projections that show more than one side of an object
are calledaxonometric orthographic projections. The most
common axonometric projection is an isometric projection where
the projection plane intersects each coordinate axis in the model
coordinate system at an equal distance. In this projection parallelism
of lines are preserved but angles are not preserved. The following
figure shows isometric projection
Perspective Projection
In perspective projection, the distance from the center of projection
to project plane is finite and the size of the object varies inversely
with distance which looks more realistic.
The distance and angles are not preserved and parallel lines do not
remain parallel. Instead, they all converge at a single point
called center of projection or projection reference point. There
are 3 types of perspective projections which are shown in the
following chart.
Translation
In 3D translation, we transfer the Z coordinate along with the X and Y
coordinates. The process for translation in 3D is similar to 2D
translation. A translation moves an object into a different position on
the screen.
The following figure shows the effect of translation
point
can
be
translated
in
3D
by
adding
translation
T=100tx010ty001tz0001T=[100001000010txtytz1]
P = PT
[X'Y'Z'1]=[XYZ1]100tx010ty001tz0001[XYZ1]=[XYZ1]
[100001000010txtytz1]
=[X+txY+tyZ+tz1]=[X+txY+tyZ+tz1]
3D Transformation
Rotation
3D rotation is not same as 2D rotation. In 3D rotation, we have to
specify the angle of rotation along with the axis of rotation. We can
perform 3D rotation about X, Y, and Z axes. They are represented in
the matrix form as below
Rx()=10000cossin00sincos00001Ry()=co
s0sin00100sin0cos00001Rz()=cossin00sin
cos0000100001Rx()=[10000cossin00sincos00001]Ry()=[cos0sin00
100sin0cos00001]Rz()=[cossin00sincos0000100001]
Scaling
You can change the size of an object using scaling transformation. In
the scaling process, you either expand or compress the dimensions of
the object. Scaling can be achieved by multiplying the original
coordinates of the object with the scaling factor to get the desired
result. The following figure shows the effect of 3D scaling
S=Sx0000Sy0000Sz00001S=[Sx0000Sy0000Sz00001]
P = PS
[XYZ1]=[XYZ1]Sx0000Sy0000Sz00001[XYZ1]=[XYZ1]
[Sx0000Sy0000Sz00001]
=[X.SxY.SyZ.Sz1]=[X.SxY.SyZ.Sz1]
Shear
A transformation that slants the shape of an object is called the shear
transformation. Like in 2D shear, we can shear an object along the
X-axis, Y-axis, or Z-axis in 3D.
Sh=1shxyshxz0shyx1shyz0shzxshzy100001Sh=[1shxysh
xz0shyx1shyz0shzxshzy100001]
P = P Sh
X=X+ShyxY+ShzxZX=X+ShxyY+ShxzZ
Y=ShxyX+Y+shzyZY=ShyxX+Y+shyzZ
Z=ShxzX+ShyzY+ZZ=ShzxX+ShzyY+Z
Transformation Matrices
Transformation matrix is a basic tool for transformation. A matrix with
n x m dimensions is multiplied with the coordinate of objects. Usually
3 x 3 or 4 x 4 matrices are used for transformation. For example,
consider the following matrix for various operation.
TS
==
Sh
=
1 Sx
00
0
00
0
Sy
t
x 00
0 00
1 Sz
0 00
t 00
y
0 1
0
1
t
z
0
1
sh
xy
sh
xz0
sh
yx1
sh
yz0
sh
zxs
hz
y1
00
00
S=
0 [S
x0
0 00
0S S
1 y0 h=
00 [1s
0S
z0 hx
ys
00 hx
01 z0s
] hy
x1
T
=
[
1
0
0
0
0
1
0
0
0
0
1
0
t
x
t
y
sh
yz
0s
hz
xs
hz
y1
00
00
1]
t
z
1
]
T
r
a
n
s
l
a
t
i
o
n
Sc Sh
ali ea
ng r
M Ma
at tri
rix x
M
a
t
r
i
x
R Ry Rz
x
( (
(
)= )=
)
=
co co
s s
0 si
n
1
00
0 si
n s
0
00 in
0
c
10 os
0
c 0s 0
o in 00
s 0
co 01
s s 00
i
n 00 00
00 1
0
1
0
R
z(
s
)=
i
[co
n Ry s
() si
c =[ n
o co 00
sin
s s
0si c
n os
0 00 0
10
0
sin
0 0
co
0 s
00
1 00
1]
R
x
(
)
=
[
1
0
0
0
0
c
o
s
s
i
n
0
0
s
i
n
00
01
00
00
1]
c
o
s
0
0
0
0
1
]
Rotatio
n
Matrix
Types of Curves
A curve is an infinitely large set of points. Each point has two
neighbors except endpoints. Curves can be broadly classified into
three categories explicit, implicit, and parametric curves.
Implicit Curves
Implicit curve representations define the set of points on a curve by
employing a procedure that can test to see if a point in on the curve.
Usually, an implicit curve is defined by an implicit function of the form
f(x, y) = 0
It can represent multivalued curves (multiple y values for an x value).
A common example is the circle, whose implicit representation is
x 2 + y2 - R 2 = 0
Explicit Curves
A mathematical function y = f(x) can be plotted as a curve. Such a
function is the explicit representation of the curve. The explicit
Parametric Curves
Curves having parametric form are called parametric curves. The
explicit and implicit curve representations can be used only when the
function is known. In practice the parametric curves are used. A twodimensional parametric curve has the following form
P(t) = f(t), g(t) or P(t) = x(t), y(t)
The functions f and g become the (x, y) coordinates of any point on
the curve, and the points are obtained when the parameter t is varied
over a certain interval [a, b], normally [0, 1].
Bezier Curves
Bezier curve is discovered by the French engineer Pierre Bzier.
These curves can be generated under the control of other points.
Approximate tangents by using control points are used to generate
curve. The Bezier curve can be represented mathematically as
k=0nPiBni(t)k=0nPiBin(t)
Where pipi is
the
set
of
points
the
Bni(t)=(ni)(1t)nttiBin(t)=(ni)(1t)ntti
Where n is the polynomial degree, i is the index, and t is the variable.
The simplest Bzier curve is the straight line from the
point P0P0 to P1P1. A quadratic Bezier curve is determined by three
control points. A cubic Bezier curve is determined by four control
points.
They generally follow the shape of the control polygon, which consists of
the segments joining the control points.
They always pass through the first and last control points.
They are contained in the convex hull of their defining control points.
The degree of the polynomial defining the curve segment is one less that
the number of defining polygon point. Therefore, for 4 control points, the
degree of the polynomial is 3, i.e. cubic polynomial.
The direction of the tangent vector at the end points is same as that of
the vector determined by first and last segments.
The convex hull property for a Bezier curve ensures that the polynomial
smoothly follows the control points.
No straight line intersects a Bezier curve more times than it intersects its
control polygon.
Bezier curves exhibit global control means moving a control point alters
the shape of the whole curve.
A given Bezier curve can be subdivided at a point t=t0 into two Bezier
segments which join together at the point corresponding to the
parameter value t=t0.
B-Spline Curves
The Bezier-curve produced by the Bernstein basis function has limited
flexibility.
First, the number of specified polygon vertices fixes the order of the
resulting polynomial which defines the curve.
The B-spline basis contains the Bernstein basis as the special case.
The B-spline basis is non-global.
A B-spline curve is defined as a linear combination of control points Pi
and B-spline basis function Ni,Ni, k (t) given by
the
Ni,k(t)Ni,k(t) are
ti:i=0,...n+Kti:i=0,...n+K
The Ni, k functions are described as follows
Ni,1(t)={1,0,ifu[ti,ti+1)OtherwiseNi,1(t)={1,ifu[ti,ti+1)0,Otherwise
and if k > 1,
Ni,k(t)=ttiti+k1Ni,k1(t)
+ti+ktti+kti+1Ni+1,k1(t)Ni,k(t)=ttiti+k1Ni,k1(t)+ti+ktti+kti+1Ni+1,k1(t)
and
t[tk1,tn+1)t[tk1,tn+1)
The sum of the B-spline basis functions for any parameter value is 1.
Each basis function has precisely one maximum value, except for k=1.
B-spline allows the local control over the curve surface because each
vertex affects the shape of a curve only over a range of parameter values
where its associated basis function is nonzero.
The curve line within the convex hull of its defining polygon.
Polygon Tables
In this method, the surface is specified by the set of vertex
coordinates and associated attributes. As shown in the following
figure, there are five vertices, from v1 to v5.
The Edge table is used to store the edge information of polygon. In the
following
figure,
edge
E1 lies
between
vertex
v1 and
v2 which
is
Plane Equations
The equation for plane surface can be expressed as
Ax + By + Cz + D = 0
Where (x, y, z) is any point on the plane, and the coefficients A, B, C,
and D are constants describing the spatial properties of the plane. We
can obtain the values of A, B, C, and D by solving a set of three plane
equations using the coordinate values for three non collinear points in
the plane. Let us assume that three vertices of the plane are (x 1, y1,
z1), (x2, y2, z2) and (x3, y3, z3).
Let us solve the following simultaneous equations for ratios A/D, B/D,
and C/D. You get the values of A, B, C, and D.
(A/D) x1 + (B/D) y1 + (C/D) z1 = -1
(A/D) x2 + (B/D) y2 + (C/D) z2 = -1
(A/D) x3 + (B/D) y3 + (C/D) z3 = -1
To obtain the above equations in determinant form, apply Cramers
rule to the above equations.
A=111y1y2y3z1z2z3B=x1x2x3111z1z2z3C=x1x2x3y1y
2y3111D=x1x2x3y1y2y3z1z2z3A=[1y1z11y2z21y3z3]B=[x1
1z1x21z2x31z3]C=[x1y11x2y21x3y31]D=[x1y1z1x2y2z2x3y3z3]
Polygon Meshes
Explicit representation
Advantages
Disadvantages
The z-coordinates are usually normalized to the range [0, 1]. The 0
value for z-coordinate indicates back clipping pane and 1 value for zcoordinates indicates front clipping pane.
Algorithm
Step-1 Set the buffer values
Depthbuffer (x, y) = 0
Framebuffer (x, y) = background color
Step-2 Process each polygon (One at a time)
For each projected (x, y) pixel position of a polygon, calculate depth
z.
If Z > depthbuffer (x, y)
Compute surface color,
set depthbuffer (x, y) = z,
framebuffer (x, y) = surfacecolor (x, y)
Advantages
It is easy to implement.
Disadvantages
Scan-Line Method
It is an image-space method to identify visible surface. This method
has a depth information for only single scan-line. In order to require
one scan-line of depth values, we must group and process all
polygons intersecting a given scan-line at the same time before
processing the next scan-line. Two important tables, edge
table and polygon table, are maintained for this.
The Edge Table It contains coordinate endpoints of each line in
the scene, the inverse slope of each line, and pointers into the
polygon table to connect edges to surfaces.
The Polygon Table It contains the plane coefficients, surface
material properties, other surface data, and may be pointers to the
edge table.
Area-Subdivision Method
The area-subdivision method takes advantage by locating those view
areas that represent part of a single surface. Divide the total viewing
area into smaller and smaller rectangles until each small area is the
projection of part of a single visible surface or no surface at all.
Continue this process until the subdivisions are easily analyzed as
belonging to a single surface or until they are reduced to the size of a
single pixel. An easy way to do this is to successively divide the area
into four equal parts at each step. There are four possible
relationships that a surface can have with a specified area boundary.
Overlapping surface One that is partly inside and partly outside the
area.
Back-Face Detection
A fast and simple object-space method for identifying the back faces
of a polyhedron is based on the "inside-outside" tests. A point (x, y, z)
is "inside" a polygon surface with plane parameters A, B, C, and D if
When an inside point is along the line of sight to the surface, the
polygon must be a back face (we are inside that face and cannot see
the front of it from our viewing position).
A-Buffer Method
The A-buffer method is an extension of the depth-buffer method. The
A-buffer method is a visibility detection method developed at Lucas
film Studios for the rendering system Renders Everything You Ever
Saw (REYES).
The A-buffer expands on the depth buffer method to allow
transparencies. The key data structure in the A-buffer is the
accumulation buffer.
Opacity Parameter
Depth
Surface identifier
The algorithm proceeds just like the depth buffer algorithm. The
depth and opacity values are used to determine the final color of a
pixel.
Let us take the polygon P at the end of the list. Consider all polygons
Q whose z-extents overlap Ps. Before drawing P, we make the
following tests. If any of the following tests is positive, then we can
assume P can be drawn before Q.
If all the tests fail, then we split either P or Q using the plane of the
other. The new cut polygons are inserting into the depth order and the
process continues. Theoretically, this partitioning could generate O(n 2)
individual polygons, but in practice, the number of polygons is much
smaller.
Put all the nodes that are in front of root A to the left side of node A and
put all those nodes that are behind the root A to the right side as shown
in figure (b).
Process all the front nodes first and then the nodes at the back.
Biology/Chemistry
For
depicting
bacteria
cultures,
Chemical
Others
For
depicting
clouds,
coastline
and
borderlines,
data
Generation of Fractals
Fractals can be generated by repeating the same shape over and over
again as shown in the following figure. In figure (a) shows an
equilateral triangle. In figure (b), we can see that the triangle is
repeated to create a star-like shape. In figure (c), we can see that the
star shape in figure (b) is repeated again and again to create a new
shape.
We can do unlimited number of iteration to create a desired shape. In
programming terms, recursion is used to create such shapes.
Geometric Fractals
Geometric fractals deal with shapes found in nature that have noninteger or fractal dimensions. To geometrically construct a
deterministic (nonrandom) self-similar fractal, we start with a given
geometric shape, called the initiator. Subparts of the initiator are
then replaced with a pattern, called the generator.
Computer Animation
Animation means giving life to any object in computer graphics. It has
the power of injecting energy and emotions into the most seemingly
inanimate objects. Computer-assisted animation and computergenerated animation are two categories of computer animation. It can
be presented via film or video.
The basic idea behind animation is to play back the recorded images
at the rates fast enough to fool the human eye into interpreting them
as continuous motion. Animation can make a series of dead images
come alive. Animation can be used in many areas like entertainment,
computer aided-design, scientific visualization, training, education, ecommerce, and computer art.
Animation Techniques
Animators have invented and used a variety of different animation
techniques. Basically there are six animation technique which we
would discuss one by one in this section.
Keyframing
In this technique, a storyboard is laid out and then the artists draw
the major frames of the animation. Major frames are the ones in
which prominent changes take place. They are the key points of
animation. Keyframing requires that the animator specifies critical or
key positions for the objects. The computer then automatically fills in
the missing frames by smoothly interpolating between those
positions.
Procedural
In a procedural animation, the objects are animated by a procedure
a set of rules not by keyframing. The animator specifies rules and
initial conditions and runs simulation. Rules are often based on
physical rules of the real world expressed by mathematical equations.
Behavioral
In behavioral animation, an autonomous character determines its own
actions, at least to a certain extent. This gives the character some
ability to improvise, and frees the animator from the need to specify
each detail of every character's motion.
Key Framing
A keyframe is a frame where we define changes in animation. Every
frame is a keyframe when we create frame by frame animation. When
someone creates a 3D animation on a computer, they usually dont
specify the exact position of any given object on every single frame.
They create keyframes.
Keyframes are important frames during which an object changes its
size, direction, shape or other properties. The computer then figures
out all the in-between frames and saves an extreme amount of time
for the animator. The following illustrations depict the frames drawn
by user and the frames generated by computer.
Morphing
The transformation of object shapes from one form to another form is
called morphing. It is one of the most complicated transformations.
A morph looks as if two images melt into each other with a very fluid
motion. In technical terms, two images are distorted and a fade
occurs between them.