Giter Club home page Giter Club logo

bezier's Introduction

bezier

A cubic Bezier class for Unity. This code is a conversion of the Tacent C++ code for the tBezierCurve and tBezierPath classes which can be browsed here:

Browse Tacent Source

The Bezier.cs file contains two classes. A simple CubicBezierCurve class that implements the standard Bernstein polynomials, and a CubicBezierPath class that essentially joins the curves together to create a longer composite path. Both classes implement functions to find the tangent for any t value.

CubicBezierCurve

In most cases you won't need to use this class directly, but you can if you like. Give it your 4 CVs, and it will let you get a point on the curve for a particular t value, get the tangent for a particular t value, and find the t value of the closest point on the curve to a point you specify.

CubicBezierPath

This one is much more powerful. It allows you to only construct it with the knots you want interpolated. It will compute the necessary extra CVs internally so that things remain smooth between the curve sections. You must give it 2 or more knots (I use the term knot to mean interpolated CV... as in, the path will go right through the point). For 2 knots you just get a straight-line segment. For 3 it'll be curvy.

CubicBezierPath supports open and closed (looping) paths. You can work with t values E [0,1] for the whole path, or t E [0, numSegments]. When you see the word 'Norm' it means t E [0,1]. For open paths t will be clamped, for closed paths it will just loop around if you pass it a large t value.

The class also lets you compute what t value will result in a position on the path closest to an arbitrary position you specify. See ComputeClosestParam(). When you see the word 'Compute', worry about efficiency. ComputeClosestParam is a recursive call that terminates when a user-specified tolerance is met.

bezier's People

Contributors

bluescan avatar

Watchers

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