Skip to content

Javascript library to generate/calculate linear trajectories / paths

License

Notifications You must be signed in to change notification settings

tiagopadua/pather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pather

Javascript library to generate/calculate linear 2d trajectories / paths

How to use

First include the script

<script src="js/pather.min.js" type="text/javascript"></script>

If you are using the cubic path, you need the Sylvester js library to calculate the equations system using matrices.

<script src="js/sylvester.min.js" type="text/javascript"></script>

Then create a new object passing the start and end points [x, y] you want to make the trajectory. Types of trajectory currently supported are 'linear', 'cubic' and 'bezier'.

I recommend using 'bezier' over 'cubic' because the implementation is a lot faster to run - there is a test in samples/performance.html

var point1 = { x: 0, y: 0 };
var point2 = { x: 50, y: 100 };
var myPath = new Path(point1.x, point1.y, point2.x, point2.y, 'bezier');

Now you can get the 'y' value given any 'x' input, like this:

var y = myPath.getValue(13.5);

About

Javascript library to generate/calculate linear trajectories / paths

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published