当前位置:网站首页>N-degree Bessel curve
N-degree Bessel curve
2022-06-12 06:07:00 【Rulelur】
n Recursion formula of subbezier curve :
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.translate(10, 10); // Remap... On canvas (0,0) Location , Avoid spillovers
function drawCircle(x, y, color, r = 6) {
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(x, y, r, 0, 2 * Math.PI);
ctx.fill();
}
function drawPath(path) {
ctx.beginPath();
path.forEach((p, i) => {
if (i) {
ctx.lineTo(p.x, p.y);
} else {
ctx.moveTo(p.x, p.y);
}
});
ctx.stroke();
}
function bezier(pointList, t) {
if (pointList.length === 1) {
return pointList[0];
} else {
// B(t)=(1-t)Bp0p1…pn-1(t) + tBp1p2…pn(t)
var p1 = bezier(pointList.slice(0, -1), t);
var p2 = bezier(pointList.slice(1), t);
var p = {
x: (1 - t) * p1.x + t * p2.x,
y: (1 - t) * p1.y + t * p2.y,
};
return p;
}
}
var startPoint = { x: 0, y: 0 };
var endPoint = { x: 900, y: 0 };
var pointList = [
startPoint,
// In the middle is the control point
{ x: 300, y: 0 },
{ x: 400, y: 100 },
{ x: 600, y: 200 },
{ x: 700, y: 0 },
endPoint,
];
// draw a curve
var path = [];
for (var i = 0; i <= 100; i++) {
path.push(bezier(pointList, i / 100));
}
drawPath(path);
// Red start and end points
[startPoint, endPoint].forEach((p) => {
drawCircle(p.x, p.y, "red");
});
// Blue control point
pointList.slice(1, -1).forEach((p) => {
drawCircle(p.x, p.y, "blue");
});
Final effect

边栏推荐
- Directx11 advanced tutorial tiled based deffered shading
- MySQL master-slave, 6 minutes to master
- The unity3d script searches for colliders with overlaps within the specified radius
- sqlite交叉编译动态库
- Types, functions and applications of intelligent sensors
- User login (medium)
- nus_data_handler源码解读结构体等数据类型
- E-book analysis
- 哈工大信息内容安全实验
- Project progress on February 28, 2022
猜你喜欢

三年磨一剑:蚂蚁金服的研发效能洞察实践

Poisson disk sampling for procedural placement

(UE4 4.27) customize globalshader

Understanding of distributed transactions

dlib 人脸检测

MySQL master-slave, 6 minutes to master

Book classification based on Naive Bayes

Why is the union index the leftmost matching principle?

Logistic regression model
![[untitled]](/img/75/599c5b13dd483fad50f73ddb431989.jpg)
[untitled]
随机推荐
Research Report on truffle fungus industry - market status analysis and development prospect forecast
Project management and overall planning
夜神模拟器adb查看log
Leetcode buckle -10 Regular expression matching analysis [recursion and dynamic programming]
Solution to the problem of the 80th fortnight competition of leetcode
Houdini & UE4 programmed generation of mountains and multi vegetation scattering points
Poisson disk sampling for procedural placement
IDEA常用配置
Recursive implementation of exponential, permutation and combination enumerations
China Aquatic Fitness equipment market trend report, technical innovation and market forecast
The application could not be installed: INSTALL_ FAILED_ TEST_ ONLY
Unity implements smooth interpolation
Why is the union index the leftmost matching principle?
Why doesn't the database use binary tree, red black tree, B tree and hash table? Instead, a b+ tree is used
Leetcode-1706. Where does the club fall
单通道图片的读入
Leetcode-139. Word splitting
Guns框架多数据源配置,不修改配置文件
Leetcode-553. Optimal division
EBook upload