简体   繁体   English

我想使用节点在搅拌机中制作 Cornu 螺旋

[英]I want to make a Cornu spiral in blender using nodes

And I have no clue where to start.我不知道从哪里开始。 In case you don't know what a cornu spiral is: https://mathworld.wolfram.com/CornuSpiral.html如果您不知道角螺旋是什么: https://mathworld.wolfram.com/CornuSpiral.html

All that I see are intrincated maths whose terms I'm not familiar with and doesn't translate as far as I know directly to blender interface which also I don't know in depth.我所看到的都是复杂的数学,我不熟悉这些术语,并且据我所知并没有直接翻译成我也不深入了解的搅拌机界面。

I had some success setting the handle absolute positions given point position on the bezier but I have no idea how to relate them in order to achieve my goal.我在贝塞尔曲线上给定点 position 设置手柄绝对位置取得了一些成功,但我不知道如何关联它们以实现我的目标。 Can you lend me any formula to calculate the correct brezier handle positions relative to point position and also the positions of the points?你能借给我任何公式来计算相对于点 position 的正确布雷齐尔手柄位置以及点的位置吗? I'm about a week on this and I'm still starting.我已经做了大约一个星期,但我还在开始。

We can draw Cornu spiral using small line segments.我们可以使用小线段绘制 Cornu spiral。 Example in Delphi: 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;

here t is curve parameter (proportional to arc length), and we calculate coordinate of current point using Fresnel integrals and scaling (to make a picture of viewable size).这里t是曲线参数(与弧长成正比),我们使用菲涅尔积分和缩放计算当前点的坐标(以制作可视尺寸的图片)。 This code generates black curve:此代码生成黑色曲线:

在此处输入图像描述

If we want to approximate Cornu spiral by Bezier curves, we have to get endpoints with the same equations, then get direction angles in previous point and in the current point (slope equation (2) in your link) to define intermediate control points.如果我们想通过贝塞尔曲线近似 Cornu spiral,我们必须用相同的方程得到端点,然后得到前一点和当前点的方向角(链接中的斜率方程(2))来定义中间控制点。 But we also need to calculate distances to control points - seems rather hard problem.但我们还需要计算到控制点的距离——这似乎是一个相当困难的问题。 I made quick code to demonstrate an approach.我制作了快速代码来演示一种方法。

Curvature of Cornu spiral rises along the curve.角螺旋的曲率沿曲线上升。 To approximate spiral better, I had to diminish steps, so Bezier segments become smaller and smaller.为了更好地近似螺旋,我不得不减少步数,因此贝塞尔曲线段变得越来越小。 Small circles are Bezier endpoints, they become closer.小圆圈是贝塞尔曲线的端点,它们变得更近了。

I tried to make coeff depending on t value, but have not found good equation.我试图根据t值计算coeff ,但没有找到合适的方程式。 The code below generates blue curve.下面的代码生成蓝色曲线。 It is very close to black one (we can align them) in chosen t range.在选定的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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM