pymead.core.bspline.BSpline#

class BSpline(point_sequence: PointSequence, knot_sequence: ParamSequence, default_nt: int | None = None, name: str | None = None, t_start: float | None = None, t_end: float | None = None, **kwargs)[source]#

Bases: ParametricCurve

__init__(point_sequence: PointSequence, knot_sequence: ParamSequence, default_nt: int | None = None, name: str | None = None, t_start: float | None = None, t_end: float | None = None, **kwargs)[source]#

Non-uniform rational B-spline (NURBS) curve evaluation class

Methods

derivative(t, order)

Calculates an arbitrary-order derivative of the Bézier curve.

disable_clamped_knots()

evaluate([t])

Evaluates the curve using an optionally specified parameter vector.

evaluate_xy([t])

Evaluate the B-spline curve at parameter t

get_control_point_array()

get_dict_rep()

Gets a dictionary representation of the pymead object.

get_knot_vector()

hodograph()

insert_point(idx, point)

insert_point_after_point(point_to_add, ...)

is_clamped(loc)

Determines whether the knot sequence of the B-spline is clamped.

knot_sequence()

knots()

plot([ax, nt, show, save_file])

Plots the airfoil to a matplotlib figure.

point_removal_deletes_curve()

point_sequence()

points()

remove()

remove_point([idx, point])

reverse_knot_sequence()

reverse_point_sequence()

set_knot_sequence(knot_sequence)

set_name(name)

Sets the object name.

set_point_sequence(point_sequence)

Attributes

degree

weights

derivative(t: ndarray, order: int)[source]#

Calculates an arbitrary-order derivative of the Bézier curve.

Parameters:
  • t (np.ndarray) – The parameter vector

  • order (int) – The derivative order. For example, order=2 returns the second derivative.

Returns:

An array of shape=(N,2) where N is the number of evaluated points specified by the \(t\) vector. The columns represent \(C^{(m)}_x(t)\) and \(C^{(m)}_y(t)\), where \(m\) is the derivative order.

Return type:

np.ndarray

evaluate(t: array | None = None, **kwargs)[source]#

Evaluates the curve using an optionally specified parameter vector.

Parameters:

t (np.ndarray or None) – Optional direct specification of the parameter vector for the curve. Not specifying this value gives a linearly spaced parameter vector from t_start or t_end with the default size. Default: None

Returns:

Data class specifying the following information about the Bézier curve:

\[C_x(t), C_y(t), C'_x(t), C'_y(t), C''_x(t), C''_y(t), \kappa(t)\]

where the \(x\) and \(y\) subscripts represent the \(x\) and \(y\) components of the vector-valued functions \(\vec{C}(t)\), \(\vec{C}'(t)\), and \(\vec{C}''(t)\).

Return type:

PCurveData

evaluate_xy(t: array | None = None, **kwargs) ndarray[source]#

Evaluate the B-spline curve at parameter t

get_dict_rep() dict[source]#

Gets a dictionary representation of the pymead object. In general, this dictionary should consist of only the required arguments for object instantiation. For example, the dictionary representation of a point looks something like this: {"x": 0.3, "y": 0.5}. If the argument requires a reference to a PymeadObj rather than a string or float value, the name() method should be the value that is stored. For an example, see the overridden value of this method in pymead.core.airfoil.Airfoil. All subclasses of PymeadObj must implement this method, since it is the way pymead objects are stored in saved instances of a GeometryCollection (.jmea files).

is_clamped(loc: ParametricCurveEndpoint) bool[source]#

Determines whether the knot sequence of the B-spline is clamped. A knot sequence is clamped when the first \(p+1\) knots are equal and the last \(p+1\) knots are equal.

Parameters:

loc (ParametricCurveEndpoint) – Specifies whether to check if the curve is clamped at the start or end

Returns:

Whether the B-spline has a clamped knot sequence

Return type:

bool

plot(ax: Axes | None = None, nt: int = 100, show: bool = True, save_file: str | None = None, **plt_kwargs)[source]#

Plots the airfoil to a matplotlib figure.

Parameters:
  • ax (plt.Axes or None) – Matplotlib Axes object on which the curve will be plotted. If specified, this method will only. If None, a new figure will be created. Default: None

  • nt (int) – Number of parametric values to evaluate along the curve. Default: 100

  • show (bool) – Whether to immediately show the curve plot. Ignored if ax is not None. Default: True

  • save_file (str or None) – Name of the file to save. If None, the curve image will not be saved to file. Ignored if ax is not None. Default: None

  • plt_kwargs – Additional keyword arguments to pass to matplotlib.pyplot.plot

set_name(name: str)[source]#

Sets the object name.

Parameters:

name (str) – The object name