BeeneticToolkit.Numerics
0.12.1
dotnet add package BeeneticToolkit.Numerics --version 0.12.1
NuGet\Install-Package BeeneticToolkit.Numerics -Version 0.12.1
<PackageReference Include="BeeneticToolkit.Numerics" Version="0.12.1" />
<PackageVersion Include="BeeneticToolkit.Numerics" Version="0.12.1" />
<PackageReference Include="BeeneticToolkit.Numerics" />
paket add BeeneticToolkit.Numerics --version 0.12.1
#r "nuget: BeeneticToolkit.Numerics, 0.12.1"
#:package BeeneticToolkit.Numerics@0.12.1
#addin nuget:?package=BeeneticToolkit.Numerics&version=0.12.1
#tool nuget:?package=BeeneticToolkit.Numerics&version=0.12.1
BeeneticToolkit.Numerics
Small, allocation-free numeric helpers — a Mathf-style companion for plain .NET (and Unity).
Targets netstandard2.1. Most methods come in float/double (and decimal where it makes sense).
Install
dotnet add package BeeneticToolkit.Numerics
Highlights
Everything lives on one discoverable type, MathKit — like Unity's Mathf or .NET's Math, but for
this toolkit. Type MathKit. and browse.
using BeeneticToolkit.Numerics;
// Interpolation
float y = MathKit.Lerp(0, 100, t); // clamped to [0,1]
float ye = MathKit.SmoothStep(0, 100, t); // Hermite easing
float yx = MathKit.LerpUnclamped(0, 100, 1.5f); // extrapolates
// Remap a value from one range to another (e.g. raw reading -> percentage)
float pct = MathKit.Remap(reading, 0, 1023, 0, 100);
// Splines: cubic Bezier (Cerp) and Catmull-Rom (passes through its control points)
float b = MathKit.Cerp(p0, p1, p2, p3, t); // 4-point cubic Bezier
float s = MathKit.CatmullRom(p0, p1, p2, p3, t); // smooth path through p1..p2
// Normalize / clamp
float hp01 = MathKit.Normalize(hp, 0, maxHp); // -> [0, 1]
float c = MathKit.Clamp01(value);
// Angles
float radians = MathKit.ToRadians(90f);
float wrapped = MathKit.WrapDegrees(370f); // -> 10
float turn = MathKit.DeltaAngleDegrees(350f, 10f); // -> 20 (shortest signed turn across the seam)
float facing = MathKit.LerpAngleDegrees(350f, 10f, t); // interpolates the short way
float step = MathKit.MoveTowardsAngleDegrees(350f, 10f, 5f);// turn ≤5° toward target
// Move a value toward a target at constant speed (no overshoot)
float meter = MathKit.MoveTowards(current, target, maxDelta);
// Smoothing & cycling
float ss = MathKit.SmootherStep(0, 1, t); // Perlin's gentler ease
float gate = MathKit.Step(0.5f, x); // hard threshold: 0 or 1
float ping = MathKit.PingPong(time, 3f); // bounces 0..3..0
float cam = MathKit.SmoothDamp(current, target, ref velocity, smoothTime, deltaTime); // spring follow
// Easing curves (also surfaced as MathKit.Ease)
float eased = MathKit.Ease(EasingType.OutBack, a, b, t);
// Magnitude-aware float comparison (absolute comparison fails for large values)
bool equal = MathKit.IsApproximatelyRelative(1e9, 1e9 + 50, 1e-6); // true
Tip: these methods are overloaded for
float,double, anddecimal, so a call whose arguments are all untyped integer literals is ambiguous (e.g.Remap(30, 0, 100, 0, 1)won't compile). Use typed literals —Remap(30f, 0f, 100f, 0f, 1f),30.0, or30m— or pass at least one typed argument so the compiler can pick an overload.
Easing
The standard (Penner) easing curves for tweening and animation — Sine, Quad, Cubic, Quart, Quint, Expo,
Circ, Back, Elastic, and Bounce, each in In / Out / InOut. Every curve maps t in [0, 1] to eased
progress; combine with a lerp, or pick a curve at runtime with the Ease dispatcher.
using BeeneticToolkit.Numerics;
float p = EasingUtils.OutCubic(t); // eased progress
float x = EasingUtils.Ease(EasingType.OutBack, a, b, t); // tween a→b (OutBack overshoots past b)
// Data-driven: store the curve choice and resolve it later.
EasingType curve = config.Curve;
float eased = EasingUtils.Ease(curve, t);
Provided for float and double. Back and Elastic intentionally overshoot outside [0, 1]. The named
curves live on EasingUtils; MathKit.Ease(EasingType, …) is the discoverable shortcut.
MathKit also includes RoundToNearest and floored Wrap. Integral mapping is a separate set of
extension methods (IntegralMappingExtensions), since those read fluently on the value itself.
License
Licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on BeeneticToolkit.Numerics:
| Package | Downloads |
|---|---|
|
BeeneticToolkit
Meta-package that references the full BeeneticToolkit family: BeeneticToolkit.Random, BeeneticToolkit.Collections, BeeneticToolkit.Numerics, BeeneticToolkit.Logging, BeeneticToolkit.Spatial, and BeeneticToolkit.BigMath. Install this to get everything, or install the individual packages to take only what you need. |
GitHub repositories
This package is not used by any popular GitHub repositories.
See the changelog: https://github.com/Beenetic-Studios/BeeneticToolkit/blob/master/CHANGELOG.md