提问人:Lerian Acosenossa 提问时间:3/19/2022 更新时间:3/22/2022 访问量:434
我想使用节点在搅拌机中制作一个 Cornu 螺旋
I want to make a Cornu spiral in blender using nodes
问:
我不知道从哪里开始。如果您不知道什么是角质螺旋:https://mathworld.wolfram.com/CornuSpiral.html
我所看到的都是我不熟悉的内在数学,据我所知,这些术语并没有直接翻译成搅拌机界面,我也不知道很深入。
我成功地设置了手柄绝对位置,给定了贝塞尔上的点位置,但我不知道如何将它们联系起来以实现我的目标。你能借给我任何公式来计算相对于点位置的正确 brezier 手柄位置以及点的位置吗?我大约一个星期了,我还在开始。
答:
0赞
MBo
3/22/2022
#1
我们可以使用小线段绘制 Cornu 螺旋。Delphi 中的示例:
cx := 10;
cy := 700;
scale := 700;
step := 0.02;
Canvas.MoveTo(cx, cy);
for i := 1 to 250 do begin
t := i * step;
fresnelintegral(t, c, s);
x := cx + Round(scale * s);
y := cy - Round(scale * c);
Canvas.LineTo(x, y);
end;
这里是曲线参数(与弧长成正比),我们使用菲涅耳积分和缩放计算当前点的坐标(以制作可视大小的图片)。此代码生成黑色曲线:t
如果我们想通过贝塞尔曲线近似 Cornu 螺旋,我们必须获得具有相同方程的端点,然后获得前一个点和当前点的方向角(链接中的斜率方程 (2))以定义中间控制点。但是我们还需要计算到控制点的距离 - 似乎是相当困难的问题。我编写了快速代码来演示一种方法。
山茱萸螺旋的曲率沿曲线上升。为了更好地接近螺旋,我不得不减少步长,因此贝塞尔段变得越来越小。小圆圈是贝塞尔端点,它们变得更近。
我试图根据价值来做,但没有找到好的方程式。下面的代码生成蓝色曲线。在选定的范围内,它非常接近黑色的(我们可以对齐它们)。coeff
t
t
Canvas.Pen.Color := clBlue;
cx := 500;
step := 0.2;
prevt := 0;
t := 0;
Canvas.MoveTo(cx, cy);
Pts[0] := Point(cx, cy);
for i := 1 to 70 do begin
t := t + step;
fresnelintegral(prevt, c, s);
prevx := cx + Round(scale * s);
prevy := cy - Round(scale * c);
prevfi := 0.5 * Pi * prevt * prevt;
fresnelintegral(t, c, s);
x := cx + Round(scale * s);
y := cy - Round(scale * c);
pts[i*3] := Point(x, y);
fi := 0.5 * Pi * t * t;
Canvas.Ellipse(x-2, y-2, x+3, y+3);
coeff := 1/3;
dist := Hypot(x - prevx, y - prevy) * coeff;
px := prevx + Round(dist * Sin(prevfi));
py := prevy - Round(dist * Cos(prevfi));
pts[i * 3 - 2] := Point(px, py);
px := x - Round(dist * Sin(fi));
py := y + Round(dist * Cos(fi));
pts[i * 3 - 1] := Point(px, py);
step := step * 0.96;
prevt := t;
end;
Canvas.PolyBezier(pts);
评论
0赞
Lerian Acosenossa
3/25/2022
您好,我多次阅读您的答案,这次更仔细,我已经通过 naif 步骤得出了自己的解决方案。这并不是说我在数学上是零的,只是积分和转弯通常与我的兴趣相去甚远,事实上,当涉及任何比较转弯时,即使是最微不足道的事情,我的大脑也会挣扎。我解释这一点只是为了说明我理解了你的 appraoch 的本质,但这与我的相似。
0赞
Lerian Acosenossa
3/25/2022
我首先以这里广播的 python 脚本为例:medium.com/@alejandro.blumentals/......
0赞
Lerian Acosenossa
3/25/2022
It's fairly simply and well explained. as you see it calculates the fresnel integrals from integrating cos(thetas) and sin(thethas) to x and y respectively. I don't have a clear idea about what it comes out from the ode integrate function because I havent given it enough time, all that I know is that it works! and so I got more intrested about the fresnel equation and I think that I figured out that tyhere's a simple expression behand al that elegancy meaning e^(ipix**2)/2 = pix²+pix²*i, more or less like saying integrate this function for x and y
0赞
Lerian Acosenossa
3/25/2022
I'm better at arithmetics and abstract algebra that at calculus, so I developed the fresnel integration further at the sightt that if he is using polar coordinates to describe a circle transversing tangent along a path and diminishing it's radius over the normal then I could describe a sphere doing the same using spherical coordinates instead of polar coordinates. Hence now I also have an angle of tortion phi so x turns to be tcos(phi)*sin(theta), y turns to be tsin(phi)*sin(theta, and z=r*cos(theta), integrate this and you may have a fresnel equation in three dimensions.
0赞
Lerian Acosenossa
3/25/2022
Anyway I'm still on the details over this and I don't know how accurate could be my reasoning. I came over the blender part by using it's python api, don't ask much to that program. The good thing is that I tested it and it works and now I have euler spirals that not only bends over the xy plain but also twists over the xz plain by an equivalent function. However the result is not as intresting as you may think, just an increasing curvature that twists some degrees at every turn resuling in a small ball pf points at the end instead of the characteristic circle.
评论
t