简体   繁体   English

贝塞尔曲线是笔直的

[英]Bezier curve is straight

I would like to draw a Bezier curve, I use 4 control points, but my line is still straight. 我想绘制一个贝塞尔曲线,我使用4个控制点,但我的线仍然是直线。

I have a class which handle points. 我有一堂课处理点数。 I use pyglet to draw the output. 我使用pyglet绘制输出。

def Bezier(P0,P1,P2,P3, t):
    t2 = t*t
    t3 = t2 * t
    mt = 1-t
    mt2 = mt * mt
    mt3 = mt2 * mt

    P0.mulP(mt)

    P1.mulP(3)
    P1.mulP(mt2)
    P1.mulP(t)

    P2.mulP(mt)
    P2.mulP(3)
    P2.mulP(t2)

    P3.mulP(t3)

    P0.addP(P1)
    P0.addP(P2)
    P0.addP(P3)

    return P0

Edit: I'm still playing around with this issue. 编辑:我仍然在玩这个问题。 I have a function to calculate the coordinates of the Bezier curve, it shows the same thing... 我有一个函数来计算贝塞尔曲线的坐标,它显示出相同的内容...

def Bezier3deg(P0,P1,P2,t):
    ReP = points.point()

    t1 = (1 - t) * (1 - t)
    P0.mulP(t1)

    t2 = 2 * (1-t) * t
    P1.mulP(t2)

    t3 = t*t
    P2.mulP(t3)

    ReP.addP(P0)
    ReP.addP(P1)
    ReP.addP(P2)
    return ReP

Okay, I figure it out, that the problem was my python skill. 好的,我弄清楚了,问题出在我的python技能上。 The Bezier function always changed the original coordinates of the control points. 贝塞尔曲线功能始终会更改控制点的原始坐标。 After I fixed it, the curves are fine. 修好后,曲线就可以了。

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

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