Skip to content

Clarify smootharclengthinterpolation #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ corresponding to `(u,t)` pairs.
- `CubicHermiteSpline(du, u, t)` - A third order Hermite interpolation, which matches the values and first (`du`) order derivatives in the data points exactly.
- `PCHIPInterpolation(u, t)` - a type of `CubicHermiteSpline` where the derivative values `du` are derived from the input data in such a way that the interpolation never overshoots the data.
- `QuinticHermiteSpline(ddu, du, u, t)` - A fifth order Hermite interpolation, which matches the values and first (`du`) and second (`ddu`) order derivatives in the data points exactly.
- `SmoothArcLengthInterpolation(u)` create a continuously differentiable interpolation by arc length through the data, by approximating a non-arc length interpolation with line segments and circle segments. See the docs for more details.

## Extension Methods

Expand Down
2 changes: 1 addition & 1 deletion docs/src/arclength_interpolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Arc length interpolation is interpolation between points using a curve that is p

## Usage

`DataInteprolations.jl` offers an arc length interpolation method that approximates an existing non arc length interpolation by circle and line segments. This can be done by providing an interpolation object (the shape interpolation):
`DataInteprolations.jl` offers an arc length interpolation method that approximates an existing non arc length interpolation piecewise by circle and line segments. This can be done by providing an interpolation object (the shape interpolation):

```@example tutorial
using DataInterpolations
Expand Down
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ corresponding to `(u,t)` pairs.
- `CubicHermiteSpline(du, u, t)` - A third order Hermite interpolation, which matches the values and first (`du`) order derivatives in the data points exactly.
- `PCHIPInterpolation(u, t)` - a type of `CubicHermiteSpline` where the derivative values `du` are derived from the input data in such a way that the interpolation never overshoots the data.
- `QuinticHermiteSpline(ddu, du, u, t)` - a fifth order Hermite interpolation, which matches the values and first (`du`) and second (`ddu`) order derivatives in the data points exactly.
- `SmoothArcLengthInterpolation(u)` create a continuously differentiable interpolation by arc length through the data, by approximating a non arc length interpolation with line segments and circle segments. See [here](#smooth-arc-length-interpolation) for more details.

## Extension Methods

Expand Down
8 changes: 7 additions & 1 deletion src/interpolation_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,8 @@ If you want to do this, construct the shape interpolation yourself and use the
for the `SmoothArcLengthInterpolation` to be C¹ smooth, the `interpolation_type` must be C¹ smooth as well.
- `m`: The number of points at which the shape interpolation is evaluated in each interval between time points.
The `SmoothArcLengthInterpolation` converges to the shape interpolation (in shape) as m → ∞.
- `in_place`: Whether the value of the interpolation should be calculated in pre-allocated memory. This saves
allocations, but is not compatible with e.g. ForwardDiff. Defaults to `false`.
- `extrapolation`: The extrapolation type applied left and right of the data. Possible options
are `ExtrapolationType.None` (default), `ExtrapolationType.Constant`, `ExtrapolationType.Linear`
`ExtrapolationType.Extension`, `ExtrapolationType.Periodic` and `ExtrapolationType.Reflective`.
Expand Down Expand Up @@ -1443,6 +1445,8 @@ Approximate the `shape_itp` with a C¹ unit speed interpolation using line segme

- `m`: The number of points at which the shape interpolation is evaluated in each interval between time points.
The `SmoothArcLengthInterpolation` converges to the shape interpolation (in shape) as m → ∞.
- `in_place`: Whether the value of the interpolation should be calculated in pre-allocated memory. This saves
allocations, but is not compatible with e.g. ForwardDiff. Defaults to `false`.
- `extrapolation`: The extrapolation type applied left and right of the data. Possible options
are `ExtrapolationType.None` (default), `ExtrapolationType.Constant`, `ExtrapolationType.Linear`
`ExtrapolationType.Extension`, `ExtrapolationType.Periodic` and `ExtrapolationType.Reflective`.
Expand Down Expand Up @@ -1520,6 +1524,8 @@ segments and circle segments.
- `shape_itp`: The interpolation that is being approximated, if one exists. Note that this
interpolation is not being used; it is just passed along to keep track of where the shape
of the `SmoothArcLengthInterpolation` originated.
- `in_place`: Whether the value of the interpolation should be calculated in pre-allocated memory. This saves
allocations, but is not compatible with e.g. ForwardDiff. Defaults to `false`.
- `extrapolation`: The extrapolation type applied left and right of the data. Possible options
are `ExtrapolationType.None` (default), `ExtrapolationType.Constant`, `ExtrapolationType.Linear`
`ExtrapolationType.Extension`, `ExtrapolationType.Periodic` and `ExtrapolationType.Reflective`.
Expand Down Expand Up @@ -1618,7 +1624,7 @@ function SmoothArcLengthInterpolation(
extrapolation_right::ExtrapolationType.T = ExtrapolationType.None,
cache_parameters::Bool = false,
assume_linear_t = 1e-2,
in_place::Bool = true)
in_place::Bool = false)
N = size(u, 1)
n_circle_arcs = size(u, 2) - 1

Expand Down
4 changes: 2 additions & 2 deletions test/derivative_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ end
u = [0.3 -1.5 3.1; -0.2 0.2 -1.5; 10.4 -37.2 -5.8]
test_derivatives(
SmoothArcLengthInterpolation, args = [u], kwargs = Pair[
:m => 5, :in_place => false],
:m => 5],
name = "Smooth Arc Length Interpolation")
A = SmoothArcLengthInterpolation(u'; m = 25, in_place = false)
A = SmoothArcLengthInterpolation(u'; m = 25)
@test all(t -> norm(derivative(A, t)) ≈ 1, range(0, A.t[end]; length = 100))
@test all(
t_ -> derivative(A, prevfloat(t_)) ≈ derivative(A, nextfloat(t_)), A.t[2:(end - 1)])
Expand Down
Loading