NEFU计算机图形学实验四

编写二次插值样条曲线生成函数,然后利用该函数根据自己设计的型值点绘制出相应的曲线图形。

// erView.cpp : implementation of the CErView class
//#include "stdafx.h"
#include "er.h"#include "erDoc.h"
#include "erView.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/
// CErView
void er(POINT *p,int n,CDC* pDC)
{int x,y,i,j,k=10;double t1,t2,t3,t,a,b,c,d;p[0].x=p[1].x;p[0].y=p[1].y;p[n+1].x=p[n].x;p[n+1].y=p[n].y;t=0.5/k;pDC->MoveTo(p[1].x,p[1].y);for(i=1;i<n;i++){for(j=1;j<k;j++){t1=j*t;t2=t1*t1;t3=t1*t2;a=4.0*t2-t1-4.0*t3;		b=1.0-10.0*t2+12.0*t3;	c=t1+8.0*t2-12.0*t3;	d=4.0*t3-2.0*t2;		x=(int)(a*p[i-1].x+b*p[i].x+c*p[i+1].x+d*p[i+2].x);y=(int)(a*p[i-1].y+b*p[i].y+c*p[i+1].y+d*p[i+2].y);pDC->LineTo(x,y);}pDC->LineTo(p[i+1].x,p[i+1].y);}
}IMPLEMENT_DYNCREATE(CErView, CView)BEGIN_MESSAGE_MAP(CErView, CView)//{{AFX_MSG_MAP(CErView)// NOTE - the ClassWizard will add and remove mapping macros here.//    DO NOT EDIT what you see in these blocks of generated code!//}}AFX_MSG_MAP// Standard printing commandsON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()/
// CErView construction/destructionCErView::CErView()
{// TODO: add construction code here}CErView::~CErView()
{
}BOOL CErView::PreCreateWindow(CREATESTRUCT& cs)
{// TODO: Modify the Window class or styles here by modifying//  the CREATESTRUCT csreturn CView::PreCreateWindow(cs);
}/
// CErView drawingvoid CErView::OnDraw(CDC* pDC)
{CErDoc* pDoc = GetDocument();ASSERT_VALID(pDoc);// TODO: add draw code for native data hereint n=4;POINT ps[6];ps[1].x=25;ps[1].y=400;ps[2].x=100;ps[2].y=100;ps[3].x=175;ps[3].y=400;ps[4].x=250;ps[4].y=100;er(ps,n,pDC);}/
// CErView printingBOOL CErView::OnPreparePrinting(CPrintInfo* pInfo)
{// default preparationreturn DoPreparePrinting(pInfo);
}void CErView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{// TODO: add extra initialization before printing
}void CErView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{// TODO: add cleanup after printing
}/
// CErView diagnostics#ifdef _DEBUG
void CErView::AssertValid() const
{CView::AssertValid();
}void CErView::Dump(CDumpContext& dc) const
{CView::Dump(dc);
}CErDoc* CErView::GetDocument() // non-debug version is inline
{ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CErDoc)));return (CErDoc*)m_pDocument;
}
#endif //_DEBUG/
// CErView message handlers

编写任意阶次的Bezier曲线生成函数,然后利用该函数根据自己设计的控制点绘制出相应的曲线图形。

// renView.cpp : implementation of the CRenView class
//#include "stdafx.h"
#include "ren.h"#include "renDoc.h"
#include "renView.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/
// CRenView
double powi(double v,int k){double temp=1.0;if(k==0||v==0)return 1;else {for(int i=1;i<=k;i++)temp=temp*v;}return temp;}long fac(int m){int i;long temp=1;if(m==1)return 1;else {for(i=2;i<=m;i++)temp=temp*i;}return temp;}void Bezier(POINT *p,int n,CDC *pDC){int x,y,i,j,k=100;double t=1.0/k,t1,u,v;double temp,temp1,temp2,bi;pDC->MoveTo(p[0].x,p[0].y);for(j=1;j<k;j++){t1=j*t;u=t1;v=1-u;x=0;y=0;for(i=0;i<=n;i++){temp=double(fac(n)/fac(i)/fac(n-i));temp1=powi(u,i);temp2=powi(v,n-i);bi=temp*temp1*temp2;x=x+bi*p[i].x;y=y+bi*p[i].y;}pDC->LineTo(x,y);}pDC->LineTo(p[n].x,p[n].y);}IMPLEMENT_DYNCREATE(CRenView, CView)BEGIN_MESSAGE_MAP(CRenView, CView)//{{AFX_MSG_MAP(CRenView)// NOTE - the ClassWizard will add and remove mapping macros here.//    DO NOT EDIT what you see in these blocks of generated code!//}}AFX_MSG_MAP// Standard printing commandsON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()/
// CRenView construction/destructionCRenView::CRenView()
{// TODO: add construction code here}CRenView::~CRenView()
{
}BOOL CRenView::PreCreateWindow(CREATESTRUCT& cs)
{// TODO: Modify the Window class or styles here by modifying//  the CREATESTRUCT csreturn CView::PreCreateWindow(cs);
}/
// CRenView drawingvoid CRenView::OnDraw(CDC* pDC)
{CRenDoc* pDoc = GetDocument();ASSERT_VALID(pDoc);int n=5;CPoint ps[6]={CPoint(25,400),CPoint(100,100),CPoint(170,400),CPoint(250,20),CPoint(450,300),CPoint(350,400)};CPen pen1(PS_DASHDOT,1,RGB(28,28,28));pDC->SelectObject(&pen1);pDC->Polyline(ps,6);CPen pen2(PS_DASHDOT,2,RGB(255,0,0));pDC->SelectObject(&pen2);Bezier(ps,n,pDC);
} /
// CRenView printingBOOL CRenView::OnPreparePrinting(CPrintInfo* pInfo)
{// default preparationreturn DoPreparePrinting(pInfo);
}void CRenView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{// TODO: add extra initialization before printing
}void CRenView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{// TODO: add cleanup after printing
}/
// CRenView diagnostics#ifdef _DEBUG
void CRenView::AssertValid() const
{CView::AssertValid();
}void CRenView::Dump(CDumpContext& dc) const
{CView::Dump(dc);
}CRenDoc* CRenView::GetDocument() // non-debug version is inline
{ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRenDoc)));return (CRenDoc*)m_pDocument;
}
#endif //_DEBUG/
// CRenView message handlers

编写三次B样条曲线生成函数,然后利用该函数根据自己设计的控制点绘制出相应的曲线图形。

// sanView.cpp : implementation of the CSanView class
//#include "stdafx.h"
#include "san.h"#include "sanDoc.h"
#include "sanView.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/
// CSanView
void BSpLine(POINT *p,int n,CDC* pDC)
{int x,y,i,j,k=1000;double t,t1,t2,t3,a,b,c,d;t=1.0/k;p[0].x=2*p[1].x-p[2].x;p[0].y=2*p[1].y-p[2].y;p[n].x=2*p[n-1].x-p[n-2].x;p[n].y=2*p[n-1].y-p[n-2].y;pDC->MoveTo(p[1].x,p[1].y);for(i=1;i<n-1;i++)for(j=1;j<=k;j++){t1=j*t;t2=t1*t1;t3=t2*t1;a=(3*t2-t3-3*t1+1)/6;b=(3*t3-6*t2+4)/6;c=(3*t2-3*t3+3*t1+1)/6;d=t3/6;x=int(a*p[i-1].x+b*p[i].x+c*p[i+1].x+d*p[i+2].x);y=int(a*p[i-1].y+b*p[i].y+c*p[i+1].y+d*p[i+2].y);pDC->LineTo(x,y);}
}IMPLEMENT_DYNCREATE(CSanView, CView)BEGIN_MESSAGE_MAP(CSanView, CView)//{{AFX_MSG_MAP(CSanView)// NOTE - the ClassWizard will add and remove mapping macros here.//    DO NOT EDIT what you see in these blocks of generated code!//}}AFX_MSG_MAP// Standard printing commandsON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()/
// CSanView construction/destructionCSanView::CSanView()
{// TODO: add construction code here}CSanView::~CSanView()
{
}BOOL CSanView::PreCreateWindow(CREATESTRUCT& cs)
{// TODO: Modify the Window class or styles here by modifying//  the CREATESTRUCT csreturn CView::PreCreateWindow(cs);
}/
// CSanView drawingvoid CSanView::OnDraw(CDC* pDC)
{CSanDoc* pDoc = GetDocument();ASSERT_VALID(pDoc);// TODO: add draw code for native data hereint n=5;POINT ps[6];ps[1].x=350;ps[1].y=250;ps[2].x=500;ps[2].y=20;ps[3].x=600;ps[3].y=250;ps[4].x=750;ps[4].y=30;CPen pen1(PS_DASHDOT,2,RGB(0,0,255));pDC->SelectObject(&pen1);BSpLine(ps,n,pDC);CPen pen2(PS_DASHDOT,1,RGB(28,28,28));pDC->SelectObject(&pen2);pDC->Polyline(ps,6);} /
// CSanView printingBOOL CSanView::OnPreparePrinting(CPrintInfo* pInfo)
{// default preparationreturn DoPreparePrinting(pInfo);
}void CSanView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{// TODO: add extra initialization before printing
}void CSanView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{// TODO: add cleanup after printing
}/
// CSanView diagnostics#ifdef _DEBUG
void CSanView::AssertValid() const
{CView::AssertValid();
}void CSanView::Dump(CDumpContext& dc) const
{CView::Dump(dc);
}CSanDoc* CSanView::GetDocument() // non-debug version is inline
{ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSanDoc)));return (CSanDoc*)m_pDocument;
}
#endif //_DEBUG/
// CSanView message handlers

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/829481.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

大型语言模型高效推理综述

论文地址&#xff1a;2404.14294.pdf (arxiv.org) 大型语言模型&#xff08;LLMs&#xff09;由于在各种任务中的卓越表现而受到广泛关注。然而&#xff0c;LLM推理的大量计算和内存需求给资源受限的部署场景带来了挑战。该领域的努力已经朝着开发旨在提高LLM推理效率的技术方…

C语言递归刷题(一)

目录 走台阶题目思路代码 西格玛题目思路代码 用函数实现数的阶乘题目思路代码 digit题目思路代码 Hermite多项式题目思路代码 排列数题目思路代码 逆序输出题目思路代码 结语 走台阶 题目 描述 小乐乐上课需要走n阶台阶&#xff0c;因为他腿比较长&#xff0c;所以每次可以选…

挑战特斯拉?深蓝汽车与华为强强联手

作为中国乃至全球汽车行业的盛宴&#xff0c;4月25日在中国国家展览中心揭幕的2024北京国际车展&#xff0c;吸引了无数企业行业人士的关注。 而就在车展开幕当天&#xff0c;深蓝汽车发布会就爆出了一个大新闻&#xff1a;深蓝汽车将携手华为&#xff0c;打造比特斯拉更好的智…

【开发问题记录】启动某个服务时请求失败(docker-componse创建容器时IP参数不正确)

问题记录 一、问题描述1.1 产生原因1.2 产生问题 二、问题解决2.1 找到自己的docker-compose.yml文件2.2 重新编辑docker-compose.yml文件2.3 通过docker-componse重新运行docker-compose.yml文件2.4 重新启动docker容器2.5 查看seata信息 一、问题描述 1.1 产生原因 因为我是…

FPGA 以太网通信UDP通信环回

1 实验任务 上位机通过网口调试助手发送数据给 FPGA &#xff0c; FPGA 通过 PL 端以太网接口接收数据并将接收到的数据发送给上位机&#xff0c;完成以太网 UDP 数据的环回。 2 系统设计 系统时钟经过PLL时钟模块后&#xff0c;生成了两种不同频率和相位的时钟信号&#…

Python 面向对象——6.封装

本章学习链接如下&#xff1a; Python 面向对象——1.基本概念 Python 面向对象——2.类与对象实例属性补充解释&#xff0c;self的作用等 Python 面向对象——3.实例方法&#xff0c;类方法与静态方法 Python 面向对象——4.继承 Python 面向对象——5.多态 1. 封装的基…

unity cinemachine相机 (案例 跟随角色移动)

安装相机包 打开包管理工具 在 unity registry 搜索cinemachine 会在maincamera中生成一个组件cinemachineBrain 只能通过虚拟相机操控 主相机 虚拟相机的参数 案例 1.固定相机效果 位置 在固定的地方 默认的模式 2.相机跟随人物效果 焦距设置 20 跟随设置 把playere…

使用Tortoise 创建远程分支

1。首先创建本地分支branch1&#xff0c;右键tortoise git->创建分支&#xff0c;输入分支名称branch1&#xff0c;确定。 2。右键tortoise git->推送&#xff0c;按下图设置&#xff0c;确定&#xff0c;git会判断远程有没有分支branch1&#xff0c;如果没有会自动创建…

重看Spring聚焦Environment分析

目录 一、理解Environment的设计 &#xff08;一&#xff09;整体理解 &#xff08;二&#xff09;聚焦Profiles分析 &#xff08;三&#xff09;聚焦Properties分析 二、Environment类图结构分析 三、PropertyResolver源码分析 &#xff08;一&#xff09;源码展示说明…

C语言学习/复习36

一、程序的环境与预处理 二、翻译环境与执行环境 三、运行环境 四、预编译(预处理)详解

mac电脑搭建vue环境(上篇)

第一步&#xff1a;mac电脑要有homebrew&#xff0c;如何安装homebrew 点击下方 MAC安装homebrew-CSDN博客 第二步&#xff1a;homebrew安装node.js 第三步&#xff1a;安装npm 第四步&#xff1a;安装webpack 第五步&#xff1a;安装vue脚手架 第六步&#xff1a;可以在…

NumPy 1.26 中文官方指南(一)

NumPy 用户指南 原文&#xff1a;numpy.org/doc/1.26/user/index.html 本指南是一个概述&#xff0c;解释了重要特性&#xff1b;细节请参阅 NumPy 参考文档。 入门指南 什么是 NumPy? 安装 NumPy 快速入门 NumPy&#xff1a;初学者的绝对基础 基础知识和用法 NumPy 基础…

工信部绿色工厂、绿色设计产品、绿色供应链企业、绿色园区名单数据集(2017-2022年)

01、数据简介 工信部致力于推动制造业的绿色转型&#xff0c;为了表彰在绿色制造领域取得显著成绩的企业和园区&#xff0c;工信部发布了绿色工厂公示名单、绿色设计产品公示名单、绿色供应链企业公示名单和绿色园区公示名单。 这些企业和园区在绿色制造方面做出了卓越的贡献…

MySQL__锁

文章目录 &#x1f60a; 作者&#xff1a;Lion J &#x1f496; 主页&#xff1a; https://blog.csdn.net/weixin_69252724 &#x1f389; 主题&#xff1a; MySQL__锁&#xff09; ⏱️ 创作时间&#xff1a;2024年04月27日 ———————————————— 这里写目录…

刷题训练之前缀和

> 作者&#xff1a;დ旧言~ > 座右铭&#xff1a;松树千年终是朽&#xff0c;槿花一日自为荣。 > 目标&#xff1a;熟练掌握前缀和算法。 > 毒鸡汤&#xff1a;学习&#xff0c;学习&#xff0c;再学习 ! 学&#xff0c;然后知不足。 > 专栏选自&#xff1a;刷题…

【Hadoop】-HDFS的存储原理[4]

目录 前言 一、fsck命令 1、HDFS副本块数量的配置 2、fsck命令查看文件的副本数 3、block配置 二、NameNode元数据 1、edits文件 2、fsigame文件 3、NameNode元数据管理维护 4、元数据合并控制参数 5、SecondaryNameNode的作用 三、HDFS数据的读写流程 1、数据写入…

Pytorch 之torch.nn初探 卷积--Convolution Layers

任务描述 本关任务&#xff1a; 本关提供了一个Variable 类型的变量input&#xff0c;按照要求创建一 Conv1d变量conv&#xff0c;对input应用卷积操作并赋值给变量 output&#xff0c;并输出output 的大小。 相关知识 卷积的本质就是用卷积核的参数来提取原始数据的特征&a…

前端HTML5学习1(新增布局,状态,列表,文本,表单控件标签)

前端HTML5学习1&#xff08;新增布局&#xff0c;状态&#xff0c;列表&#xff0c;文本&#xff0c;表单控件标签&#xff09; 新增布局标签新增状态标签新增列表标签新增文本标签新增表单控件属性input新增属性值 新增布局标签 HTML5 引入了许多新的语义化标签&#xff0c;用…

【MySQL】A01、性能优化-参数监控分析

1、参数监控 1.1、MySQL command 查看 mysql>SHOW STATUS; &#xff08;服务器状态变量&#xff0c;运行服务器的统计和状态指标&#xff09; mysql> SHOW VARIABLES;&#xff08;服务器系统变量&#xff0c;实际上使用的变量的值&#xff09; mysql> SHOW STATUS …

SpringBoot---------Hutool

第一步&#xff1a;引入依赖 <dependency><groupId>cn.hutool</groupId><artifactId>hutool-parent</artifactId><version>5.7.17</version></dependency> 第二步&#xff1a;各种用法 ①生成随机数 //生成验证码 String s …