实验10 Bezier曲线生成-实验提高-控制点生成B样条曲线

本文展示了如何使用控制点(10,5,0), (5,10,0), (-5,15,0), ... 和 (10,5,0) 生成三次B样条曲线,并通过代码实例讲解了计算和绘制过程。

本代码根据已知控制点( 10, 5, 0 ),( 5, 10, 0 ),( -5, 15, 0 ),( -10, -5, 0 ),( 4, -4, 0 ),( 10, 5, 0 ), ( 5, 10, 0 ), ( -5, 15, 0 ), ( -10, -5, 0 ),( 10, 5, 0 )来生成三次B样条曲线。

#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

struct Point
{
   
   
	float c[2];
	float& x = c[0];
	float& y = c[1];

	Point() {
   
    x = 0, y = 0; }
	Point(float x0, float y0) {
   
    x = x0, y = y0; }
	Point(const Point& pt) {
   
    x = pt.x, y = pt.y; }
	float& operator[](const int i) {
   
    return c[i]; }
};

vector<Point> GctrlPt, GbsCurvePt;
int GnumSegment = 10;

void CalcBSPoints()
{
   
   
	int numCtrPt = GctrlPt.size();
	float F0[2], F1[2], F2[2], F3[2];

	float t = 0;
	float dt = 1 / (float)GnumSegment;

	//第一段NumSubSegment + 1个点,第二段之后每段为NumSubSegment个点,因为第二段之后的起点为前一段的终点
	int numCurvePoint = (GnumSegment + 1) + GnumSegment * (numCtrPt - 4
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

图形空间

文章不错,赞赏鼓励

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值