chapter 3 the foundation of computer graphics

45
Chapter 3 the foundation of Computer graphics

Upload: ruby-small

Post on 03-Jan-2016

48 views

Category:

Documents


7 download

DESCRIPTION

Chapter 3 the foundation of Computer graphics. 教学要求和教学提示. 教学提示: 本章主要介绍计算机绘图软件的类型和功能、绘图程序的基本设计方法、图形软件标准和图形变换 ( 二维图形和三维图形的几何变换 教学要求: 了解计算机绘图系统的类型及组成 掌握图形变换(比例、对称、错切、平移、旋转、复合变换等)的原理和方法 了解常用自由曲线. Contents. 1.Outline of computer drawing 2.Computer drawing software 3.Coordinate system - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 3 the foundation of Computer graphics

Chapter 3

the foundation of Computer graphics

Page 2: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 2

教学要求和教学提示教学提示: 本章主要介绍计算机绘图软件的类型和功能、绘图程序的基本设计

方法、图形软件标准和图形变换 ( 二维图形和三维图形的几何变换教学要求: 了解计算机绘图系统的类型及组成 掌握图形变换(比例、对称、错切、平移、旋转、复合变换等)的

原理和方法 了解常用自由曲线

Page 3: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 3

Contents 1.Outline of computer drawing 2.Computer drawing software 3.Coordinate system 4.Graphics transformation 5.Transform of 3D graphics 6.Projection transform of 3D graphics 7.Free form curve and surface

Page 4: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 4

计算机绘图是 CAD/CAM 的重要组成部分。其发展有力地推动了 CAD/CAM 的研究和应用,为 CAD/CAM 提供了高效的工具和手段;CAD/CAM 的发展又不断提出新的要求和设想,其中包括对计算机绘图的要求因此 CAD/CAM 的发展与计算机绘图的发展有着密不可分的关系。 Computer drawing is the important part of CAD/CAM. The development of computer drawing powerfully drove the researches and applications of CAD/CAM, and provided highly effective tools and methods for CAD/CAM; in addition, the development of CAD/CAM constantly sets forth new requirements and ideas, including the requirements for computer drawing. Thus, there is a inseparable relationship between the development of CAD/CAM and the development of computer drawing.

3.1 Outline of computer drawing

Page 5: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 5

Applications:

Mechanics Architecture Costume design Video

3.1 Outline of computer drawing

Page 6: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 6

3.2 Computer drawing software 计算机绘图软件的主要功能

Graphic descriptions Graphic edit and transformation Graphic control Graphic files processing Interactive processing

可画点、线、圆、圆弧、文本、多边形、椭圆、曲线等能进行几何计算。如求交点、切点等 对图形进行删除、修改实现图形的几何变换,如缩放、旋转、投影等 显示控制、图形输出控制可将不同方位或不同内容的图形定义成文件进行处理,便于统一调度管理人机界面良好,因为 CAD 过程是个反复试探、修改的过程

Page 7: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 7

class

coordinate system

DCS: device coordinate systemVDCS: virtual device coordinate systemNDCS: normalized device coordinate system  

WCS: world coordinate system

  MCS: modeling coordinate systemVCS: viewing coordinate system

直角坐标系仿射坐标系圆柱坐标系   球坐标系

3.3 coordinate system

Page 8: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 8

DCS: 用于在图形显示设备上定义图形或窗口的位置。计算机对图形对象进行了必要的处理之后,要将它在图形显示器或者绘图纸上绘制出来,这就要在显示屏幕上或绘图纸上定义一个坐标系,这个坐标系叫做屏幕坐标系或者设备坐标系设备坐标系的 z 轴垂直于屏幕平面。利用设备坐标系编写图形程序时,在不同显示设备上显示图形是不同的。

x

yy

x

xy

3.3 coordinate system

Page 9: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 9

NDCS and VDCS :规格化设备坐标系是直角坐标系,它是将二维的设备坐标系规格化到( 0.0 , 0.0 )~( 1.0,1.0 )的坐标范围内形成的,规范化坐标系保证了观察变换独立于输出设备。其原点常位于显示器左下角, x,y 分别指向右方和上方。规格化坐标系是用于定义视图的。虚拟设备坐标系和规格化坐标系类似,是编写图形程序时采用的。

x

y

3.3 coordinate system

Page 10: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 10

WCS : 用于描述现实世界的整体布局,又称为用户坐标系。1) 直角坐标系,又称笛卡尔坐标系,由一个原点(坐标为(0,0,0) )和三个通过原点的、相互垂直的坐标轴构成。分右手坐标系和左手坐标系两种。任一点可用 p ( x,y,z )表示。

3.3 coordinate system

Page 11: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 11

2)仿射坐标系 其三个坐标轴不是相互垂直的

cbaOP

3.3 coordinate system

Page 12: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 12

3) 圆柱坐标系用来描述旋转体的形状。

3.3 coordinate system

Page 13: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 13

4) 球坐标系3.3 coordinate system

Page 14: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 14

MCS : 用于描述世界坐标系中每个具体物体的形状,又称为局部坐标系。当物体空间位置发生变化时,由造型坐标系定义的物体上各点的坐标值不变。

3.3 coordinate system

Page 15: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 15

VCS :为了在世界坐标系中实现对三维物体的观察而建立的坐标系。

有两个主要用途:用于指定裁剪空间确定的那一部分形体的显示输出;通过定义观察平面,把三维形体的世界坐标变换成规格化的设备坐标

3.3 coordinate system

Page 16: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 16

Coordinates transform :3.3 coordinate system

Page 17: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 17

不同的坐标系之间通过变换矩阵建立联系MCS

WCS

VCS

DCS

造型变换

观察变换

VDCS投影变换

3.3 coordinate system

Page 18: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 18

3.4 Transform of 2D graphics1. 二维图形几何变换的一般表示将二维空间中的任意点 P ( x , y )变换到一个新位置,其数学表达为:

矩阵表达

令 ,称该矩阵为变换矩阵

dybxcyaxdc

bayxyx

''

dybxy

cyaxx

'

'

dc

baT

Page 19: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 19

3.4 Transform of 2D graphics 二维基本变换

比例变换 对称变换 旋转变换 错切变换 平移变换

Page 20: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 20

3.4 Transform of 2D graphics1) 比例变换 将原有图形在 x 、 y 两个方向上进行放大或缩小的变换,其变换矩阵为:

当 a=d=1 ,变换为恒等变换,即变换后点的坐标不变当 a=d≠1 ,变换为等比例变换,即变换为等比例放大或缩小当 a ≠ d , 变换后的图形会产生畸变

)0,0(0

0

da

d

aTs

Page 21: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 21

2 )对称变换 对称变换又称为镜像变换,主要包括以下几种:

对 x 轴的对称变换 对 y 轴的对称变换 对直线 y = x 的对称变换 对直线 y = -x 的对称变换 对坐标原点的对称变换

3.4 Transform of 2D graphics

Page 22: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 22

3.4 Transform of 2D graphics关于 x 轴的对称变换:           x’=x , y’=-y

变换矩阵为: 点关于 x 轴的对称变换为:

10

01,xmT

yxyxyx

10

01''

Page 23: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 23

关于 y 轴的对称变换:        x’=-x , y’=y

变换矩阵:

点关于 y 轴的对称变换:

10

01,ymT

yxyxyx

10

01''

3.4 Transform of 2D graphics

Page 24: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 24

3.4 Transform of 2D graphics关于直线 y=x 的对称变换 :          x’= y , y’=x

变换矩阵:

点关于直线 y=x 的对称变换为:

01

10, xymT

xyyxyx

01

10''

Page 25: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 25

3.4 Transform of 2D graphics关于直线 y=-x 的对称变换 :        x’= -y , y’=-x

变换矩阵为:

点关于直线 y=-x 的对称变换为:

01

10, xymT

xyyxyx

01

10''

Page 26: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 26

3.4 Transform of 2D graphics关于坐标原点的对称变换 :        x’=-x , y’=-y

变换矩阵为:

点关于坐标原点的对称变换为:

10

01,OmT

yxyxyx

10

01''

Page 27: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 27

3.4 Transform of 2D graphics3) 旋转变换 : 逆时针方向逆时针方向

为正为正

cossin

sincosrT

绕原点旋转的变换矩阵为:点绕原点旋转的变换为:

α

θρ (x,y)

(x’,y’)

sin

cos

y

x

cossinsincoscossin)sin(

sincossinsincoscos)cos(

yxy

yxx

cossinsincos

cossin

sincos'' yxyxyxyx

Page 28: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 28

3.4 Transform of 2D graphics4) 错切变换 使图形沿错切方向的坐标发生变化,

而另一方向的坐标值不变,从而达到使原图形发生特定变化的目的,分为以下两种形式:

• 沿 y 轴方向的错切

cy

bx

• 沿 x 轴方向的错切

Page 29: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 29

沿 x 轴方向的错切变换: x’=x+x , y’=y ,

变换矩阵为:

点沿 x 轴措切变换

3.4 Transform of 2D graphics

cy

1

01, c

T xsh

ycyxc

yxyx

1

01''

Page 30: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 30

沿 y 轴方向的错切变换 :       x’=x , y’=y + y ,

变换矩阵为:

点沿 y 轴方向的错切变换为:

bx

10

1,

bT ysh

ybxxb

yxyx

10

1''

3.4 Transform of 2D graphics

Page 31: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 31

3.4 Transform of 2D graphics5) 平移变换 x’=x+m y’=y+n 矩阵表示: [x’ y’]=[x y]+[m n]=[x y]+Ti

变换矩阵??

Page 32: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 32

2. 点的齐次坐标表示

所谓齐次坐标表示法就是用 n+1 维向量表示一个 n 维向

[x y] [hx hy h] ;

令 h=1 [x y 1] 齐次坐标的正常化齐次坐标的正常化

3.4 Transform of 2D graphics

Page 33: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 33

点的矩阵表达 :

齐次坐标 :

yxP

mm yx

yx

yx

22

11

1yxP

1

1

1

22

11

mm yx

yx

yx

3.4 Transform of 2D graphics

Page 34: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 34

引入齐次坐标后,可以用一个统一的 3X3 矩阵来描述包括平移在内的全部二维图形变换,即:

其中: 产生比例、对称、旋转和错切 变换;产生平移变换;

[p q] 产生投影变换,通常不做投影变换时取 p=0 , q=0

[s] 为全比例因子,使图形产生总体的比例变化,通常取S=1 ;

3.4 Transform of 2D graphics

dc

ba

nm

Page 35: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 35

平移变换:

P(x,y)

P’(x’y’)mn

X

Y

1

010

001

nm

TM变换矩阵:

点的平移变换则可用矩阵表示为:

3.4 Transform of 2D graphics

1

1

010

001

11'' nymx

nm

yxyx

引入坐标的齐次表示法,各基本变换的矩阵:

Page 36: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 36

3.4 Transform of 2D graphics 比例变换

100

0d0

00a

ST变换矩阵:

a=d=1 a=d>1 a=d<1 a≠d

Page 37: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 37

3.4 Transform of 2D graphics对称变换

以 x 轴对称

100

010

001

T

Page 38: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 38

3.4 Transform of 2D graphics对称变换

以 y 轴对称

100

010

001

T

Page 39: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 39

3.4 Transform of 2D graphics对称变换

以原点对称

100

010

001

T

Page 40: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 40

3.4 Transform of 2D graphics对称变换

以 y=x 直线对称

100

001

010

T

Page 41: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 41

3.4 Transform of 2D graphics对称变换

以 y=-x 直线对称

100

001

010

T

Page 42: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 42

错切变换 变换矩阵:

3.4 Transform of 2D graphics

100

010

01

100

01

001

,

,

b

T

cT

ysh

xsh

cy

bx

Page 43: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 43

3.4 Transform of 2D graphics

100

0cossin

0sincos

RT

旋转变换 逆时针方向为正逆时针方向为正

Page 44: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 44

3.4 Transform of 2D graphics

3. 二维组合变换: here ex: 一平面图形绕任意点旋转角,求其旋转矩阵 T1 – 旋转中心平移到坐标原点的变换矩阵 T2 – 绕坐标原点旋转角的变换矩阵 T3 – 将旋转中心平移回原位置的变换矩阵

1

010

001

100

0cossin

0sincos

1

010

001

321

pppp yxyx

TTTT

Page 45: Chapter 3 the foundation of Computer graphics

23/4/20 上理机械 吴恩启 45

3.4 Transform of 2D graphics 上机作业: 利用 VB 语言编写程序:实现矩形绕任意一点

的旋转变换