This document discusses algorithms for rendering lines in raster graphics. It begins by introducing common line primitives in OpenGL and reviewing basic line drawing math. It then describes the Digital Differential Analyzer (DDA) line algorithm and its limitations. The document introduces Bresenham's midpoint line algorithm as a faster alternative that uses integer arithmetic. It explains how Bresenham's algorithm works by tracking the sign of a decision variable to select the next pixel along the line. The document concludes by generalizing Bresenham's algorithm and discussing optimizations.
Model Selection with Piecewise Regular GaugesGabriel Peyré
Talk given at Sampta 2013.
The corresponding paper is :
Model Selection with Piecewise Regular Gauges (S. Vaiter, M. Golbabaee, J. Fadili, G. Peyré), Technical report, Preprint hal-00842603, 2013.
http://hal.archives-ouvertes.fr/hal-00842603/
Model Selection with Piecewise Regular GaugesGabriel Peyré
Talk given at Sampta 2013.
The corresponding paper is :
Model Selection with Piecewise Regular Gauges (S. Vaiter, M. Golbabaee, J. Fadili, G. Peyré), Technical report, Preprint hal-00842603, 2013.
http://hal.archives-ouvertes.fr/hal-00842603/
This slide contain description about the line, circle and ellipse drawing algorithm in computer graphics. It also deals with the filled area primitive.
IIT JAM MATH 2021 Question Paper | Sourav Sir's ClassesSOURAV DAS
IIT JAM Math Previous Year Question Paper
IIT JAM Math 2021 Question Paper
IIT JAM Preparation Strategy
For any query about exams feel free to contact us
Call - 9836793076
This slide contain description about the line, circle and ellipse drawing algorithm in computer graphics. It also deals with the filled area primitive.
IIT JAM MATH 2021 Question Paper | Sourav Sir's ClassesSOURAV DAS
IIT JAM Math Previous Year Question Paper
IIT JAM Math 2021 Question Paper
IIT JAM Preparation Strategy
For any query about exams feel free to contact us
Call - 9836793076
This is the entrance exam paper for ISI MSQE Entrance Exam for the year 2008. Much more information on the ISI MSQE Entrance Exam and ISI MSQE Entrance preparation help available on http://crackdse.com
This is the entrance exam paper for ISI MSQE Entrance Exam for the year 2010. Much more information on the ISI MSQE Entrance Exam and ISI MSQE Entrance preparation help available on http://crackdse.com
FINAL PROJECT, MATH 251, FALL 2015[The project is Due Mond.docxvoversbyobersby
FINAL PROJECT, MATH 251, FALL 2015
[The project is Due Monday after the thanks giving recess]
.NAME(PRINT).________________ SHOW ALL WORK. Explain and
SKETCH (everywhere anytime and especially as you try to comprehend the prob-
lems below) whenever possible and/or necessary. Please carefully recheck your
answers. Leave reasonable space between lines on your solution sheets. Number
them and print your name.
Please sign the following. I hereby affirm that all the work in this project was
done by myself ______________________.
1) i) Explain how to derive the representation of the Cartesian coordinates x,y,z
in terms of the spherical coordinates ρ, θ, φ to obtain
(0.1) r =< x = ρsin(φ)cos(θ), y = ρsin(φ)sin(θ), z = ρcos(φ) > .
What are the conventional ranges of ρ, θ, φ?
ii) Conversely, explain how to express ρ, sin(θ), cos(θ), cos(φ), sin(φ) as
functions of x,y,z.
iii) Consider the spherical coordinates ρ,θ, φ. Sketch and describe in your own
words the set of all points x,y,z in x,y,z space such that:
a) 0 ≤ ρ ≤ 1, 0 ≤ θ < 2π, 0 ≤ φ ≤ π b) ρ = 1, 0 ≤ θ < 2π, 0 ≤ φ ≤ π,
c) 0 ≤ ρ < ∞, 0 ≤ θ < 2π, φ = π
4
, d) ρ = 1, 0 ≤ θ < 2π, φ = π
4
,
e) ρ = 1, θ = π
4
, 0 ≤ φ ≤ π. f) 1 ≤ ρ ≤ 2, 0 ≤ θ < 2π, π
6
≤ φ ≤ π
3
.
iv) In a different set of Cartesian Coordinates ρ, θ, φ sketch and describe in your
own words the set of points (ρ, θ, φ) given above in each item a) to f). For example
the set in a) in x,y,z space is a ball with radius 1 and center (0,0,0). However, in
the Cartesian coordinates ρ, θ, φ the set in a) is a rectangular box.
2) [Computation and graphing of vector fields]. Given r =< x,y,z > and the
vector Field
(0.2) F(x,y,z) = F(r) =< 1 + z,yx,y >,
1
FINAL PROJECT, MATH 251, FALL 2015 2
i) Draw the arrows emanating from (x,y,z) and representing the vectors F(r) =
F(x,y,z) . First draw a 2 raw table recording F(r) versus (x,y,z) for the 4 points
(±1,±2,1) . Afterwards draw the arrows.
ii) Show that the curve
(0.3) r(t) =< x = 2cos(t), y = 4sin(t), z ≡ 0 >, 0 ≤ t < 2π,
is an ellipse. Draw the arrows emanating from (x(t),y(t),z(t)) and representing
the vector values of dr(t)
dt
, F(r(t)) = F(x(t),y(t),z(t)) . Let θ(t) be the angle
between the arrows representing dr(t)
dt
and F(r(t)) . First draw a 5 raw table
recording t, (x(t),y(t),z(t)), dr(t)
dt
, F(r(t)), cos(θ(t)) for the points (x(t),y(t),z(t))
corresponding to t = 0,π
4
, 3π
4
, 5π
4
, 7π
4
. Then draw the arrows.
iii) Given the surface
r(θ,φ) =< x = 2sin(φ)cos(θ), y = 2sin(φ)sin(θ), z = 2cos(φ) >,0 ≤ θ < 2π, 0 ≤ φ ≤ π,
in parametric form. Use trigonometric formulas to show that the following iden-
tity holds
x2(θ,φ) + y2(θ,φ) + z2(θ,φ) ≡ 22.
iv) Draw the arrows emanating from (x(θ,φ),y(θ,φ),z(θ,φ)) and representing the
vectors ∂r(θ,φ)
∂θ
× ∂r(θ,φ)
∂φ
, F(r(θ,φ)) = F(x(θ,φ),y(θ,φ),z(θ,φ)) . Let α(θ,φ) be
the angle between the arrows representing ∂r(θ,φ)
∂θ
× ∂r(θ,φ)
∂φ
and F(r(θ,φ)) . First
draw a table with raws and columns recording (θ,φ),(x(θ,φ),y ...
On the Seidel’s Method, a Stronger Contraction Fixed Point Iterative Method o...BRNSS Publication Hub
In the solution of a system of linear equations, there exist many methods most of which are not fixed point iterative methods. However, this method of Sidel’s iteration ensures that the given system of the equation must be contractive after satisfying diagonal dominance. The theory behind this was discussed in sections one and two and the end; the application was extensively discussed in the last section.
Mathematics (from Greek μάθημα máthēma, “knowledge, study, learning”) is the study of topics such as quantity (numbers), structure, space, and change. There is a range of views among mathematicians and philosophers as to the exact scope and definition of mathematics
Techarea adalah perusahaan di bidang IT & Business Development berasal dari Semarang. Kami juga memberikan pelayanan servis dan jasa di berbagai segi project. Kami memiliki tim yang mempunyai pasion di bidang Software Engineering. Kami selalu memberikan hasil yang lebih dari yang Anda inginkan. Kami selalu bekerja keras untuk memberikan yang terbaik.
Perintah perintah dasar linux Operating SistemRoziq Bahtiar
presentation about base command line interface linux
please see in this link
http://roziq.com/perintah-perintah-dasar-linux-dan-konfigurasi-ip-address-cli/
eigen merupakan vector yang membuat image 1 dengan image yang lain berbeda sehingga dapat digunakan untuk mengenali image, hal ini biasa digunakan untuk melakukan proses recognition seperti pengenalan wajah dan lain sebagainya
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
1. 1
Elementary raster algorithms forElementary raster algorithms for
fast renderingfast rendering
Elementary RenderingElementary Rendering
nn Geometric PrimitivesGeometric Primitives
–– Line processingLine processing
–– Polygon processingPolygon processing
nn Managing OpenGL StateManaging OpenGL State
nn OpenGL BuffersOpenGL Buffers
OpenGL Geometric PrimitivesOpenGL Geometric Primitives
nn All geometric primitives are specified byAll geometric primitives are specified by
verticesvertices
GL_QUAD_STRIPGL_QUAD_STRIP
GL_POLYGONGL_POLYGON
GL_TRIANGLE_STRIPGL_TRIANGLE_STRIP GL_TRIANGLE_FANGL_TRIANGLE_FAN
GL_POINTSGL_POINTS
GL_LINESGL_LINES
GL_LINE_LOOPGL_LINE_LOOPGL_LINE_STRIPGL_LINE_STRIP
GL_TRIANGLESGL_TRIANGLES
GL_QUADSGL_QUADS
Design of Line AlgorithmsDesign of Line Algorithms
Why Lines?Why Lines?
nn Lines:Lines:
–– Most common 2D primitiveMost common 2D primitive -- done 100s or 1000sdone 100s or 1000s
of times each frame, even 3Dof times each frame, even 3D wireframeswireframes areare
eventually 2D lines!eventually 2D lines!
–– Lines areLines are compatiblecompatible with vector displays butwith vector displays but
nowadays most displays are raster displays. Anynowadays most displays are raster displays. Any
render stage beforerender stage before vizviz might needmight need discretizationdiscretization..
–– Optimized algorithms contain numerousOptimized algorithms contain numerous
tricks/techniques that help in designing moretricks/techniques that help in designing more
advanced algorithms for line processing.advanced algorithms for line processing.
Line Algorithms in the OpenGLLine Algorithms in the OpenGL
ArchitectureArchitecture
Display
List
Polynomial
Evaluator
Per Vertex
Operations &
Primitive
Assembly
Rasterization
Per Fragment
Operations
Frame
Buffer
Texture
Memory
CPU
Pixel
Operations
2. 2
Line RequirementsLine Requirements
nn Must compute integer coordinates of pixels which lie on or nearMust compute integer coordinates of pixels which lie on or near aa
line or circle.line or circle.
nn Pixel level algorithms are invoked hundreds or thousands of timePixel level algorithms are invoked hundreds or thousands of timess
when an image is created or modifiedwhen an image is created or modified –– must be fast!must be fast!
nn Lines must create visually satisfactory images.Lines must create visually satisfactory images.
–– Lines should appear straightLines should appear straight
–– Lines should terminate accuratelyLines should terminate accurately
–– Lines should have constant densityLines should have constant density
nn Line algorithm should always be defined.Line algorithm should always be defined.
Basic Math ReviewBasic Math Review
PointPoint--slope Formula For a Lineslope Formula For a Line
Given two points (XGiven two points (X11,Y,Y11), (X), (X22, Y, Y22))
Consider a third point on the line:Consider a third point on the line:
P = (X,Y)P = (X,Y)
Slope = (YSlope = (Y22 -- YY11)/(X)/(X22 -- XX11))
= (Y= (Y -- YY11)/(X)/(X -- XX11))
Solving For YSolving For Y
Y = [(YY = [(Y22--YY11)/(X)/(X22--XX11)]*(X)]*(X--XX11)+ Y)+ Y11
or, plug in the point (0, b) to getor, plug in the point (0, b) to get
thethe SlopeSlope--intercept form:intercept form:
Y =Y = mxmx + b+ b
Cartesian Coordinate System
2
4
1 2 3 4 5 6
3
5
6
1 P1 = (X1,Y1)
P2 = (X2,Y2)
P = (X,Y)
SLOPE =
RISE
RUN
=
Y2-Y1
X2-X1
Other Helpful FormulasOther Helpful Formulas
nn Length of line segment between PLength of line segment between P11 and Pand P22::
L =L =
nn Midpoint of a line segment between PMidpoint of a line segment between P11 andand
PP33::
PP22 = ( (X= ( (X11+X+X33)/2 , (Y)/2 , (Y 11+Y+Y33)/2 ))/2 )
nn Two lines areTwo lines are perpendicularperpendicular iffiff
1) M1) M11 == --1/M1/M22
2) Cosine of the angle between them is 0.2) Cosine of the angle between them is 0.
2
12
2
12 )()( yyxx −+−
Using this information, whatUsing this information, what
are some possible algorithmsare some possible algorithms
for line drawing?for line drawing?
Parametric FormParametric Form
Given points PGiven points P11 = (X= (X11, Y, Y11) and P) and P22 = (X= (X22, Y, Y22))
X = XX = X11 + t(X+ t(X22--XX11))
Y = YY = Y11 + t(Y+ t(Y22--YY11))
t is called the parameter. Whent is called the parameter. When
t = 0 we get (Xt = 0 we get (X11,Y,Y11))
t = 1 we get (Xt = 1 we get (X22,Y,Y22))
As 0 < t < 1 we get all the other points on the line segmentAs 0 < t < 1 we get all the other points on the line segment
between (Xbetween (X11,Y,Y11) and (X) and (X22,Y,Y22).).
New algorithm ideas based onNew algorithm ideas based on
parametric form?parametric form?
3. 3
Simple DDA* Line AlgorithmSimple DDA* Line Algorithm
voidvoid DDA(intDDA(int X1,Y1,X2,Y2)X1,Y1,X2,Y2)
{{
intint Length, I;Length, I;
floatfloat X,Y,Xinc,YincX,Y,Xinc,Yinc;;
Length = ABS(X2Length = ABS(X2 -- X1);X1);
if (ABS(Y2if (ABS(Y2 -- Y1) > Length)Y1) > Length)
Length = ABS(Y2Length = ABS(Y2--Y1);Y1);
XincXinc = (X2= (X2 -- X1)/Length;X1)/Length;
YincYinc = (Y2= (Y2 -- Y1)/Length;Y1)/Length;
*DDA: Digital Differential Analyzer*DDA: Digital Differential Analyzer
X = X1;
Y = Y1;
while(X<X2){
Plot(Round(X),Round(Y));
X = X + Xinc;
Y = Y + Yinc;
}
}
DDA creates good lines but it is too time consuming due to the rDDA creates good lines but it is too time consuming due to the roundound
function and long operations on real values.function and long operations on real values.
Compute which pixels should be turned on to
represent the line from (6,9) to (11,12).
Length = ?
Xinc = ?
Yinc = ?
DDA ExampleDDA Example
6 7 8 9 10 11 12 13
9
10
11
12
13
DDA ExampleDDA Example
Line from (6,9) to (11,12).Line from (6,9) to (11,12).
Length := Max of (ABS(11Length := Max of (ABS(11--6), ABS(126), ABS(12--9)) = 59)) = 5
XincXinc := 1:= 1
YincYinc := 0.6:= 0.6
Values computed are:Values computed are:
(6,9), (7,9.6),(6,9), (7,9.6),
(8,10.2), (9,10.8),(8,10.2), (9,10.8),
(10,11.4), (11,12)(10,11.4), (11,12)
6 7 8 9 10 11 12 13
9
10
11
12
13
Fast LinesFast Lines –– Midpoint MethodMidpoint Method
nn Simplifying assumptions: AssumeSimplifying assumptions: Assume
we wish to draw a line betweenwe wish to draw a line between
points (0,0) and (a,b) with slope mpoints (0,0) and (a,b) with slope m
between 0 and 1 (i.e. line lies in firstbetween 0 and 1 (i.e. line lies in first
octant).octant).
nn The general formula for a line isThe general formula for a line is yy
== mxmx + B+ B wherewhere mm is the slope ofis the slope of
the line andthe line and BB is the yis the y--intercept.intercept.
From our assumptionsFrom our assumptions mm = b/a and= b/a and
BB = 0.= 0.
nn y = (b/a)x + 0y = (b/a)x + 0 ---->> f(x,y) =f(x,y) = bxbx -- ayay
= 0= 0 is an equation for the line.is an equation for the line.
+x-x
-y
+y
Having turned on pixel P at (xHaving turned on pixel P at (xii,, yyii), the next pixel is NE at (x), the next pixel is NE at (xii+1,+1,
yyii+1) or E at (x+1) or E at (xii+1,+1, yyii). Choose the pixel closer to the line). Choose the pixel closer to the line
f(x, y) =f(x, y) = bxbx -- ay = 0.ay = 0.
Fast Lines (cont.)Fast Lines (cont.)
For lines in the first octant,For lines in the first octant,
given one pixel on thegiven one pixel on the
line, the next pixel is toline, the next pixel is to
the right (E) or to thethe right (E) or to the
right and up (NE).right and up (NE).
P = (xi ,yi ) E = (xi + 1, yi)
NE = (xi + 1, yi + 1)
current pixel possible
next pixels
Fast Lines (cont.)Fast Lines (cont.)
The midpoint between pixels E
and NE is (xi + 1, yi + ½).
Let e be the “upward”
distance between the midpoint
and where the line actually
crosses between E and NE. If
e is positive the line crosses
above the midpoint and is
closer to NE. If e is
negative, the line crosses
below the midpoint and is
closer to E. To pick the
correct point we only need to
know the sign of e.
(xi +1, yi + ½ + e)
e
(xi +1, yi + ½)
P = (xi ,yi ) E = (xi + 1, yi)
NE = (xi + 1, yi + 1)
4. 4
The Decision VariableThe Decision Variable
f(xf(xii+1,+1, yy ii+ ½ + e) = 0 (point on line)+ ½ + e) = 0 (point on line)
== b(xb(xii + 1)+ 1) -- a(ya(y ii+ ½ + e)+ ½ + e)
== b(xb(xii + 1)+ 1) -- a(ya(y ii + ½)+ ½) –– aeae
== f(xf(xii + 1,+ 1, yy ii + ½)+ ½) -- aeae
LetLet ddii == f(xf(xii + 1,+ 1, yy ii + ½) =+ ½) = aeae;; ddii is known as theis known as the decisiondecision
variablevariable..
Since a = 0,Since a = 0, ddii has the same sign as ehas the same sign as e..
Therefore, we only need to know the value ofTherefore, we only need to know the value of ddii to choose betweento choose between
pixels E and NE. Ifpixels E and NE. If ddii = 0 choose NE, else choose E.= 0 choose NE, else choose E.
ButBut, calculating, calculating ddii directly each time requires at least two adds, adirectly each time requires at least two adds, a
subtract, and two multipliessubtract, and two multiplies --> too slow!> too slow!
è f(xi + 1, yi + ½) = ae
Decision VariableDecision Variable
calculationcalculation
Algorithm:Algorithm:
Calculate dCalculate d00 directly, then for each i >= 0:directly, then for each i >= 0:
ifif ddii = 0 Then= 0 Then
Choose NE = (xChoose NE = (xii + 1,+ 1, yy ii + 1) as next point+ 1) as next point
ddi+1i+1 = f(x= f(xi+1i+1 + 1, y+ 1, y i+1i+1 + ½) =+ ½) = f(xf(xii + 1 + 1,+ 1 + 1, yy ii + 1 + ½)+ 1 + ½)
== b(xb(xii + 1 + 1)+ 1 + 1) -- a(ya(y ii + 1 + ½) =+ 1 + ½) = f(xf(xii + 1,+ 1, yy ii + ½) + b+ ½) + b -- aa
== ddii + b+ b -- aa
elseelse
Choose E = (xChoose E = (xii + 1,+ 1, yy ii) as next point) as next point
ddi+1i+1 = f(x= f(xi+1i+1 + 1, y+ 1, y i+1i+1 + ½) =+ ½) = f(xf(xii + 1 + 1,+ 1 + 1, yy ii + ½)+ ½)
== b(xb(xii + 1 + 1)+ 1 + 1) -- a(ya(y ii + ½) =+ ½) = f(xf(xii + 1,+ 1, yy ii + ½) + b+ ½) + b
== ddii + b+ b
èè KnowingKnowing ddii, we need only add a, we need only add a constantconstant term to find dterm to find di+1i+1 !!
else {else {
x = x + 1;x = x + 1;
d = d + bd = d + b
}}
}}
The initial value for the decision variable, d0, may be calculated directly
from the formula at point (0,0).
d0 = f(0 + 1, 0 + 1/2) = b(1) - a(1/2) = b - a/2
Therefore, the algorithm for a line from (0,0) to (a,b) in the first octant is:
x = 0;
y = 0;
d = b - a/2;
for(i = 0; i < a; i++) {
Plot(x,y);
if (d = 0) {
x = x + 1;
y = y + 1;
d = d + b - a;
}
Fast Line AlgorithmFast Line Algorithm
Note that the only non-integer value is a/2. If we then multiply by 2 to get d' = 2d, we
can do all integer arithmetic. The algorithm still works since we only care about the
sign, not the value of d.
Bresenham’sBresenham’s Line AlgorithmLine Algorithm
We can also generalize the algorithm to work for lines beginningWe can also generalize the algorithm to work for lines beginning atat
points other than (0,0) by giving x and y the proper initial valpoints other than (0,0) by giving x and y the proper initial values.ues.
This results inThis results in Bresenham'sBresenham's Line Algorithm.Line Algorithm.
{Bresenham for lines with slope between 0 and 1}
a = ABS(xend - xstart);
b = ABS(yend - ystart);
d = 2*b - a;
Incr1 = 2*(b-a);
Incr2 = 2*b;
if (xstart > xend) {
x = xend;
y = yend
}
else {
x = xstart;
y = ystart
}
for (i = 0; i<a; i++){
Plot(x,y);
x = x + 1;
if (d = 0) {
y = y + 1;
d = d + incr1;
}
else
d = d + incr2;
}
}
OptimizationsOptimizations
nn Speed can be increased even more by detecting cycles in the deciSpeed can be increased even more by detecting cycles in the decisionsion
variable. These cycles correspond to a repeated pattern of pixevariable. These cycles correspond to a repeated pattern of pixel choices.l choices.
nn The pattern is saved and if a cycle is detected it is repeatedThe pattern is saved and if a cycle is detected it is repeated withoutwithout
recalculating.recalculating.
11 12 13 14 15 16 17
9
10
11
12
13
14
15
16
6 7 8 9 10
didi== 22 --6 66 6 --2 102 10 22 --6 66 6 --2 102 10
The aliasing problemThe aliasing problem
nn Aliasing is caused by finite addressability of the display.Aliasing is caused by finite addressability of the display.
nn Approximation of lines and circles with discrete points oftenApproximation of lines and circles with discrete points often
gives a staircase appearance or "gives a staircase appearance or "JaggiesJaggies".".
Desired line
Aliased rendering of the line
5. 5
AntialiasingAntialiasing -- solutionssolutions
nn Aliasing can be smoothed out by using higher addressability.Aliasing can be smoothed out by using higher addressability.
nn If addressability is fixed but intensity is variable, use the inIf addressability is fixed but intensity is variable, use the intensitytensity
to control the address of a "virtual pixel". Two adjacent pixeto control the address of a "virtual pixel". Two adjacent pixelsls
can be be used to give the impression of a point part way betweecan be be used to give the impression of a point part way betweenn
them. The perceived location of the point is dependent upon thethem. The perceived location of the point is dependent upon the
ratio of the intensities used at each. The impression of a pixeratio of the intensities used at each. The impression of a pixell
located halfway between two addressable points can be given bylocated halfway between two addressable points can be given by
having two adjacent pixels at half intensity.having two adjacent pixels at half intensity.
nn AnAn antialiasedantialiased line has a series of virtual pixels each located at theline has a series of virtual pixels each located at the
proper address.proper address.
Aliasing /Aliasing / AntialiasingAntialiasing
ExamplesExamples
AntialiasedAntialiased BresenhamBresenham LinesLines
nn Line drawing algorithms such asLine drawing algorithms such as Bresenham'sBresenham's can easily becan easily be
modified to implement virtual pixels. We use the distance (e =modified to implement virtual pixels. We use the distance (e =
ddii/a) value to determine pixel intensities./a) value to determine pixel intensities.
nn Three possible cases which occur during theThree possible cases which occur during the BresenhamBresenham algorithm:algorithm:
AA
B
C
e
B
C
e
A
B
C
e
A = 0.5 + e
B = 1 - abs(e+0.5)
C = 0
A = 0.5 + e
B = 1 - abs(e+0.5)
C = 0
A = 0
B = 1 - abs(e+0.5)
C = -0.5 - e
e > 0 0 > e > -0.5 e < -0.5
Line Rendering ReferencesLine Rendering References
BresenhamBresenham, J.E., "Ambiguities In Incremental Line, J.E., "Ambiguities In Incremental Line RasteringRastering,"," IEEEIEEE
Computer Graphics And ApplicationsComputer Graphics And Applications, Vol. 7, No. 5, May 1987., Vol. 7, No. 5, May 1987.
EcklandEckland, Eric, "Improved Techniques For, Eric, "Improved Techniques For OptimisingOptimising IterativeIterative
DecisionDecision-- Variable Algorithms, Drawing AntiVariable Algorithms, Drawing Anti--Aliased Lines QuicklyAliased Lines Quickly
And Creating Easy To Use Color Charts," CSC 462 Project Report,And Creating Easy To Use Color Charts," CSC 462 Project Report,
Department of Computer Science, North Carolina State UniversityDepartment of Computer Science, North Carolina State University
(Spring 1987).(Spring 1987).
Foley, J.D. and A. Van Dam,Foley, J.D. and A. Van Dam, Fundamentals of Interactive ComputerFundamentals of Interactive Computer
GraphicsGraphics, Addison, Addison--Wesley 1982.Wesley 1982.
Newman, W.M and R.F.Newman, W.M and R.F. SproullSproull,, Principles Of Interactive ComputerPrinciples Of Interactive Computer
GraphicsGraphics, McGraw, McGraw --Hill, 1979.Hill, 1979.