MoonTools.Curve/README.md

32 lines
1.0 KiB
Markdown
Raw Normal View History

2020-02-21 01:37:52 +00:00
# MoonTools.Curve
2019-10-29 21:57:07 +00:00
2020-02-21 01:37:52 +00:00
[![NuGet Badge](https://buildstats.info/nuget/MoonTools.Curve)](https://www.nuget.org/packages/MoonTools.Curve/)
2020-02-21 01:42:10 +00:00
[![Build Status](https://drone.moonside.games/api/badges/MoonsideGames/MoonTools.Curve/status.svg)](https://drone.moonside.games/MoonsideGames/MoonTools.Curve)
2019-10-29 21:58:58 +00:00
2020-02-21 01:42:10 +00:00
Efficiently implements quadratic and cubic Bezier curves in 2D and 3D using immutable structs.
2019-10-29 21:57:07 +00:00
## Example
```cs
var myCurve = new CubicBezierCurve3D(
new Vector3(-4, -4, -3),
new Vector3(-2, 4, 0),
new Vector3(2, -4, 3),
new Vector3(4, 4, 0)
);
myCurve.Point(0.5f); // => Vector3(0, 0, 0.75f)
2020-02-21 01:42:10 +00:00
myCurve.Point(3, 2, 4); // => Vector3(0, 0, 0.75f)
2019-10-29 21:57:07 +00:00
myCurve.Velocity(0.5f); // => Vector3(9, 0, 4.5f)
2020-02-21 01:42:10 +00:00
myCurve.Velocity(3, 2, 4); // => Vector3(9, 0, 4.5f)
// curve values can be calculated statically as well
CubicBezierCurve3D.Point(
new Vector3(-4, -4, -3),
new Vector3(-2, 4, 0),
new Vector3(2, -4, 3),
new Vector3(4, 4, 0),
0.5f
); // => Vector3(0, 0, 0.75f)
2020-02-21 01:37:52 +00:00
```