Scan Conversion 2
Scan Conversion 2
E
(x, y) by adding appropriate second constant
increment update delta terms as we move.
This is also true of
SE
(x, y)
Having drawn pixel (a,b), decide location of new
pixel at (a + 1, b) or (a + 1, b 1), using
previously computed d(a, b).
Having drawn new pixel, must update d(a, b) for
next iteration; need to find either d(a + 1, b) or
d(a + 1, b 1) depending on pixel choice
Must add
E
(a, b)
or
SE
(a, b) to d(a, b)
So we
Look at d(i) to decide which to draw next,
update x and y
Update d using
E
(a,b) or
SE
(a,b)
Update each of
E
(a,b) and
SE
(a,b) for future
use
Draw pixel
Second Differences (2/2)
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
Midpoint Eighth Circle Algorithm
MEC (R) /* 1/8
th
of a circle w/ radius R */
{
int x = 0, y = R;
int delta_E, delta_SE;
float decision;
delta_E = 2*x + 3;
delta_SE = 2(x-y) + 5;
decision = (x+1)*(x+1) + (y + 0.5)*(y + 0.5) R*R;
Pixel(x, y);
while( y > x ) {
if (decision > 0) {/* Move east */
decision += delta_E;
delta_E += 2; delta_SE += 2; /*Update delta*/
}
else {/* Move SE */
y--;
decision += delta_SE;
delta_E += 2; delta_SE += 4; /*Update delta*/
}
x++;
Pixel(x, y);
}
}
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
Uses floats!
1 test, 3 or 4 additions per pixel
Initialization can be improved
Multiply everything by 4 No Floats!
Makes the components even, but sign of
decision variable remains same
Questions
Are we getting all pixels whose distance
from the circle is less than ?
Why is y > x the right stopping criterion?
What if it were an ellipse?
Analysis
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
Patterned primitives
Aligned Ellipses
Non-integer
primitives
General conics
Other Scan Conversion Problems
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
Patterned line from P to Q is not same
as patterned line from Q to P.
Patterns can be geometric or cosmetic
Cosmetic: Texture applied after
transformations
Geometric: Pattern subject to
transformations
Cosmetic patterned line
Geometric patterned line
Patterned Lines
P Q
P Q
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
Geometric Pattern vs. Cosmetic Pattern
+
Geometric
(Perspectivized/Filtered)
Cosmetic
(Contact Paper)
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
Equation is
i.e,
Computation of and is similar
Only 4-fold symmetry
When do we stop stepping horizontally and
switch to vertical?
Aligned Ellipses
1
2
2
2
2
= +
b
y
a
x
2 2 2 2 2 2
b a y a x b
= +
E
A
SE
A
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
When absolute value of slope of ellipse is
more than 1, viz:
How do you check this? At a point (x,y) for
which f(x,y) = 0, a vector perpendicular to
the level set is f(x,y) which is
This vector points more right than up when
Direction Changing Criterion (1/2)
(
(
c
c
c
c
) , ( ), , ( y x
y
f
y x
x
f
0 ) , ( ) , (
>
c
c
c
c
y x
y
f
y x
x
f
V
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
In our case,
and
so we check for
i.e.
This, too, can be computed incrementally
Direction Changing Criterion (2/2)
x a y x
x
f
2
2 ) , (
=
c
c
y b y x
y
f
2
2 ) , (
=
c
c
0 2 2
2 2
>
y b x a
0
2 2
>
y b x a
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
Now in ENE octant, not ESE octant
This problem is artifact of aliasing much
more on this later
Problems with Aligned Ellipses
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
Non-Integer Primitives
Initialization is harder
Endpoints are hard, too
making Line (P,Q) and Line (Q,R)
join properly is a good test
Symmetry is lost
Non Integer Primitives and
General Conics
General Conics
Very hard--the octant-changing test is
tougher, the difference computations
are tougher, etc.
do it only if you have to.
Note that drawing gray-scale conics is
easier than drawing B/W conics
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S
Andries van Dam September 23, 2008 ScanConversion2 #/26
Generic Polygons
(More information and these pictures on page
92-93 of textbook)