Giter VIP home page Giter VIP logo

arglength-bezier's Introduction

等长贝塞尔曲线的C++实现

简略说明

在本次的内容中实现了等长的贝塞尔曲线和贝塞尔曲线的拟合方式,主要是以C++的形式进行。本项目是对Philip J. Schneider的C代码的C++实现版本,旨在能够使更多的人更方便的使用。原始的C代码在 http://graphicsgems.org/ ,同样可以在GitHub中找到:https://github.com/erich666/GraphicsGems\ 在本仓库中中实现了三个工具类和一个属性类:

属性类

属性类为

struct Point{
    double x;
    double y;
}

工具类

BezierCurve
Bezier_smoothL3

作用:
BezierCurve
用于拟合多阶贝塞尔曲线,输入是vector<Point>
使用函数有

double total_length()
此函数主要是获得多阶贝塞尔曲线的整体的长度

vector<Point> get_arg_points(int k, double iter_eps = 1e-5)
在贝塞尔曲线的起始点和终点之间插入k个点,让整体的贝塞尔曲线分为(k+1)段等长的曲线

vector<Point> get_points(int k)
根据t的等长度选择中间的k个点

Bezier_smoothL3
用于贝塞尔曲线的平滑。不需要输入,主要是为工具类。

使用的函数有:

vector<Point> fit_curve(vector<Point>& pts, const double& maxE)
作用为拟合pts所表达的曲线离散点,而且所产生的贝塞尔曲线距离每个点的最大距离不超过maxE,返回的内容为贝塞尔曲线的控制点,因为这个为三阶贝塞尔曲线的拟合,整体的拟合为4k

测试结果:

贝塞尔曲线等长结果

image

平滑结果

image

引用材料

Graphics Gems http://www.realtimerendering.com/resources/GraphicsGems/gems.html

arglength-bezier's People

Contributors

zkm98 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.