GithubHelp home page GithubHelp logo

pborsutzki / cubicsplineclosestpoint Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nrtaylor/cubicsplineclosestpoint

0.0 1.0 0.0 54 KB

Classes that demonstrate how to use Sturm's Theroem for root finding to solve the 5th degree polynomial required to project a 3D point to the closest point on a set of cubic Bézier splines.

Home Page: https://computingandrecording.wordpress.com/2017/03/20/closest-point-to-a-cubic-spline/

License: GNU General Public License v3.0

C++ 100.00%

cubicsplineclosestpoint's Introduction

CubicSplineClosestPoint

Classes that demonstrate how to use Sturm's Theroem for root finding to solve the 5th degree polynomial required to project a 3D point to the closest point on a set of cubic Bézier splines.

For a detailed description see this blog entry: https://computingandrecording.wordpress.com/2017/03/20/closest-point-to-a-cubic-spline/

alt text

Here is an example usage:

std::vector control_points;

control_points.push_back(WorldSpace(74.f, 100.f, 1.3f)); // Spline 1 control_points.push_back(WorldSpace(62.f, 88.f, 0.f)); control_points.push_back(WorldSpace(136.f, 48.f, 0.f)); control_points.push_back(WorldSpace(139.f, 69.f, 8.f)); // Spline 2

control_points.push_back(WorldSpace(171.f, 127.f, 0.f)); control_points.push_back(WorldSpace(276.f, 159.f, 5.f)); control_points.push_back(WorldSpace(195.f, 155.f, 9.94f)); // Spline 3

control_points.push_back(WorldSpace(185.f, 155.f, 23.f)); control_points.push_back(WorldSpace(185.f, 205.f, 0.333f)); control_points.push_back(WorldSpace(233.f, 205.f, 0.f));

ScopedPointer bezier_path = new CubicBezierPath(&control_points[0], (int)control_points.size());

ScopedPointer solver = new ClosestPointSolver();

for (a set of positions) { WorldSpace solution = bezier_path->ClosestPointToPath(position, solver); // Do something. }

cubicsplineclosestpoint's People

Contributors

nrtaylor avatar

Watchers

James Cloos 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.