Hidden Line Removal - PowerPoint PPT Presentation

About This Presentation
Title:

Hidden Line Removal

Description:

Hidden Line Removal. Applying vector algebra to the problem of removing hidden ... So visible faces can be drawn in any order. Examples: barn, cube, and dodecahedron ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 17
Provided by: ProfessorA2
Learn more at: https://www.cs.usfca.edu
Category:
Tags: barn | hidden | line | removal

less

Transcript and Presenter's Notes

Title: Hidden Line Removal


1
Hidden Line Removal
  • Applying vector algebra to the problem of
    removing hidden lines from wire-frame models

2
Convex objects
  • We first focus on modeling convex objects
  • One outward face cannot hide another
  • So visible faces can be drawn in any order
  • Examples barn, cube, and dodecahedron

3
A non-convex object
part of this face is hidden by that face
eye of viewer
4
2D Polygons in 3D space
  • A polygon is a 2-dimensional figure
  • Its edges and corner-points are coplanar
  • Its a bounded region of an infinite plane
  • Any plane in 3-space can be described by an
    first-degree (linear) algebraic equation ax
    by cz d
  • Alternatively, using vector algebra, a plane can
    be described using a reference-point Q and a
    direction-vector N (a, b, c), as N QP 0

5
Face-Planes of solid objects
  • Any plane surface has two sides
  • When a plane is a surface of a solid object it
    has an inside surface and an outside surface
    (a viewer sees the outside one)

front
back
viewer
6
Angles and cosines
  • An angle of 90-degrees is a right angle
  • Angles less than 90-degrees are acute
  • And angles over 90-degrees are obtuse

obtuse angle
right angle
acute angle
cosine lt 0
cosine gt 0
cosine 0
7
Vectors and dot-products
  • Vectors u (ux, uy, uz) and v (vx, vy, vz)
    have a dot-product
  • uv ux vx uy vy uz vz
  • A vectors length u equals sqrt( uu )
  • A dot-product is related to the cosine of the
    angle ? between the two vectors uv
    uvcosine(?)
  • So sign of dot-product tells angles type

8
Visibility of face-planes
N outward pointing normal vector
N
D
?
DN gt 0 (acute angle ?)
outer surface is visible
D direction vector (from plane toward viewers
eye)
9
Hidden face-plane
N outward pointing normal vector
N
?
D
DN lt 0 (obtuse angle ?)
outer surface is hidden
D direction vector (from plane toward viewers
eye)
10
Format of models data-set
  • Added data needed to describe our model
  • Number and Location of vertices as before
  • Edge-list is no longer needed (zero edges)
  • Face-list is the new information to be add
  • Each face is a polygon number of sides, list of
    vertices in counter-clockwise order (as viewed
    from the outside of the model), and the
    face-color to be used for the face

11
Example data-set cube
7
0
Face-List (6 faces)
3
4
4-sided 0, 1, 2, 3 (blue) 4-sided 1, 0,
7, 6 (green) 4-sided 2, 5, 4, 3
(cyan) 4-sided 4, 5, 6, 7 (red) 4-sided
6, 5, 2, 1 (magenta)
6
1
5
2
The vertices of each face should be listed in
counterclockwise order (an
seen from the outside of the cube)
12
Why counterclockwise order?
  • We need to compute the outward-pointing normal
    vector for each polygonal face (to determine if
    that outward face is visible)
  • That normal vector is easily computed (as a
    vector cross-product) if the vertices were listed
    in counterclockwise order

13
Recall the cross-product uv
  • If u ( ux, uy, uz ) and v ( vx, vy, vz ),
    then w uv is given by these formulas wx
    uyvz uzvy wy uzvx uxvz wz uxvy
    uyvx
  • Significance cross-product w makes a
    90-degree angle with both u and v (so its
    normal to a plane containing u and v)

14
Three consecutive vertices
pq
p v1 v0 q v2 v1
V1
q
p
V2
V0
pq will be the outward-pointing normal
vector (if v0, v1, v2 occurred in
counterclockwise order)
15
Demo program
  • Our filldemo.cpp application reads in the data
    for a 3D model, determines which of its polygonal
    faces are visible to a viewer, fills each visible
    face in its specified color, and then draws the
    edges of visible faces
  • Datasets plato.dat, redbarn.dat, plane.dat
  • Also two models for a non-convex object
    corner1.dat and corner2.dat (same object)

16
In-class exercises
  • Try to create the data-sets for some more
    interesting 3D objects, (by writing a C
    program to generate the objects vertices and the
    face-lists)
  • Example An octagonal prism
  • Divide a circle into eight equal-size angles
  • Use sine and cosine to locate upper vertices
  • Use sine and cosine to locate lower vertices
  • Use number-patterns to generate its ten
    face-planes
Write a Comment
User Comments (0)
About PowerShow.com