⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bezier3d.h

📁 This is a simple code sample to interpolate a 3d set of points using the bezier algorithm minimized
💻 H
字号:
#include "vector3d.h"
#include "Math3d.h"


class bezier3d {
public:

	void Interpolate(Vec3d *list, int size, int iterations);
	// create deltas for forward differencing
	virtual void forwdiff 
	(
		long steps,                // number of steps p1...p4
		const vector3d &p1,  // point 1 (start-point)
		const vector3d &z12, // point 2 (intermediate 1)
		const vector3d &z21, // point 3 (intermediate 2)
		const vector3d &p2,  // point 4 (end point)
		vector3d &delta1,    // out: delta 1 
		vector3d &delta2,    // out: delta 2 
		vector3d &delta3)    // out: delta 3
	{
	double step1 = 1.0 / (double)(steps-1);
	double step2 = step1*step1;
	double step3 = step2*step1;

	vector3d a (-p1.x + 3.0*z12.x - 3.0*z21.x + p2.x,
					  -p1.y + 3.0*z12.y - 3.0*z21.y + p2.y,
					  -p1.z + 3.0*z12.z - 3.0*z21.z + p2.z);
	vector3d b (3.0*p1.x - 6.0*z12.x + 3.0*z21.x,
					  3.0*p1.y - 6.0*z12.y + 3.0*z21.y,
					  3.0*p1.z - 6.0*z12.z + 3.0*z21.z);
	vector3d c (-3.0*p1.x + 3.0*z12.x,
					  -3.0*p1.y + 3.0*z12.y,
					  -3.0*p1.z + 3.0*z12.z);

	delta1.set (a.x*step3 + b.x*step2 + c.x*step1,
				a.y*step3 + b.y*step2 + c.y*step1,
				a.z*step3 + b.z*step2 + c.z*step1);
	delta2.set (6.0*a.x*step3 + 2.0*b.x*step2,
				6.0*a.y*step3 + 2.0*b.y*step2,
				6.0*a.z*step3 + 2.0*b.z*step2);
	delta3.set (6.0*a.x*step3,
				6.0*a.y*step3,
				6.0*a.z*step3);
	}

  // ...
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -