问题描述
查看,我终于明白为什么编程老师总是告诉我数学如此重要。不幸的是,我没有听。
任何人都可以提供一个更具体的 - 例如计算机语言 - y公式,用于将二次曲线转换为立方曲线?理解可能存在一些舍入误差,这很好。
给定一个由变量表示的四条曲线:
StartX,StartY
ControlX,ControlY
EndX,EndY
并且希望StartX,StartY和EndX,EndY保持不变,但现在Control1X,Control1Y和Control2X,Control2Y是一个三次曲线。
它是...
pre $ Control1X = StartX +(.66 *(ControlX - StartX))
Control2X = EndX +(.66 *(ControlX - EndX))
使用相同的基本函数来计算Control1Y和Control2Y?
你的代码是正确的,除了你应该使用 2.0 / 3.0
而不是 0.66
。
Looking at Convert a quadratic bezier to a cubic?, I can finally understand why programming teachers always told me that math was so important. Sadly, I didn't listen.
Can anyone provide a more concrete - e.g., computer-language-y - formula for converting a quadratic curve to a cubic? Understanding that there's some rounding errors possible, which is fine.
Given a quad curve represented by variables:
StartX, StartY
ControlX, ControlY
EndX, EndY
And desiring StartX, StartY and EndX, EndY to remain the same, but to now have Control1X, Control1Y and Control2X, Control2Y of a cubic curve.
Is it...
Control1X = StartX + (.66 * (ControlX - StartX))
Control2X = EndX + (.66 * (ControlX - EndX))
With the same essential functions used to calculate Control1Y and Control2Y?
Your code is right except that you should use 2.0/3.0
instead of 0.66
.
这篇关于将二次曲线转换为三次曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!