41_slopes: Slopes and Tangents

Description Usage Arguments Details Value References See Also Examples

Description

Functions for computing (possibly) suitable slopes and tangents.

Usage

1
2
3
4
5
6
7
chs.slopes (cx, cy, ..., constraints = chs.constraints (, ...),
    init.method)
chs.tangents (cx, cy, ..., constraints = chs.constraints (, ...),
    init.method)

apply.chs.constraints (cx, cy, cb, ...,
    constraints = chs.constraints (, ...) )

Arguments

cx

Vector of unique ascending control point x values.
(Preferably, equally-spaced).

cy

Vector of control point y values.

cb

Vector of control slopes.

constraints

A CHS.Constraints object.
Can be NULL or NA, for no constraints.

Refer to the help file for chs.constraints for more information.

init.method

Initialization method for slopes.
Possible values are "SL" and "SQ".

...

Alternative (possibly simpler) way of specifying constraints.
Ignored, if a chs.constraints object supplied.

This (specifying constraints in dots) should not be used inside packages, because the use of dots may change.

Details

These functions work by computing a initial vector of slopes, and then trying to transform them to satisfy constraints.

Currently, there are two methods that may be used to initialize the slopes:
SL, Simple secant-based method with near-linear tails.
SQ, Modified secant based-method with quadratic tails.

If the initialization method isn't specified by the user, it defaults to "SQ", if the control points are equally-spaced (or near-equally-spaced), and it defaults to "SL", otherwise.

If there's only one spline segment:
(Regardless of of what initialization method is used).
The initial slopes are set equal to the secant's slope.

Where the secant refers to the secant line between the surrounding control points.

And if there's two more spline segments:
The second slope is computed from the (double-interval) secant line between the first and third control points, the third slope is computed from the (double-interval) secant line between the second and fourth control points, and so on, up to the second to last slope, which is computed from the (double-interval) secant line between the third-to-last and last control points.

For the SL method, the the outermost slopes are set equal to the adjacent secants' slopes, resulting in near-linear tails. For the SQ method, the first slope is computed by fitting a quadratic polynomial to the first three control points and evaluating the derivative at the first point, and the last slope is computed by fitting a quadratic polynomial to the last three control points and evaluating the derivative at the last point.

The SQ method should only be used for equally-spaced control points.

Note that while secants may sound linear, computing slopes from secants gives similar results to computing all the slopes via quadratic polynomials.
(And precedence is given to the SQ method, because the level of resulting curvature, is relatively consistent over the entire spline, including the tails).

The apply.chs.constraints function tries to transform a vector of slopes to satisfy a set of constraints.

If a transformation isn't possible, an error is generated.
(This applies to all three functions).

Note that it's possible to use chs.slopes to compute slopes, and then modify them as desired.

Value

chs.slopes returns a (possibly) suitable vector of slopes.

chs.tangents returns a (possibly) suitable two-column matrix, giving the intercepts and slopes.

appl.chs.constraints returns a transformed vector of slopes.

References

Please refer to the help page for chs for background information and references.

See Also

chs, chs.constraints

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#control points
cx <- 1:4
cy <- c (-4, -1, 1, 4)

#control slopes
chs.slopes (cx, cy)

#control tangents
#(intercepts and slopes)
chs.tangents (cx, cy)

kubik documentation built on April 15, 2021, 9:09 a.m.

Related to 41_slopes in kubik...