align_curves {elasdics}R Documentation

Align two curves measured at discrete points

Description

Finds the optimal reparametrisation of the second curve (stored in data_curve2) to the first one (stored in data_curve1) with respect to the elastic distance. Constructor function for class aligned_curves.

Usage

align_curves(data_curve1, data_curve2, closed = FALSE, eps = 0.01)

Arguments

data_curve1

data.frame with observed points in each row. Each variable is one coordinate direction. If there is a variable t, it is treated as the time parametrisation, not as an additional coordinate.

data_curve2

same as data_curve1

closed

TRUE if the curves should be treated as closed.

eps

convergence tolerance

Value

an object of class aligned_curves, which is a list with entries

data_curve1

data_curve1 with parametrisation variable t

data_curve2_aligned

data_curve2 with initial parametrisation variable t and optimal parametrisation t_optim

elastic_dist

elasic distance between curve1 and curve2

closed

TRUE if the curves should have been treated as closed.

Examples

#open curves
data_curve1 <- data.frame(x1 = c(1, 0.5, -1, -1), x2 = c(1, -0.5, -1, 1))
data_curve2 <- data.frame(x1 = c(0.1,0.7)*sin(1:6), x2 = cos(1:6))
aligned_curves <- align_curves(data_curve1, data_curve2)
plot(aligned_curves)

#different parametrisation of the first curve
data_curve1$t <- 0:3/3
align_curves(data_curve1, data_curve2)

#closed curves
data_curve1 <- data.frame(x1 = sin(0:12/5), x2 = cos(0:12/5))
data_curve2 <- data.frame(x1 = c(1, 0.5, -1, -1), x2 = c(1, -0.5, -1, 1))
aligned_curves_closed <- align_curves(data_curve1, data_curve2, closed = TRUE)
plot(aligned_curves_closed, asp = 1)

[Package elasdics version 0.2.0 Index]