计算机图形学--图形几何变换实现_第1页
计算机图形学--图形几何变换实现_第2页
计算机图形学--图形几何变换实现_第3页
计算机图形学--图形几何变换实现_第4页
计算机图形学--图形几何变换实现_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1 实验五 图形几何变换的实现 班级 信计二班 学号 20080502065 姓名 解川 分数 一 实验目的 为了掌握理解二维 三维的数学知识 变换原理 变换种类 变换方法 进一 步理解采用齐次坐标进行二维 三维变换的必要性 利用 VC 语言实现二维 三维图形的基本变换与复合变换 二 实验内容 1 理解采用齐次坐标进行图形变换的必要性 变换的连续性 使复合变 换得以实现 2 掌握二维 三维图形基本变换的原理及数学公式 3 利用 VC 语言实现二维 三维图形的基本变换 复合变换 在评不上 显示变换过程或变换结果 三 实验步骤 1 预习教材关于二维 三维图形变换的原理与方法 2 使用 VC 语言实现某一种或几种基本变换 3 调试 编译 运行程序 四 原理分析 源程序分别实现了对二维图形进行的平移变换 基本变换 对三维图形进行的 绕某一个坐标轴旋转变换以及相对于立方体中心的比例变换 复合变换 三维几何变换 1 比例变换 T3D 1111zyx 1zyx 1zyx snml rjih qfed pcbq 局部比例变换 其中 a b j 分别为在 x y z 方向的比例系数 s T 1000 000 000 000 j e a 2 整体比例变换 其中 s 为在 xyz 方向的等比例系数 S 1 时 整体缩小 s 1 时 整体 s T s000 0100 0010 0001 放大 2 旋转变换 旋转变换的角度方向为 沿坐标轴的反方向看去 各轴按逆时针方向旋转 绕 z 轴旋转 RZ T 1000 0100 00cossin 00sincos 绕 x 轴旋转 RX T 1000 0cossin0 0sincos0 0001 绕 y 轴旋转 RY T 1000 0cos0sin 0010 0sin0cos 程序代码 三维图形 立方体 旋转变换 比例变换三维图形 立方体 旋转变换 比例变换 include include include include include include define ZOOM IN 0 9 define ZOOM OUT 1 1 3 int turn1 3 0 rx 1 ry 3 zoom typedef struct float x float y float z point typedef struct float x float y point2d typedef struct float x float y float h point biao 8 fanti void make box float x float y float h fanti p p x x p y y p h h p biao 0 x x 2 p biao 0 y y 2 p biao 0 z h 2 p biao 1 x x 2 p biao 1 y y 2 p biao 1 z h 2 p biao 2 x x 2 p biao 2 y y 2 p biao 2 z h 2 p biao 3 x x 2 p biao 3 y y 2 p biao 3 z h 2 p biao 4 x x 2 p biao 4 y y 2 p biao 4 z h 2 p biao 5 x x 2 p biao 5 y y 2 p biao 5 z h 2 p biao 6 x x 2 p biao 6 y y 2 p biao 6 z h 2 p biao 7 x x 2 p biao 7 y y 2 p biao 7 z h 2 void trun2d point p point2d q q x p x p z cos 0 25 q y p y p z sin 0 25 4 void initm float mat 4 int count for count 0 countx tm 1 0 p y tm 2 0 p z tm 3 0 yv tm 0 1 p x tm 1 1 p y tm 2 1 p z tm 3 1 zw tm 0 2 p x tm 1 2 p y tm 2 2 p z tm 3 2 p x xu p y yv p z zw return void rotationx point p float alfa float tm 4 float rad 0 0174532925 initm tm tm 1 1 cos rad alfa tm 1 2 sin rad alfa tm 2 1 tm 1 2 tm 2 2 tm 1 1 return 5 void rotationz point p float alfa float tm 4 float rad 0 0174532925 initm tm tm 0 0 cos rad alfa tm 0 1 sin rad alfa tm 1 0 tm 0 1 tm 1 1 tm 0 0 return void rotationy point p float alfa float tm 4 float rad 0 0174532925 initm tm tm 0 0 cos rad alfa tm 2 0 sin rad alfa tm 0 2 tm 2 0 tm 2 2 tm 0 0 return void adjust point p point q float t 4 4 switch turn1 0 case 1 rotationy p 2 t transfrom p q t break case 1 rotationy p 2 t transfrom p q t break default break switch turn1 1 6 case 1 rotationz p 2 t transfrom p q t break case 1 rotationz p 2 t transfrom p q t break default break switch turn1 2 case 1 q x ZOOM IN p x q y ZOOM IN p y q z ZOOM IN p z break case 1 q x ZOOM OUT p x q y ZOOM OUT p y q z ZOOM OUT p z break default break void drawbox fanti p point2d fan2d 8 int i 7 for i 0 ibiao i trun2d fan2d i x 300 fan2d i y 200 cleardevice outtext right left up v down moveto 0 20 outtext page up zoom in page down zoom out space Redraw Esc exit for i 0 i 3 i if i 3 line fan2d i x fan2d i y fan2d 0 x fan2d 0 y line fan2d i 4 x fan2d i 4 y fan2d 4 x fan2d 4 y else line fan2d i x fan2d i y fan2d i 1 x fan2d i 1 y line fan2d i 4 x fan2d i 4 y fan2d i 5 x fan2d i 5 y line fan2d i x fan2d i y fan2d i 4 x fan2d i 4 y void main int gd DETECT gm i j 8 char key float x y h fanti a1 x 100 y 100 h 100 initgraph setcolor GREEN make box x y h for turn1 0 0 turn1 1 0 turn1 2 0 key getch switch key case 77 turn1 0 1 break RIGHT case 75 turn1 0 1 break LIFT case 72 turn1 1 1 break UP case 80 turn1 1 1 break DOWN case 73 turn1 2 1 break Zoom In case 81 turn1 2 1 break Zoom Out case 32 make box x y h break Redraw case 27 exit 0 break default ke

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论