Skip to content

Commit afa2f79

Browse files
Write release notes for the curve derivative work (#2064)
1 parent dc031c5 commit afa2f79

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed
Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
1-
<!-- Derivative access patterns for curves -->
2-
<!-- https://github.com/bevyengine/bevy/pull/16503 -->
1+
`bevy_math` has collected a sizable collection of curves and methods for working with curves, which are useful for everything from animations to color gradients to gameplay logic.
32

4-
<!-- TODO -->
3+
One of the most natural and important things you might want to do with a curve is to inspect its **derivative**:
4+
the rate at which it's changing.
5+
You might even be after its **second derivative**: the rate at which the rate of change is changing.
6+
7+
Accessing this information should be easy and error-resistant,
8+
but we also won't accept any complication or performance penalty in the more common derivative-less use cases.
9+
10+
To satisfy these requirements, our resident mathematicians have built a careful solution involving multiple traits and wrapper types.
11+
For a full description of the mechanisms and considerations, dive down the rabbit hole into the linked PR description!
12+
Despite (or because of?) all of the mathematical type wizardry, the actual usage is straightforward:
13+
14+
```rust
15+
let points = [
16+
vec2(-1.0, -20.0),
17+
vec2(3.0, 2.0),
18+
vec2(5.0, 3.0),
19+
vec2(9.0, 8.0),
20+
];
21+
22+
// A cubic spline curve that goes through `points`.
23+
let curve = CubicCardinalSpline::new(0.3, points).to_curve().unwrap();
24+
25+
// Calling `with_derivative` causes derivative output to be included in the output of the curve API.
26+
let curve_with_derivative = curve.with_derivative();
27+
28+
// A `Curve<f32>` that outputs the speed of the original.
29+
let speed_curve = curve_with_derivative.map(|x| x.derivative.norm());
30+
```
31+
32+
We've implemented the required traits for most of our native curve types: splines, lines, and all manner of compound curves.
33+
Curves which accept arbitrary functions are not covered (build your own specialized curve types),
34+
as Rust does not have a first-class notion of a differentiable function!

release-content/0.16/release-notes/_release-notes.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ file_name = "15074_bevy_reflect_Function_Overloading_Generic__Variadic_Functi.md
187187
# Math
188188

189189
[[release_notes]]
190-
title = "Derivative access patterns for curves"
190+
title = "Curve derivatives"
191191
authors = ["@mweatherley"]
192192
contributors = ["@alice-i-cecile"]
193193
prs = [16503]

0 commit comments

Comments
 (0)