如何将二次贝塞尔曲线代码转换为三次贝塞尔曲线?

编程入门 行业动态 更新时间:2024-10-09 09:11:18
本文介绍了如何将二次贝塞尔曲线代码转换为三次贝塞尔曲线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

因此,我最近开始进行图形编程,我想计算三次贝塞尔曲线.我在二次贝塞尔曲线上发现了这个绝佳的答案,但我不知道如何将其转换为三次贝塞尔曲线.

So I've recently picked up graphics programming and I wanted to compute a cubic Bézier curve. I found this excellent answer on quadratic Bézier but I don't know how to convert this to a cubic Bézier curve.

推荐答案

对于立方贝塞尔曲线,如您在共享链接中所看到的,绿线是从与二次曲线相同的过程中获得的.区别在于:您有两条绿线,然后需要根据它们计算一条蓝线.因此,for循环更改为:

For cubic Bézier curve, as you see in the link you shared, the green lines are obtained from the same procedure as the quadratic one. the differences are: you have two green lines, and then you need to calculate a blue line based on them. So the for loop changes as:

for( float i = 0 ; i < 1 ; i += 0.01 ) { // The Green Lines xa = getPt( x1 , x2 , i ); ya = getPt( y1 , y2 , i ); xb = getPt( x2 , x3 , i ); yb = getPt( y2 , y3 , i ); xc = getPt( x3 , x4 , i ); yc = getPt( y3 , y4 , i ); // The Blue Line xm = getPt( xa , xb , i ); ym = getPt( ya , yb , i ); xn = getPt( xb , xc , i ); yn = getPt( yb , yc , i ); // The Black Dot x = getPt( xm , xn , i ); y = getPt( ym , yn , i ); drawPixel( x , y , COLOR_RED ); }

更多推荐

如何将二次贝塞尔曲线代码转换为三次贝塞尔曲线?

本文发布于:2023-11-29 06:52:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645659.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:塞尔   曲线   转换为   如何将   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!