pymead.core.rbezier.RBezier#
- class RBezier(point_sequence: PointSequence, weight_sequence: ParamSequence, default_nt: int | None = None, name: str | None = None, **kwargs)[source]#
Bases:
ParametricCurve- __init__(point_sequence: PointSequence, weight_sequence: ParamSequence, default_nt: int | None = None, name: str | None = None, **kwargs)[source]#
Creates a rational Bézier curve parametrized by the control points \(\mathbf{P}_i\) and weights \(w_i\) according to
\[\mathbf{C}(t)=\frac{\sum_{i=0}^n B_{i,n}(t) w_i \mathbf{P}_i}{\sum_{i=0}^n B_{i,n}(t) w_i}\]where \(B_{i,n}(t)\) is the Bernstein polynomial, given by
\[B_{i,n}(t)={n \choose i} t^i (1-t)^{n-i}\]The weights have the effect of “pulling” the curve toward their corresponding control points when their values are increased.
- Parameters:
point_sequence (PointSequence) – Sequence of points defining the control points for the Bézier curve
name (str or
None) – Optional name for the curve. Default:Nonet_start (float or
None) – Optional starting parameter vector value for the rational Bézier curve. Not specifying this value automatically gives a value of0.0. Default:Nonet_end (float or
None) – Optional ending parameter vector value for the rational Bézier curve. Not specifying this value automatically gives a value of1.0. Default:None
Methods
bernstein_poly(n, i, t)Calculates the Bernstein polynomial for a given Bézier curve order, index, and parameter vector.
derivative(t, order)Calculates an arbitrary-order derivative of the Bézier curve.
evaluate([t])Evaluates the curve using an optionally specified parameter vector.
evaluate_xy([t])finite_diff_P(P, k, i)Calculates the finite difference of the control points as shown in https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier-der.html
get_control_point_array()Gets a dictionary representation of the pymead object.
get_weight_vector()hodograph(t)Evaluates the hodograph of the rational Bézier curve using a specified parameter vector.
insert_point(idx, point, weight)insert_point_after_point(point_to_add, ...)point_removal_deletes_curve()point_sequence()points()remove()remove_point([idx, point])reverse_point_sequence()reverse_weight_sequence()set_point_sequence(point_sequence)set_weight_sequence(weight_sequence)weight_sequence()weights()Attributes
- static bernstein_poly(n: int, i: int, t: int)[source]#
Calculates the Bernstein polynomial for a given Bézier curve order, index, and parameter vector. The Bernstein polynomial is described by
\[B_{i,n}(t)={n \choose i} t^i (1-t)^{n-i}\]- Parameters:
- Returns:
Array of values of the Bernstein polynomial evaluated for each point in the parameter vector
- Return type:
np.ndarray
- 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=2returns the second derivative.
- Returns:
An array of
shape=(N,2)whereNis 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 fromt_startort_endwith the default size. Default:Nonekwargs – Additional keyword arguments to pass to
ParametricCurve.generate_t_vec
- 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 \(\mathbf{C}(t)\), \(\mathbf{C}'(t)\), and \(\mathbf{C}''(t)\).
- Return type:
- static finite_diff_P(P: ndarray, k: int, i: int)[source]#
Calculates the finite difference of the control points as shown in https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier-der.html
- get_dict_rep()[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 aPymeadObjrather than a string or float value, thename()method should be the value that is stored. For an example, see the overridden value of this method inpymead.core.airfoil.Airfoil. All subclasses ofPymeadObjmust implement this method, since it is the way pymead objects are stored in saved instances of aGeometryCollection(.jmeafiles).
- hodograph(t: ndarray) ndarray[source]#
Evaluates the hodograph of the rational Bézier curve using a specified parameter vector. Note that unlike in the case of the non-rational Bézier, the hodograph is not itself a rational Bézier curve. Therefore, only an array of \(x\)- and \(y\)-values is returned
- t: np.ndarray
Parameter vector along which the hodograph will be evaluated
- Returns:
Evaluated hodograph of the curve, dimensions \(N_t imes 2\), where \(N_t\) is the length of the input parameter vector, and columns represent the first derivative with respect to \(x\) and \(y\), respectively.
- Return type:
np.ndarray