好文档 - 专业文书写作范文服务资料分享网站

图形学实验四_Sutherland-Hodgman多边形裁剪算法实验报告

天下 分享 时间: 加入收藏 我要投稿 点赞

《计算机图形学》实验报告

《裁剪算法实验》

姓名 闫学森 学号 3013216087 专业 计算机 班级 3班

天津大学计算机科学与技术学院

2015年 12 月 1日

一、实验目的

实现Sutherland-Hodgman多边形裁剪算法

二、实验内容

自定义裁剪窗口和待裁剪直线段(或多边形),采用不同颜色突出显示裁剪结果

三、实验结果

四、实验分析和总结

Sutherland-Hodgman多边形裁剪算法是将原多边形进行左右下上四次裁剪。其中进行两次分解

? 第一次分解:将多边形关于矩形窗口的裁剪分解为它关于窗口四条边所在直线的裁剪; ? 第二次分解:将多边形关于一条直线的裁剪分解为多边形各边关于该直线的裁剪。

四次裁剪相似,只要修改部分变量即可。但是第一次修改时没有完全改掉,出来的图像不正

确。

通过这次试验使我了解到如何运用计算机程序对窗口进行剪裁,了解到编码剪裁算法直观方便,速度较快,中点分割剪裁算法不用进行乘除运算,剪裁效率高, Sutherland-Hodgman直线裁剪算法更快。

五、源代码

// PolygonClipDemo.cpp : Defines the class behaviors for the application. //

#include \

#include \#include \

#ifdef _DEBUG

#define new DEBUG_NEW #endif

// CPolygonClipDemoApp

BEGIN_MESSAGE_MAP(CPolygonClipDemoApp, CWinApp)

// CPolygonClipDemoApp construction

CPolygonClipDemoApp::CPolygonClipDemoApp() { }

// The one and only CPolygonClipDemoApp object

CPolygonClipDemoApp theApp;

// TODO: add construction code here,

// Place all significant initialization in InitInstance ON_COMMAND(ID_APP_ABOUT, OnAppAbout) END_MESSAGE_MAP()

// CPolygonClipDemoApp initialization

BOOL CPolygonClipDemoApp::InitInstance() { }

// CPolygonClipDemoApp message handlers

// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog {

// Standard initialization

// If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization

SetRegistryKey(_T(\// To create the main window, this code creates a new frame window // object and then sets it as the application's main window object CMainFrame* pFrame = new CMainFrame; m_pMainWnd = pFrame;

// create and load the frame with its resources pFrame->LoadFrame(IDR_MAINFRAME,

WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL);

CWinApp::InitInstance();

// InitCommonControls() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. InitCommonControls();

// The one and only window has been initialized, so show and update it pFrame->ShowWindow(SW_SHOW); pFrame->UpdateWindow();

// call DragAcceptFiles only if there's a suffix

// In an SDI app, this should occur after ProcessShellCommand return TRUE;

public:

// Dialog Data

protected:

// Implementation protected: };

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { }

void CAboutDlg::DoDataExchange(CDataExchange* pDX) { }

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP()

// App command to run the dialog void CPolygonClipDemoApp::OnAppAbout() { }

// CPolygonClipDemoApp message handlers

CAboutDlg aboutDlg; aboutDlg.DoModal();

CDialog::DoDataExchange(pDX); DECLARE_MESSAGE_MAP()

virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support enum { IDD = IDD_ABOUTBOX }; CAboutDlg();

图形学实验四_Sutherland-Hodgman多边形裁剪算法实验报告

《计算机图形学》实验报告《裁剪算法实验》姓名闫学森学号3013216087专业计算机班级3班
推荐度:
点击下载文档文档为doc格式
3onmp7wc5h97tl27ll3h
领取福利

微信扫码领取福利

微信扫码分享