aerosandbox.modeling.splines#

Submodules#

Package Contents#

Functions#

quadratic_bezier_patch_from_tangents(t, x_a, x_b, y_a, ...)

Computes sampled points in 2D space from a quadratic Bezier spline defined by endpoints and end-tangents.

linear_hermite_patch(x, x_a, x_b, f_a, f_b)

Computes the linear Hermite polynomial patch that passes through the given endpoints f_a and f_b.

cubic_hermite_patch(x, x_a, x_b, f_a, f_b, dfdx_a, dfdx_b)

Computes the cubic Hermite polynomial patch that passes through the given endpoints and endpoint derivatives.

cosine_hermite_patch(x, x_a, x_b, f_a, f_b, dfdx_a, dfdx_b)

Computes a Hermite patch (i.e., values + derivatives at endpoints) that uses a cosine function to blend between

Attributes#

x

aerosandbox.modeling.splines.quadratic_bezier_patch_from_tangents(t, x_a, x_b, y_a, y_b, dydx_a, dydx_b)[source]#

Computes sampled points in 2D space from a quadratic Bezier spline defined by endpoints and end-tangents.

Note: due to the inherent nature of a quadratic Bezier curve, curvature will be strictly one-sided - in other words, this will not make “S”-shaped curves. This means that you should be aware that bad values of dydx at either endpoint might cause this curvature to flip, which would result in the curve “going backwards” at one endpoint.

Also, note that, in general, points will not be spaced evenly in x, y, or arc length s.

Parameters:
  • t (Union[float, aerosandbox.numpy.ndarray]) –

  • x_a (float) – The x-coordinate of the first endpoint.

  • x_b (float) – The x-coordinate of the second endpoint.

  • y_a (float) – The y-coordinate of the first endpoint.

  • y_b (float) – The y-coordinate of the second endpoint.

  • dydx_a (float) – The derivative of y with respect to x at the first endpoint.

  • dydx_b (float) – The derivative of y with respect to x at the second endpoint.

Returns:

A scalar or numpy array of scalars representing the x-coordinates of the sampled points. y: A scalar or numpy array of scalars representing the y-coordinates of the sampled points.

Return type:

x

Usage:
>>> x_a, x_b = 0, 10
>>> y_a, y_b = 0, 5
>>> dydx_a, dydx_b = 0.5, -0.5
>>>
>>> t = np.linspace(0, 1, 50)
>>> x, y = quadratic_bezier_patch_from_tangents(
>>>     t=t,
>>>     x_a=x_a,
>>>     x_b=x_b,
>>>     y_a=y_a,
>>>     y_b=y_b,
>>>     dydx_a=dydx_a,
>>>     dydx_b=dydx_b
>>> )
aerosandbox.modeling.splines.linear_hermite_patch(x, x_a, x_b, f_a, f_b)[source]#

Computes the linear Hermite polynomial patch that passes through the given endpoints f_a and f_b.

Parameters:
  • x (Union[float, aerosandbox.numpy.ndarray]) – Scalar or array of values at which to evaluate the patch.

  • x_a (float) – The x-coordinate of the first endpoint.

  • x_b (float) – The x-coordinate of the second endpoint.

  • f_a (float) – The function value at the first endpoint.

  • f_b (float) – The function value at the second endpoint.

Returns:

The value of the patch evaluated at the input x. Returns a scalar if x is a scalar, or an array if x is an array.

Return type:

Union[float, aerosandbox.numpy.ndarray]

aerosandbox.modeling.splines.cubic_hermite_patch(x, x_a, x_b, f_a, f_b, dfdx_a, dfdx_b, extrapolation='continue')[source]#

Computes the cubic Hermite polynomial patch that passes through the given endpoints and endpoint derivatives.

Parameters:
  • x (Union[float, aerosandbox.numpy.ndarray]) – Scalar or array of values at which to evaluate the patch.

  • x_a (float) – The x-coordinate of the first endpoint.

  • x_b (float) – The x-coordinate of the second endpoint.

  • f_a (float) – The function value at the first endpoint.

  • f_b (float) – The function value at the second endpoint.

  • dfdx_a (float) – The derivative of the function with respect to x at the first endpoint.

  • dfdx_b (float) – The derivative of the function with respect to x at the second endpoint.

  • extrapolation (str) – A string indicating how to handle extrapolation outside of the domain [x_a, x_b]. Valid values are “continue”, which continues the patch beyond the endpoints, and “clip”, which clips the patch at the endpoints. Default is “continue”.

Returns:

The value of the patch evaluated at the input x. Returns a scalar if x is a scalar, or an array if x is an array.

Return type:

Union[float, aerosandbox.numpy.ndarray]

aerosandbox.modeling.splines.cosine_hermite_patch(x, x_a, x_b, f_a, f_b, dfdx_a, dfdx_b, extrapolation='continue')[source]#

Computes a Hermite patch (i.e., values + derivatives at endpoints) that uses a cosine function to blend between linear segments.

The end result is conceptually similar to a cubic Hermite patch, but computation is faster and the patch is C^infty-continuous.

Parameters:
  • x (Union[float, aerosandbox.numpy.ndarray]) – Scalar or array of values at which to evaluate the patch.

  • x_a (float) – The x-coordinate of the first endpoint.

  • x_b (float) – The x-coordinate of the second endpoint.

  • f_a (float) – The function value at the first endpoint.

  • f_b (float) – The function value at the second endpoint.

  • dfdx_a (float) – The derivative of the function with respect to x at the first endpoint.

  • dfdx_b (float) – The derivative of the function with respect to x at the second endpoint.

  • extrapolation (str) – A string indicating how to handle extrapolation outside of the domain [x_a, x_b]. Valid values are “continue”, which continues the patch beyond the endpoints, and “linear”, which extends the patch linearly at the endpoints. Default is “continue”.

Returns:

The value of the patch evaluated at the input x. Returns a scalar if x is a scalar, or an array if x is an array.

Return type:

Union[float, aerosandbox.numpy.ndarray]

aerosandbox.modeling.splines.x[source]#