Drawing Hermite curves in OpenGL

后端 未结 3 818
半阙折子戏
半阙折子戏 2021-02-14 17:40

How can I draw Hermite curves using OpenGL, are there any built in functions? I saw some examples on-line that show how to use evaluators to draw Bezier curves but could not fin

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-14 18:32

    As Steven mentioned, you can convert a cubic Hermite curve to a cubic Bezier curve. It's actually quite simple.

    A typical cubic Hermite curve is defined with two points and two vectors:

    • P0 -- start point
    • V0 -- derivative at P0
    • P1 -- end point
    • V1 -- derivative at P1

    The conversion to a cubic Bezier is simply:

    B0 = P0
    B1 = P0 + V0/3
    B2 = P1 - V1/3
    B3 = P1
    

    You can then draw your Bezier curve using and evaluator or any other way you wish.

提交回复
热议问题