0% found this document useful (0 votes)
18 views22 pages

4 - Triangle Scan Conversion

Uploaded by

dawitkebedewoldu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views22 pages

4 - Triangle Scan Conversion

Uploaded by

dawitkebedewoldu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Triangle Scan Conversion

Computation Stage
Computation

Model Output

Transformations Rasterization

Transformed
Model
Any object can be broken down
into polygons
Polygon Filling Algorithms
• A solid object
• Concave and Convex polygons
• Inside-Outside tests (odd-even rule)
• Bounding box
• Seed fill algorithms
– Boundary fill algorithm
– Flood fill algorithms
Polygon Tables
Triangle Area Filling Algorithms
• Why do we care about triangles?

• Edge Equations

• Edge Walking
Do something easier!
• Instead of polygons, TRIANGLES! Why?

1) All polygons can


be broken into
triangles
2) Easy to specify
3) Always convex
4) Going to 3D is
MUCH easier
Polygons can be broken down
Triangulate - Dividing a
polygon into triangles.

Is it always possible? Why?


Any object can be broken down
into polygons
Specifying a model
• For polygons, we had to worry about
connectivity AND vertices.
• How would you specify a triangle? (What is
the minimum you need to draw one?)
– Only vertices
(x1,y1) (x2,y2) (x3,y3)
– No ambiguity
– Line equations
A1x1+B1y1+C1=0 A2x2+B2y2+C2=0 A3x3+B3y3+C3=0
Triangles are always convex
• What is a convex shape?

An object is convex if and only if any line segment connecting two


points on its boundary is contained entirely within the object or one
of its boundaries. Think about scan lines again!
Scan Converting a Triangle
• Two main ways
to rasterize a
triangle
– Edge Equations
• A1x1+B1y1+C1=0
• A2x2+B2y2+C2=0
• A3x3+B3y3+C3=0

– Edge Walking
Types of Triangles

What determines the spans? Can you think of an easy way


to compute spans?
What is the special vertex here?
Edge Walking
• 1. Sort vertices in
y and then x P0

• 2. Determine the
middle vertex
• 3. Walk down
edges from P0 P1
• 4. Compute
spans
P2
Edge Walking Pros and Cons

Pros Cons
• Fast • Special Cases
• Easy to implement in • Interpolation can be
hardware tricky
Edge Equations
P0
• A1x1+B1y1+C1=0
• A2x2+B2y2+C2=0
• A3x3+B3y3+C3=0

• How do you go from:


x1, y1 - x2, y2 to
A1x1+B1y1+C1?
P1
P2
Edge Equations
• What does the edge P0
equation mean?
• A1x1+B1y1+C1=0
• Pt1[2,1], Pt2[6,11]
• A=-10, B=4, C=16
• What is the value of the
equation for the:
– gray part
– yellow part
– the boundary line P1
• What happens when we
reverse P0 and P1?
Positive Interior
• We add the C element from each edge
– area = edge0.C + edge1.C + edge2.C
– if (area>0) then inside points are in the positive
half spaces
– if (area<0) then what should we do?
– What happens if area=0?
Combining all edge equations

1) Determine edge equations P0


for all three edges
2) Find out if we should
reverse the edges
3) Create a bounding box P1
4) Test all pixels in the
bounding box whether they too P2
reside on the same side
Pros and Cons of Edge Equations
• Pros • Cons
• If you have the right • Can be expensive if
hardware you don’t have
(PixelPlanes) then it is hardware
very fast • 50% efficient
• Fast tests
• Easy to interpolate
colors
Recap
P0
P0

P1 P1

P2

P2

You might also like