77
Computer Graphics 2012 5. Geometry and Transform Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2012-09-26 121023日星期二

Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012

5. Geometry and TransformHongxin Zhang

State Key Lab of CAD&CG, Zhejiang University

2012-09-2612年10月23日星期二

Page 2: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

上机实践

• 地址:ftp://give.zju.edu.cn

• 用户:cgzhang

• 密码:cgzhang

• 请大家把上机作业结果和报告内容,上传至“学号_姓名”子目录

12年10月23日星期二

Page 3: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Today outline

• Triangle rasterization

• Basic vector algebra ~ geometry

• Antialiasing revisit

• Clipping

• Transforms (I)

12年10月23日星期二

Page 4: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Previous lesson

• Primitive attributes

• Rasterization and scan line algorithm

• line,

• general polygon

12年10月23日星期二

Page 5: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Polygon filling• Polygon representation

• By vertex By lattice

• Polygon filling:

• vertex representation vs lattice representation

12年10月23日星期二

Page 6: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Scan Line Method

• Proceeding from left to right the intersections are paired and intervening pixels are set to the specified intensity

• Algorithm

• Find the intersections of the scan line with all the edges in the polygon

• Sort the intersections by increasing X-coordinates

• Fill the pixels between pair of intersections

From top to down

12年10月23日星期二

Page 7: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

• Intersections could be found using edge coherencethe X-intersection value xi+1 of the lower scan line can be

computed from the X-intersection value xi of the proceeding scan line as

• List of active edges could be maintained to increase efficiency

Efficiency Issues in Scan Line Method

12年10月23日星期二

Page 8: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Advantages of Scan Line method

• The algorithm is efficient

• Each pixel is visited only once

• Shading algorithms could be easily integrated with this method to obtain shaded area

• Efficiency could be further improved if polygons are convex,

• much better if they are only triangles

12年10月23日星期二

Page 9: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Seed Fill Algorithms• Assumes that at least one pixel interior to the

polygon is known

• It is a recursive algorithm

• Useful in interactive paint packages

Seed 4-connected 8 - connected

12年10月23日星期二

Page 10: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Triangle Rasterization

12年10月23日星期二

Page 11: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Triangle Rasterization?

12年10月23日星期二

Page 12: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Triangle Rasterization

12年10月23日星期二

Page 13: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Compute Bounding Box

12年10月23日星期二

Page 14: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Point Inside Triangle Test

12年10月23日星期二

Page 15: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Line equation

12年10月23日星期二

Page 16: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

The Parallelogram Rule

12年10月23日星期二

Page 17: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Dot Product

12年10月23日星期二

Page 18: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Orthonormal Vectors

12年10月23日星期二

Page 19: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Coordinates and Vectors

12年10月23日星期二

Page 20: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Dot product between two vectors

12年10月23日星期二

Page 21: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Cross Product

12年10月23日星期二

Page 22: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Cross Product

12年10月23日星期二

Page 23: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

2~3D

12年10月23日星期二

Page 24: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Vector operations

12年10月23日星期二

Page 25: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Point operations

12年10月23日星期二

Page 26: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

illegal operations

12年10月23日星期二

Page 27: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Directed line

12年10月23日星期二

Page 28: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Perpendicular vector in 2D

12年10月23日星期二

Page 29: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Line equation

12年10月23日星期二

Page 30: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Normal to the line

12年10月23日星期二

Page 31: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Line equation

12年10月23日星期二

Page 32: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Line equation

12年10月23日星期二

Page 33: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Singularities

12年10月23日星期二

Page 34: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Handling singularity

12年10月23日星期二

Page 35: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Antialiasing

12年10月23日星期二

Page 36: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

• Aliasing is caused due to the discrete nature of the display device

• Rasterizing primitives is like sampling a continuous signal by a finite set of values (point sampling)

• Information is lost if the rate of sampling is not sufficient. This sampling error is called aliasing.

• Effects of aliasing are

– Jagged edges

– Incorrectly rendered fine details

– Small objects might miss

Aliasing

12年10月23日星期二

Page 37: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Aliasing(examples)

12年10月23日星期二

Page 38: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Aliasing(examples)

12年10月23日星期二

Page 39: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Aliasing(examples)

12年10月23日星期二

Page 40: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

Antialiasing

• Application of techniques to reduce/eliminate aliasing artifacts

• Some of the methods are

– increasing sampling rate by increasing the resolution. Display memory requirements increases four times if the resolution is doubled

– averaging methods (post processing). Intensity of a pixel is set as the weighted average of its own intensity and the intensity of the surrounding pixels

– Area sampling, more popular

12年10月23日星期二

Page 41: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Antialiasing (postfiltering)How should one supersample?

12年10月23日星期二

Page 42: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

36

Area Sampling

• A scan converted primitive occupies finite area on the screen

• Intensity of the boundary pixels is adjusted depending on the percent of the pixel area covered by the primitive. This is called weighted area sampling

12年10月23日星期二

Page 43: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

• Methods to estimate percent of pixel covered by the primitive–subdivide pixel into sub-pixels and determine how

many sub-pixels are inside the boundary–Incremental line algorithm can be extended, with

area calculated as

x+0.5

Area Sampling

y+0.5

y-0.5

x-0.5 x

y

filled area

12年10月23日星期二

Page 44: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

• Clipping of primitives is done usually before scan converting the primitives

• Reasons being–scan conversion needs to deal only with the clipped

version of the primitive, which might be much smaller than its unclipped version

–Primitives are usually defined in the real world, and their mapping from the real to the integer domain of the display might result in the overflowing of the integer values resulting in unnecessary artifacts

Clipping

12年10月23日星期二

Page 45: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Clipping

• Why Clipping?• How Clipping?

–Lines–Polygons

• Note: Content from chapter 4.–Lots of stuff about rendering systems and

mathematics in that chapter.

12年10月23日星期二

Page 46: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Definition

• Clipping – Removal of content that is not going to be displayed–Behind camera–Too close–Too far–Off sides of

the screen

12年10月23日星期二

Page 47: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

How would we clip?

• Points?• Lines?• Polygons?• Other objects?

12年10月23日星期二

Page 48: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

We’ll start in 2D

• Assume a 2D upright rectangle we are clipping against–Common in windowing systems–Points are trivial

• >= minx and <= maxx and >= miny and <= maxy

ab

c12年10月23日星期二

Page 49: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Line Segments

• What can happen when a line segment is clipped?

12年10月23日星期二

Page 50: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Cohen-Sutherland Line Clipping

• We’ll assign the ends of a line “outcodes”, 4 bit values that indicate if they are inside or outside the clip area.

1001 1000 1010

0001

0101 0110

0010

0100

0000

x < xminx > xmaxy < ymin

y > ymax

ymin

ymax

xmin xmax12年10月23日星期二

Page 51: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Outcode cases

• We’ll call the two endpoint outcodes o1 and o2. – If o1 = o2 = 0, both endpoints are inside.–else if (o1 & o2) != 0, both ends points are on the

same side, the edge is discarded.

1001 1000 1010

0001

0101 0110

0010

0100

0000

12年10月23日星期二

Page 52: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

More cases

• else if (o1 != 0) and (o2 = 0), (or vice versa), one end is inside, other is outside.–Clip and recompute one that’s outside until inside.–Clip edges with bits set…–May require two

clip computations 1001 1000 1010

0001

0101 0110

0010

0100

0000

12年10月23日星期二

Page 53: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Last case…

–else if (o1 & o2) = 0, end points are on different sides.• Clip and recompute. • May have some inside part or may not…• May require up to 4 clips!

1001 1000 1010

0001

0101 0110

0010

0100

0000

12年10月23日星期二

Page 54: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

48

• To do the clipping find the end point that lies outside

• Test the outcode to find the edge that is crossed and determine the corresponding intersection point

• Replace the outside end-point by intersection-point

• Repeat the above steps for the new line

ab

c

d

ef

g

h

i1001

0000

1010

0010

0100

Cohen-Sutherland Line-Clipping Algorithm

12年10月23日星期二

Page 55: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

49

Sutherland-Hodgeman Polygon-ClippingAlgorithm

• Polygons can be clipped against each edge of the window one edge at a time. Window/edge intersections, if any, are easy to find since the X or Y coordinates are already known.

• Vertices which are kept after clipping against one window edge are saved for clipping against the remaining edges.

12年10月23日星期二

Page 56: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Computer Graphics 2012, ZJU

• Because polygon clipping does not depend on any other polygons, it is possible to arrange the clipping stages in a pipeline. the input polygon is clipped against one edge and any points that are kept are passed on as input to the next stage of the pipeline.

• This way four polygons can be at different stages of the clipping process simultaneously. This is often implemented in hardware.

Pipelined Polygon Clipping

ClipRight

ClipTop

ClipLeft

ClipBottom

12年10月23日星期二

Page 57: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

51

Sutherland-Hodgeman Polygon Clipping Algorithm

• Polygon clipping is similar to line clipping except we have to keep track of inside/outside relationships–Consider a polygon as a list of vertices–Note that clipping

can increase the number of vertices!

–Typically clip one edge at a time…

v1

v2

v3

v4

v5

12年10月23日星期二

Page 58: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

52

Sutherland-Hodgeman algorithm• Present the vertices in pairs

–(vn,v1), (v1, v2), (v2,v3), …, (vn-1,vn)–For each pair, what are the possibilities?–Consider v1, v2

Inside Outside Inside Outside Inside Outside Inside Outside

v1

v2 v1

v1

v1

v2

v2

v2

output v2 output i no output output i and v2

12年10月23日星期二

Page 59: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

53

Examplev5, v1

v1

v2

v3

v4

v5Inside Outside

v1

Inside Outside

Inside, InsideOutput v1

CurrentOutput

s

p

12年10月23日星期二

Page 60: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

54

v1,v2

v1

v2

v3

v4

v5Inside Outside

v1

v2

Inside Outside

Inside, InsideOutput v2

CurrentOutput

s

p

12年10月23日星期二

Page 61: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

55

v2, v3

v1

v2

v3

v4

v5Inside Outside

v1

v2

Inside Outside

Inside, OutsideOutput i1

CurrentOutput

s

p

i1

i1

12年10月23日星期二

Page 62: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

56

v3, v4

v1

v2

v3

v4

v5Inside Outside

Outside, OutsideNo output

s

p

v1

v2

Inside Outside

CurrentOutput

i1

12年10月23日星期二

Page 63: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

57

v4, v5 – last edge…

v1

v2

v3

v4

v5Inside Outside

Outside, InsideOutput i2, v5

s

p

v1

v2

Inside Outside

CurrentOutput

i1

i2 i2

v5

12年10月23日星期二

Page 64: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Transform

12年10月23日星期二

Page 65: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

3

Transformations

• Procedures to compute new positions of objects

• Used to modify objects or to transform (map) from one co-ordinate system to another co-ordinate system

As all objects are eventually represented using points, it is enough to know how to transform points.

12年10月23日星期二

Page 66: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

4

Translation

• Is a Rigid Body Transformation

• Translation vector (Tx,Ty,Tz) or shift vector

12年10月23日星期二

Page 67: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

5

Translating an Object

(Tx, Ty)

x

y

12年10月23日星期二

Page 68: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

6

Scaling

• Scale factor (Sx, Sy, Sz)

• Changing the size of an object

Sy = 1Sx = 1

Sx = Sy

12年10月23日星期二

Page 69: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

7

Scaling (contd.) Scaling is always with respect to the

origin. The origin does not move.

Scaling wrt a reference point can be achieved as a composite transformation

12年10月23日星期二

Page 70: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

8

Scaling an Object

(x, y)

(x’, y’)

x

y

12年10月23日星期二

Page 71: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

Scaling an Object

(x0,y0)

Question8 : How ?

12年10月23日星期二

Page 72: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

10

Rotation• Is a Rigid Body Transformation

X= r · cos(α+θ)=r cos α cos θ-rsin α sin θ=xcos θ-ysin θ

12年10月23日星期二

Page 73: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

11

Rotation

x

y

φ

θ

(x, y)

(x’, y’)

12年10月23日星期二

Page 74: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

12

Rotation (contd.)

• Rotation also is wrt to a reference -A Reference Line in 3DA Reference Point in 2D

Define 2D rotation about arbitrary point

12年10月23日星期二

Page 75: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

x

y

φ

θ

(x, y)

(x’, y’)

(xr, yr)newx = x−xrnewy = y−yr

newxʹ′ = newx cosθ − newy sinθnewyʹ′ = newy cosθ + newx sinθ

xʹ′ = newxʹ′ + xr yʹ′ = newyʹ′ + yr

xʹ′ = xr+(x−xr)cosθ −(y−yr)sinθyʹ′ = yr+(y−yr)cosθ +(x−xr)sinθ

Rotate around (xr,yr)

12年10月23日星期二

Page 76: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

14

Shearing• Produces shape distortions• Shearing in x-direction

12年10月23日星期二

Page 77: Computer Graphics 2012 5. Geometry and Transform · 2014-05-22 · State Key Lab of CAD&CG, ... values that indicate if they are inside or outside the clip area. 1001 1000 1010 0001

15

General Linear Transformation

• Which of the following can be represented in this form?

Translation Scaling Rotation

or

12年10月23日星期二