This module defines a type curve_t that represents a parametric curve in nD space.
The curve is defined by a sequence of points and a method for interpolation. The interpolation method is specified by the user when creating the curve. The default method is ‘pchip’ (piecewise cubic Hermite interpolating polynomial).
Create a new curve from a sequence of points.
Create a new curve from a sequence of points.
The curve is given by a sequence of points in nD space, interpolation method, and extrapolation setup. Supported interpolation methods are
linear
for piecewise linear interpolation (i.e. polyline)pchip
for piecewise cubic Hermite interpolating polynomial (default)Supported extrapolation methods are
extrap
for linear extrapolation (default)NaN
for NaN extrapolationType | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rkind), | intent(in) | :: | points(:,:) |
The points that define the curve |
||
character(len=*), | intent(in), | optional | :: | method |
The interpolation method, |
|
character(len=*), | intent(in), | optional | :: | extrap |
A parametric curve in nD space.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=rkind), | public | :: | begin |
The beginning of parameter span |
|||
real(kind=rkind), | public | :: | end |
The end of parameter span |
|||
character(len=:), | public, | allocatable | :: | extrap |
The extrapolation method |
||
real(kind=rkind), | public, | allocatable | :: | knots(:) |
The parameter values for the points |
||
character(len=:), | public, | allocatable | :: | method |
The interpolation method |
||
real(kind=rkind), | public, | allocatable | :: | points(:,:) |
The points that define the curve |
Create a new curve from a sequence of points.
private function new_curve (points, method, extrap) | Create a new curve from a sequence of points. The curve is given by a sequence of points in nD space, interpolation method, and extrapolation setup. Supported interpolation methods are
Supported extrapolation methods are
|
generic, public :: at => at_1, at_n | Evaluate the curve at a single point or at multiple points |
procedure, public :: move_by | Move the curve by a given displacement |
procedure, public :: tangent_at | Compute the tangent vector at a given point |
Compute the intersection of two curves.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(curve_t), | intent(in) | :: | c1 |
The first curve |
||
type(curve_t), | intent(in) | :: | c2 |
The second curve |
||
real(kind=rkind), | intent(in), | optional | :: | x0(:) |
The initial guess for the intersection |
The intersection point
Project a point onto a curve.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rkind), | intent(inout) | :: | x(:) |
The point to be projected |
||
type(curve_t), | intent(in) | :: | c |
The curve |
||
real(kind=rkind), | intent(out), | optional | :: | t |
The parameter value of the projection |
|
real(kind=rkind), | intent(in), | optional | :: | t0 |
The initial guess for the parameter of the projection |