aerocaps.geom.surfaces.BezierSurface#
- class BezierSurface(points: List[List[Point3D]], name: str = 'BezierSurface', construction: bool = False)[source]#
Bases:
SurfaceBézier surface class. A NURBS surface with no internal knots and all weights equal to unity.
- __init__(points: List[List[Point3D]], name: str = 'BezierSurface', construction: bool = False)[source]#
A Bézier surface is a parametric surface described by a matrix of control points and defined on a rectangular domain \(\{u \in [0,1], v \in [0,1]\}\). The mathematical expression for the Bézier surface is identical to that of the Bézier curve except with an extra dimension:
\[\mathbf{S}(u,v) = \sum\limits_{i=0}^n \sum\limits_{j=0}^m B_{i,n}(u) B_{j,m}(v) \mathbf{P}_{i,j}\]Where \(B_{i,n}(t)\) is the Bernstein polynomial given by
\[B_{i,n}(t) = {n \choose i} t^i (1-t)^{n-i}\]An example of a Bézier surface with \(n=2\) and \(m=3\) is shown below. Note that the only control points that lie directly on the surface are the corner points of the control point mesh. This is analogous to the fact that only the starting and ending control points of Bézier curves lie directly on the curve. In fact, Bézier curves derived from the bounding rows and columns of control points exactly represent the boundary curves of the surface. In this example, the control points given by \(\mathbf{P}_{i,j=0}\) and \(\mathbf{P}_{i,j=m}\) represent quadratic Bézier curves (\(n=2\)), and the control points given by \(\mathbf{P}_{i=0,j}\) and \(\mathbf{P}_{i=n,j}\) represent cubic Bézier curves (\(m=3\)).
A \(2 \times 3\) Bézier surface with control points and control point net lines shown#
A \(2 \times 3\) Bézier surface with isoparametric curves in both \(u\) and \(v\) shown#
Bézier surfaces can be constructed either via the default constructor with a nested list of
aerocaps.geom.point.Point3Dobjects of by a 3-Dnumpyarray. For example, say we have sixPoint3Dobjects, A-F and would like to use them to create a \(2 \times 1\) Bézier surface. Using the default constructor with the point objects,surf = BezierSurface([[pA, pB], [pC, pD], [pE, pF]])
Using the array class method and point \(xyz\) float values given by
pA_x,pA_y,pA_z, etc.,control_points = np.array([ [[pA_x, pA_y, pA_z], [pB_x, pB_y, pB_z]], [[pC_x, pC_y, pC_z], [pD_x, pD_y, pD_z]], [[pE_x, pE_y, pE_z], [pF_x, pF_y, pF_z]], ]) surf = BezierSurface(control_points)
- Parameters:
points (List[List[Point3D]] or numpy.ndarray) – Control points for the Bézier surface, either as a nested list of
Point3Dobjects or anndarrayof size \((n+1) \times (m+1) \times 3\), where \(n\) is the surface degree in the \(u\)-parametric direction and \(m\) is the surface degree in the \(v\)-parametric directionname (str) – Name of the geometric object. May be re-assigned a unique name when added to a
GeometryContainer. Default: ‘BezierSurface’construction (bool) – Whether this is a geometry used only for construction of other geometries. If
True, this geometry will not be exported or plotted. Default:False
Methods
d2Sdu2(u, v)Evaluates the second derivative with respect to \(u\) at a single \((u,v)\) pair
d2Sdu2_grid(Nu, Nv)Evaluates the second derivative with respect to \(u\) on a linearly-spaced grid of \(u\)- and \(v\)-values.
d2Sdu2_uvvecs(u, v)Evaluates the second derivative of the surface with respect to \(u\) at arbitrary vectors of \(u\) and \(v\)-values.
d2Sdv2(u, v)Evaluates the second derivative with respect to \(v\) at a single \((u,v)\) pair
d2Sdv2_grid(Nu, Nv)Evaluates the second derivative with respect to \(v\) on a linearly-spaced grid of \(u\)- and \(v\)-values.
d2Sdv2_uvvecs(u, v)Evaluates the second derivative of the surface with respect to \(v\) at arbitrary vectors of \(u\) and \(v\)-values.
dSdu(u, v)Evaluates the first derivative with respect to \(u\) at a single \((u,v)\) pair
dSdu_grid(Nu, Nv)Evaluates the first derivative with respect to \(u\) on a linearly-spaced grid of \(u\)- and \(v\)-values.
dSdu_uvvecs(u, v)Evaluates the first derivative of the surface with respect to \(u\) at arbitrary vectors of \(u\) and \(v\)-values.
dSdv(u, v)Evaluates the first derivative with respect to \(v\) at a single \((u,v)\) pair
dSdv_grid(Nu, Nv)Evaluates the first derivative with respect to \(v\) on a linearly-spaced grid of \(u\)- and \(v\)-values.
dSdv_uvvecs(u, v)Evaluates the first derivative of the surface with respect to \(v\) at arbitrary vectors of \(u\) and \(v\)-values.
Elevates the degree of the Bézier surface in the \(u\)-parametric direction.
Elevates the degree of the Bézier surface in the \(v\)-parametric direction.
enforce_c0(other, surface_edge, ...)For zeroth-degree continuity, there is no difference between geometric (\(G^0\)) and parametric (\(C^0\)) continuity.
enforce_c0c1(other, surface_edge, ...)Equivalent to calling
enforce_g0g1withf=1.0.enforce_c0c1c2(other, surface_edge, ...)Equivalent to calling
enforce_g0g1g2withf=1.0.enforce_g0(other, surface_edge, ...)Enforces \(G^0\) continuity along the input
surface_edgeby equating the control points along this edge to the control points along theother_surface_edgeof the Bézier surface given byother.enforce_g0g1(other, f, surface_edge, ...)First enforces \(G^0\) continuity, then tangent (\(G^1\)) continuity is enforced according to the following equation:
enforce_g0g1_multiface([adjacent_surf_u0, ...])enforce_g0g1g2(other, f, surface_edge, ...)First enforces \(G^0\) and \(G^1\) continuity, then curvature (\(G^2\)) continuity is enforced according to the following equation:
enforce_g0g1g2_multiface([adjacent_surf_u0, ...])evaluate(u, v)Evaluates the surface at a given \((u,v)\) parameter pair.
evaluate_grid(Nu, Nv)Evaluates the Bézier surface on a uniform \(N_u \times N_v\) grid of parameter values.
evaluate_point3d(u, v)Evaluates the Bézier surface at a single \((u,v)\) parameter pair and returns a point object.
evaluate_uvvecs(u, v)Evaluates the Bézier surface at arbitrary vectors of \(u\) and \(v\)-values.
extract_edge_curve(surface_edge)Extracts the control points from one of the four edges of the Bézier surface and outputs a Bézier curve with these control points
Extracts a curve along the \(v\)-direction at a fixed value of \(u\)
Extracts a curve along the \(u\)-direction at a fixed value of \(v\)
from_curve_extrude(curve, distance[, ...])Creates a Bézier surface by extruding a Bézier curve along an axis.
Generates a list of
Point3DandLine3Dobjects representing the Bézier surface's control points and connections between themConverts the nested list of control points to a 3-D
ndarray.get_edge(edge[, n_points])Evaluates the surface at
n_pointsparameter locations along a given edge.get_first_deriv_cp_sens_along_edge(edge, i, j)Gets the sensitivity of the first \(u\)- or \(v\)-derivative along an edge with respect to control point \(\mathbf{P}_{i,j}\)
get_first_derivs_along_edge(edge[, ...])Evaluates the parallel or perpendicular derivative along a surface edge at
n_pointsparameter locations.get_parallel_degree(surface_edge)Gets the degree of the curve corresponding to the input surface edge.
get_parallel_n_points(surface_edge)Gets the number of control points in the parametric direction parallel to the input surface edge.
get_perpendicular_degree(surface_edge)Gets the degree of the curve in the parametric direction perpendicular to the input surface edge.
get_perpendicular_n_points(surface_edge)Gets the number of control points in the parametric direction perpendicular to the input surface edge.
get_point(row_index, continuity_index, ...)Gets the point corresponding to a particular index along the edge curve with perpendicular index corresponding to the level of continuity being applied.
get_point_ij(row_index, continuity_index, ...)Gets the point indices corresponding to a particular index along the edge curve with perpendicular index corresponding to the level of continuity being applied.
get_second_deriv_cp_sens_along_edge(edge, i, j)Gets the sensitivity of the second \(u\)- or \(v\)-derivative along an edge with respect to control point \(\mathbf{P}_{i,j}\)
get_second_derivs_along_edge(edge[, ...])Evaluates the parallel or perpendicular second derivative along a surface edge at
n_pointsparameter locations.get_u_or_v_given_uvxyz([u, v, uv_guess, x, y, z])Computes one parametric value given the other and a specified \(x\)-, \(y\)-, or \(z\)-location.
plot_control_point_mesh_lines(plot, ...)Plots the network of lines connecting the Bézier surface control points using the pyvista library
plot_control_points(plot, **point_kwargs)plot_surface(plot[, Nu, Nv])set_point(point, row_index, ...)Sets the point corresponding to a particular index along the edge curve with perpendicular index corresponding to the level of continuity being applied.
split_at_u(u0)Splits the Bézier surface at \(u=u_0\) along the \(v\)-parametric direction.
split_at_v(v0)Splits the Bézier surface at \(v=v_0\) along the \(u\)-parametric direction.
to_iges(*args, **kwargs)Converts the Bézier surface to an IGES entity.
Converts the current non-rational Bézier surface to a rational Bézier surface by setting all weights to unity.
transform(**transformation_kwargs)Creates a transformed copy of the surface by transforming each of the control points
verify_g0(other, surface_edge, ...[, n_points])Verifies that two Bézier surfaces are \(G^0\)-continuous along their shared edge
verify_g1(other, surface_edge, ...[, n_points])Verifies that two Bézier surfaces are \(G^1\)-continuous along their shared edge
verify_g2(other, surface_edge, ...[, n_points])Verifies that two Bézier surfaces are \(G^2\)-continuous along their shared edge
Attributes
Surface degree in the \(u\)-parametric direction
Surface degree in the \(v\)-parametric direction
Shorthand for
degree_vShorthand for
degree_uNumber of control points in the \(u\)-parametric direction
Number of control points in the \(v\)-parametric direction
- d2Sdu2(u: float, v: float) ndarray[source]#
Evaluates the second derivative with respect to \(u\) at a single \((u,v)\) pair
- Parameters:
- Returns:
1-D array containing the \(x\)-, \(y\)-, and \(z\)-components of the second derivative
- Return type:
np.ndarray
- d2Sdu2_grid(Nu: int, Nv: int) ndarray[source]#
Evaluates the second derivative with respect to \(u\) on a linearly-spaced grid of \(u\)- and \(v\)-values.
- d2Sdu2_uvvecs(u: ndarray, v: ndarray)[source]#
Evaluates the second derivative of the surface with respect to \(u\) at arbitrary vectors of \(u\) and \(v\)-values.
- Parameters:
u (np.ndarray) – 1-D array of \(u\)-parameter values
v (np.ndarray) – 1-D array of \(v\)-parameter values
- Returns:
Array of size \(\text{len}(u) \times \text{len}(v) \times 3\)
- Return type:
np.ndarray
- d2Sdv2(u: float, v: float)[source]#
Evaluates the second derivative with respect to \(v\) at a single \((u,v)\) pair
- Parameters:
- Returns:
1-D array containing the \(x\)-, \(y\)-, and \(z\)-components of the second derivative
- Return type:
np.ndarray
- d2Sdv2_grid(Nu: int, Nv: int) ndarray[source]#
Evaluates the second derivative with respect to \(v\) on a linearly-spaced grid of \(u\)- and \(v\)-values.
- d2Sdv2_uvvecs(u: ndarray, v: ndarray)[source]#
Evaluates the second derivative of the surface with respect to \(v\) at arbitrary vectors of \(u\) and \(v\)-values.
- Parameters:
u (np.ndarray) – 1-D array of \(u\)-parameter values
v (np.ndarray) – 1-D array of \(v\)-parameter values
- Returns:
Array of size \(\text{len}(u) \times \text{len}(v) \times 3\)
- Return type:
np.ndarray
- dSdu(u: float, v: float) ndarray[source]#
Evaluates the first derivative with respect to \(u\) at a single \((u,v)\) pair
- Parameters:
- Returns:
1-D array containing the \(x\)-, \(y\)-, and \(z\)-components of the second derivative
- Return type:
np.ndarray
- dSdu_grid(Nu: int, Nv: int) ndarray[source]#
Evaluates the first derivative with respect to \(u\) on a linearly-spaced grid of \(u\)- and \(v\)-values.
- dSdu_uvvecs(u: ndarray, v: ndarray)[source]#
Evaluates the first derivative of the surface with respect to \(u\) at arbitrary vectors of \(u\) and \(v\)-values.
- Parameters:
u (np.ndarray) – 1-D array of \(u\)-parameter values
v (np.ndarray) – 1-D array of \(v\)-parameter values
- Returns:
Array of size \(\text{len}(u) \times \text{len}(v) \times 3\)
- Return type:
np.ndarray
- dSdv(u: float, v: float)[source]#
Evaluates the first derivative with respect to \(v\) at a single \((u,v)\) pair
- Parameters:
- Returns:
1-D array containing the \(x\)-, \(y\)-, and \(z\)-components of the second derivative
- Return type:
np.ndarray
- dSdv_grid(Nu: int, Nv: int) ndarray[source]#
Evaluates the first derivative with respect to \(v\) on a linearly-spaced grid of \(u\)- and \(v\)-values.
- dSdv_uvvecs(u: ndarray, v: ndarray)[source]#
Evaluates the first derivative of the surface with respect to \(v\) at arbitrary vectors of \(u\) and \(v\)-values.
- Parameters:
u (np.ndarray) – 1-D array of \(u\)-parameter values
v (np.ndarray) – 1-D array of \(v\)-parameter values
- Returns:
Array of size \(\text{len}(u) \times \text{len}(v) \times 3\)
- Return type:
np.ndarray
- elevate_degree_u() BezierSurface[source]#
Elevates the degree of the Bézier surface in the \(u\)-parametric direction.
\(u\) degree (\(n\)) elevation#
- Returns:
A new Bézier surface with identical shape to the current one but with one additional row of control points in the \(u\)-parametric direction
- Return type:
- elevate_degree_v() BezierSurface[source]#
Elevates the degree of the Bézier surface in the \(v\)-parametric direction.
\(v\) degree (\(m\)) elevation#
- Returns:
A new Bézier surface with identical shape to the current one but with one additional row of control points in the \(v\)-parametric direction
- Return type:
- enforce_c0(other: BezierSurface, surface_edge: SurfaceEdge, other_surface_edge: SurfaceEdge)[source]#
For zeroth-degree continuity, there is no difference between geometric (\(G^0\)) and parametric (\(C^0\)) continuity. Because this method is simply a convenience method that calls
enforce_g0, see the documentation for that method for more detailed documentation.- Parameters:
other (BezierSurface) – Another Bézier surface along which an edge will be used for stitching
surface_edge (SurfaceEdge) – The edge of the current surface to modify
other_surface_edge (SurfaceEdge) – Tool edge of surface
otherwhich determines the positions of control points alongsurface_edgeof the current surface
- enforce_c0c1(other: BezierSurface, surface_edge: SurfaceEdge, other_surface_edge: SurfaceEdge)[source]#
Equivalent to calling
enforce_g0g1withf=1.0. See that method for more detailed documentation.- Parameters:
other (BezierSurface) – Another Bézier surface along which an edge will be used for stitching
surface_edge (SurfaceEdge) – The edge of the current surface to modify
other_surface_edge (SurfaceEdge) – Tool edge of surface
otherwhich determines the positions of control points alongsurface_edgeof the current surface
- enforce_c0c1c2(other: BezierSurface, surface_edge: SurfaceEdge, other_surface_edge: SurfaceEdge)[source]#
Equivalent to calling
enforce_g0g1g2withf=1.0. See that method for more detailed documentation.- Parameters:
other (BezierSurface) – Another Bézier surface along which an edge will be used for stitching
surface_edge (SurfaceEdge) – The edge of the current surface to modify
other_surface_edge (SurfaceEdge) – Tool edge of surface
otherwhich determines the positions of control points alongsurface_edgeof the current surface
- enforce_g0(other: BezierSurface, surface_edge: SurfaceEdge, other_surface_edge: SurfaceEdge)[source]#
Enforces \(G^0\) continuity along the input
surface_edgeby equating the control points along this edge to the control points along theother_surface_edgeof the Bézier surface given byother. The control points of the surface from which this method is called are modified in-place, and the control points ofotherare left unchanged.Important
The parallel degree of the current surface along
surface_edgemust be equal to the parallel degree of theothersurface alongother_surface_edge, otherwise anAssertionErrorwill be raised. If these degrees are not equal, first elevate the degree of the surface with the lower parallel degree until the degrees match using eitherelevate_degree_uorelevate_degree_v, whichever is appropriate.See also
enforce_c0Parametric continuity equivalent (\(C^0\))
- Parameters:
other (BezierSurface) – Another Bézier surface along which an edge will be used for stitching
surface_edge (SurfaceEdge) – The edge of the current surface to modify
other_surface_edge (SurfaceEdge) – Tool edge of surface
otherwhich determines the positions of control points alongsurface_edgeof the current surface
- enforce_g0g1(other: BezierSurface, f: float, surface_edge: SurfaceEdge, other_surface_edge: SurfaceEdge)[source]#
First enforces \(G^0\) continuity, then tangent (\(G^1\)) continuity is enforced according to the following equation:
\[\mathcal{P}^{b,\mathcal{E}_b}_{k,1} = \mathcal{P}^{b,\mathcal{E}_b}_{k,0} + f \frac{p_{\perp}^{a,\mathcal{E}_a}}{p_{\perp}^{b,\mathcal{E}_b}} \left[\mathcal{P}^{a,\mathcal{E}_a}_{k,0} - \mathcal{P}^{a,\mathcal{E}_a}_{k,1} \right] \text{ for }k=0,1,\ldots,p_{\parallel}^{b,\mathcal{E}_b}\]Here, \(b\) corresponds to the current surface, and \(a\) corresponds to the
othersurface. The control points of the surface from which this method is called are modified in-place, and the control points ofotherare left unchanged.See also
enforce_g0Geometric point continuity enforcement (\(G^0\))
enforce_c0c1Parametric continuity equivalent (\(C^1\))
- Parameters:
other (BezierSurface) – Another Bézier surface along which an edge will be used for stitching
f (float) – Tangent proportionality factor
surface_edge (SurfaceEdge) – The edge of the current surface to modify
other_surface_edge (SurfaceEdge) – Tool edge of surface
otherwhich determines the positions of control points alongsurface_edgeof the current surface
- enforce_g0g1_multiface(adjacent_surf_u0: BezierSurface = None, adjacent_surf_u1: BezierSurface = None, adjacent_surf_v0: BezierSurface = None, adjacent_surf_v1: BezierSurface = None, other_edge_u0: SurfaceEdge = None, other_edge_u1: SurfaceEdge = None, other_edge_v0: SurfaceEdge = None, other_edge_v1: SurfaceEdge = None, f_u0_initial: float = 1.0, f_u1_initial: float = 1.0, f_v0_initial: float = 1.0, f_v1_initial: float = 1.0, n_deriv_points: int = 10) OptimizeResult[source]#
Warning
This is an experimental feature and should not be used in production geometries
Enforces \(G^0\) and \(G^1\) continuity across multiple adjacent boundaries of a surface, up to all four boundaries. This is done by first enforcing \(G^0\) continuity at all required boundaries and then optimizing the locations of the second rows of control points to minimize \(G^1\) error at
n_deriv_pointslocations along each of the boundary curves. The following is the cost function that is minimized:\[J(x_k) = \sum\limits_{i=0}^{n_p n_{\mathcal{E}}} \left( \left. \frac{\partial \mathbf{S}_i^a(u,v)}{\partial \mu} \right|_{u=u_i,v=v_i} - \frac{f_{\text{sgn},i}}{f_i(x_k)} \left. \frac{\partial \mathbf{S}^b(u,v,x_k)}{\partial \mu} \right|_{u=u_i,v=v_i} \right)^2\]where
\(x_k\) is the set of design variables to be optimized including the internal control point locations and tangent proportionality factors across each boundary
\(n_p\) is the number of discrete first derivative calculations on each boundary (specified by
n_deriv_points)\(n_\mathcal{E}\) is the number of edges across which continuity is being enforced
\(\mathbf{S}_i^a(u,v)\) is a surface specified by
adjacent_surf_u0, etc.\(\mu\) is equal to either \(u\) or \(v\), determined by the parametric direction perpendicular to the edge
\((u_i,v_i)\) is the point along an edge where the derivative is being evaluated
\(f_{\text{sgn},i}\) is the sign of the proportionality factor, \(-1\) if both the target edge and other edge specified by \(i\) end in \(0\) or both end in \(1\), \(1\) otherwise
\(f_i(x_k)\) is the tangent proportionality factor
\(\mathbf{S}^b(u,v,x_k)\) is the target surface (
self)
For maximum performance of the optimizer, the exact Jacobian is calculated:
\[\frac{\partial J(x_k)}{\partial x_k} = 2 \sum\limits_{i=0}^{n_p n_{\mathcal{E}}} \left( \left. \frac{\partial \mathbf{S}_i^a(u,v)}{\partial \mu} \right|_{u=u_i,v=v_i} - \frac{f_{\text{sgn},i}}{f_i(x_k)} \left. \frac{\partial \mathbf{S}^b(u,v,x_k)}{\partial \mu} \right|_{u=u_i,v=v_i} \right) \left[ -f_{\text{sgn},i} \frac{\partial}{\partial x_k} \left( \frac{1}{f_i} \right) \left( \left. \frac{\partial \mathbf{S}^b(u,v,x_k)}{\partial \mu} \right|_{u=u_i,v=v_i} \right) -\frac{f_{\text{sgn},i}}{f_i} \frac{\partial}{\partial x_k} \left( \left. \frac{\partial \mathbf{S}^b(u,v,x_k)}{\partial \mu} \right|_{u=u_i,v=v_i} \right) \right]\]Note
This method is reserved for the complex case where continuity is required across boundaries that share a surface corner. In the case of continuity with a single surface or a pair of surfaces with common boundaries on opposite sides of the surface (such as the \(v_0\) and \(v_1\) boundaries), the much simpler
enforce_g0g1should be used.
Multi-face \(G^0\) and \(G^1\) continuity enforcement#
- Parameters:
adjacent_surf_u0 (BezierSurface) – Surface sharing the \(u_0\) boundary of
target_surf. Default:Noneadjacent_surf_u1 (BezierSurface) – Surface sharing the \(u_1\) boundary of
target_surf. Default:Noneadjacent_surf_v0 (BezierSurface) – Surface sharing the \(v_0\) boundary of
target_surf. Default:Noneadjacent_surf_v1 (BezierSurface) – Surface sharing the \(v_1\) boundary of
target_surf. Default:Noneother_edge_u0 (SurfaceEdge) – Edge of surface
adjacent_surf_u0that will be stitched. Default:Noneother_edge_u1 (SurfaceEdge) – Edge of surface
adjacent_surf_u0that will be stitched. Default:Noneother_edge_v0 (SurfaceEdge) – Edge of surface
adjacent_surf_u0that will be stitched. Default:Noneother_edge_v1 (SurfaceEdge) – Edge of surface
adjacent_surf_u0that will be stitched. Default:Nonef_u0_initial (float) – Initial value of the tangent proportionality factor across boundary \(u_0\). The final value selected by the optimizer will be different from this value. Default:
1.0f_u1_initial (float) – Initial value of the tangent proportionality factor across boundary \(u_1\). The final value selected by the optimizer will be different from this value. Default:
1.0f_v0_initial (float) – Initial value of the tangent proportionality factor across boundary \(v_0\). The final value selected by the optimizer will be different from this value. Default:
1.0f_v1_initial (float) – Initial value of the tangent proportionality factor across boundary \(v_1\). The final value selected by the optimizer will be different from this value. Default:
1.0n_deriv_points (int) – Number of discrete locations where the continuity error will be evaluated. Default:
10
- Returns:
Result from the \(G^1\) continuity error minimization problem solution
- Return type:
OptimizeResult
- enforce_g0g1g2(other: BezierSurface, f: float, surface_edge: SurfaceEdge, other_surface_edge: SurfaceEdge)[source]#
First enforces \(G^0\) and \(G^1\) continuity, then curvature (\(G^2\)) continuity is enforced according to the following equation:
\[\mathcal{P}^{b,\mathcal{E}_b}_{k,2} = 2 \mathcal{P}^{b,\mathcal{E}_b}_{k,1} - \mathcal{P}^{b,\mathcal{E}_b}_{k,0} + f^2 \frac{p_{\perp}^{a,\mathcal{E}_a}(p_{\perp}^{a,\mathcal{E}_a}-1)}{p_{\perp}^{b,\mathcal{E}_b}(p_{\perp}^{b,\mathcal{E}_b}-1)} \left[ \mathcal{P}^{a,\mathcal{E}_a}_{k,0} - 2 \mathcal{P}^{a,\mathcal{E}_a}_{k,1} + \mathcal{P}^{a,\mathcal{E}_a}_{k,2} \right] \text{ for }k=0,1,\ldots,p_{\parallel}^{b,\mathcal{E}_b}\]Here, \(b\) corresponds to the current surface, and \(a\) corresponds to the
othersurface. The control points of the surface from which this method is called are modified in-place, and the control points ofotherare left unchanged.See also
enforce_g0Geometric point continuity enforcement (\(G^0\))
enforce_g0g1Geometric tangent continuity enforcement (\(G^1\))
enforce_c0c1c2Parametric continuity equivalent (\(C^2\))
- Parameters:
other (BezierSurface) – Another Bézier surface along which an edge will be used for stitching
f (float) – Tangent proportionality factor
surface_edge (SurfaceEdge) – The edge of the current surface to modify
other_surface_edge (SurfaceEdge) – Tool edge of surface
otherwhich determines the positions of control points alongsurface_edgeof the current surface
- enforce_g0g1g2_multiface(adjacent_surf_u0: BezierSurface = None, adjacent_surf_u1: BezierSurface = None, adjacent_surf_v0: BezierSurface = None, adjacent_surf_v1: BezierSurface = None, other_edge_u0: SurfaceEdge = None, other_edge_u1: SurfaceEdge = None, other_edge_v0: SurfaceEdge = None, other_edge_v1: SurfaceEdge = None, f_u0_initial: float = 1.0, f_u1_initial: float = 1.0, f_v0_initial: float = 1.0, f_v1_initial: float = 1.0, n_deriv_points: int = 10) OptimizeResult[source]#
Warning
This is an experimental feature and should not be used in production geometries
Enforces \(G^0\), \(G^1\), and \(G^2\) continuity across multiple adjacent boundaries of a surface, up to all four boundaries. This is done by first enforcing \(G^0\) continuity at all required boundaries and then optimizing the locations of the second and third rows of control points to minimize \(G^1\) and \(G^2\) error at
n_deriv_pointslocations along each of the boundary curves. The following is the cost function that is minimized:\[J(x_k) = \sum\limits_{l=1}^2 \sum\limits_{i=0}^{n_p n_{\mathcal{E}}} \left( \left. \frac{\partial^l \mathbf{S}_i^a(u,v)}{\partial \mu^l} \right|_{u=u_i,v=v_i} - \frac{f_{\text{sgn},i}}{f^l_i(x_k)} \left. \frac{\partial^l \mathbf{S}^b(u,v,x_k)}{\partial \mu^l} \right|_{u=u_i,v=v_i} \right)^2\]where
\(x_k\) is the set of design variables to be optimized including the internal control point locations and tangent proportionality factors across each boundary
\(n_p\) is the number of discrete derivative calculations on each boundary (specified by
n_deriv_points)\(n_\mathcal{E}\) is the number of edges across which continuity is being enforced
\(\mathbf{S}_i^a(u,v)\) is a surface specified by
adjacent_surf_u0, etc.\(\mu\) is equal to either \(u\) or \(v\), determined by the parametric direction perpendicular to the edge
\((u_i,v_i)\) is the point along an edge where the derivative is being evaluated
\(f_{\text{sgn},i}\) is the sign of the proportionality factor, \(-1\) if both the target edge and other edge specified by \(i\) end in \(0\) or both end in \(1\), \(1\) otherwise
\(f_i(x_k)\) is the tangent proportionality factor
\(\mathbf{S}^b(u,v,x_k)\) is the target surface (
self)\(l\) is the derivative order
For maximum performance of the optimizer, the exact Jacobian is calculated:
\[\frac{\partial J(x_k)}{\partial x_k} = 2 \sum\limits_{l=1}^2 \sum\limits_{i=0}^{n_p n_{\mathcal{E}}} \left( \left. \frac{\partial^l \mathbf{S}_i^a(u,v)}{\partial \mu^l} \right|_{u=u_i,v=v_i} - \frac{f_{\text{sgn},i}}{f^l_i(x_k)} \left. \frac{\partial^l \mathbf{S}^b(u,v,x_k)}{\partial \mu^l} \right|_{u=u_i,v=v_i} \right) \left[ -f_{\text{sgn},i} \frac{\partial}{\partial x_k} \left( \frac{1}{f^l_i} \right) \left( \left. \frac{\partial^l \mathbf{S}^b(u,v,x_k)}{\partial \mu^l} \right|_{u=u_i,v=v_i} \right) -\frac{f_{\text{sgn},i}}{f_i^l} \frac{\partial}{\partial x_k} \left( \left. \frac{\partial^l \mathbf{S}^b(u,v,x_k)}{\partial \mu^l} \right|_{u=u_i,v=v_i} \right) \right]\]Note
This method is reserved for the complex case where continuity is required across boundaries that share a surface corner. In the case of continuity with a single surface or a pair of surfaces with common boundaries on opposite sides of the surface (such as the \(v_0\) and \(v_1\) boundaries), the much simpler
enforce_g0g1g2should be used.- Parameters:
adjacent_surf_u0 (BezierSurface) – Surface sharing the \(u_0\) boundary of
target_surf. Default:Noneadjacent_surf_u1 (BezierSurface) – Surface sharing the \(u_1\) boundary of
target_surf. Default:Noneadjacent_surf_v0 (BezierSurface) – Surface sharing the \(v_0\) boundary of
target_surf. Default:Noneadjacent_surf_v1 (BezierSurface) – Surface sharing the \(v_1\) boundary of
target_surf. Default:Noneother_edge_u0 (SurfaceEdge) – Edge of surface
adjacent_surf_u0that will be stitched. Default:Noneother_edge_u1 (SurfaceEdge) – Edge of surface
adjacent_surf_u0that will be stitched. Default:Noneother_edge_v0 (SurfaceEdge) – Edge of surface
adjacent_surf_u0that will be stitched. Default:Noneother_edge_v1 (SurfaceEdge) – Edge of surface
adjacent_surf_u0that will be stitched. Default:Nonef_u0_initial (float) – Initial value of the tangent proportionality factor across boundary \(u_0\). The final value selected by the optimizer will be different from this value. Default:
1.0f_u1_initial (float) – Initial value of the tangent proportionality factor across boundary \(u_1\). The final value selected by the optimizer will be different from this value. Default:
1.0f_v0_initial (float) – Initial value of the tangent proportionality factor across boundary \(v_0\). The final value selected by the optimizer will be different from this value. Default:
1.0f_v1_initial (float) – Initial value of the tangent proportionality factor across boundary \(v_1\). The final value selected by the optimizer will be different from this value. Default:
1.0n_deriv_points (int) – Number of discrete locations where the continuity error will be evaluated. Default:
10
- Returns:
Result from the \(G^1\)- and \(G^2\)-continuity error minimization problem solution
- Return type:
OptimizeResult
- evaluate(u: float, v: float)[source]#
Evaluates the surface at a given \((u,v)\) parameter pair.
- Parameters:
- Returns:
1-D array of the form
array([x, y, z])representing the evaluated point on the surface- Return type:
- evaluate_grid(Nu: int, Nv: int) ndarray[source]#
Evaluates the Bézier surface on a uniform \(N_u \times N_v\) grid of parameter values.
- Parameters:
- Returns:
Array of size \(N_u \times N_v \times 3\)
- Return type:
- evaluate_point3d(u: float, v: float) Point3D[source]#
Evaluates the Bézier surface at a single \((u,v)\) parameter pair and returns a point object.
- evaluate_uvvecs(u: ndarray, v: ndarray) ndarray[source]#
Evaluates the Bézier surface at arbitrary vectors of \(u\) and \(v\)-values.
- Parameters:
u (np.ndarray) – 1-D array of \(u\)-parameter values
v (np.ndarray) – 1-D array of \(v\)-parameter values
- Returns:
Array of size \(\text{len}(u) \times \text{len}(v) \times 3\)
- Return type:
np.ndarray
- extract_edge_curve(surface_edge: SurfaceEdge) BezierCurve3D[source]#
Extracts the control points from one of the four edges of the Bézier surface and outputs a Bézier curve with these control points
- Parameters:
surface_edge (SurfaceEdge) – Edge along which to extract the curve
- Returns:
Bézier curve with control points corresponding to the control points along the edge of the surface
- Return type:
- extract_isoparametric_curve_u(u: float, Nv: int) ndarray[source]#
Extracts a curve along the \(v\)-direction at a fixed value of \(u\)
- Parameters:
- Returns:
Array of size \(N_v \times 3\) representing the \(x\)-, \(y\)-, and \(z\)-coordinates of the points evaluated along the isoparametric curve
- Return type:
- extract_isoparametric_curve_v(Nu: int, v: float) ndarray[source]#
Extracts a curve along the \(u\)-direction at a fixed value of \(v\)
- Parameters:
- Returns:
Array of size \(N_u \times 3\) representing the \(x\)-, \(y\)-, and \(z\)-coordinates of the points evaluated along the isoparametric curve
- Return type:
- classmethod from_curve_extrude(curve: BezierCurve3D, distance: Length, extrude_axis: Vector3D = None, symmetric: bool = False, reverse: bool = False)[source]#
Creates a Bézier surface by extruding a Bézier curve along an axis.
Important
If the input curve is linear, the
extrude_axisargument must be specified.- Parameters:
curve (BezierCurve3D) – Curve to extrude. The most common use case is a planar curve, but this is not required.
distance (Length) – Distance along the axis to extrude
extrude_axis (Vector3D) – Optional direct specification of the extrusion axis. If not specified, a vector normal to the plane containing the first, second, and last control points of the curve is used. Default:
Nonesymmetric (bool) – Whether to extrude in both directions. Default:
Falsereverse (bool) – Whether to flip the extrusion vector. Default:
False
- Returns:
Extruded surface
- Return type:
- generate_control_point_net()[source]#
Generates a list of
Point3DandLine3Dobjects representing the Bézier surface’s control points and connections between them
- get_control_point_array() ndarray[source]#
Converts the nested list of control points to a 3-D
ndarray.- Returns:
3-D array
- Return type:
- get_edge(edge: SurfaceEdge, n_points: int = 10) ndarray[source]#
Evaluates the surface at
n_pointsparameter locations along a given edge.- Parameters:
edge (SurfaceEdge) – Edge along which to evaluate
n_points (int) – Number of evenly-spaced parameter locations at which to evaluate the edge curve. Default: 10
- Returns:
2-D array of size \(n_\text{points} \times 3\)
- Return type:
- get_first_deriv_cp_sens_along_edge(edge: SurfaceEdge, i: int, j: int, n_points: int = 10, perp: bool = True) ndarray[source]#
Gets the sensitivity of the first \(u\)- or \(v\)-derivative along an edge with respect to control point \(\mathbf{P}_{i,j}\)
- Parameters:
edge (SurfaceEdge) – Edge along which to evaluate
i (int) – \(i\)-index of the control point
j (int) – \(j\)-index of the control point
n_points (int) – Number of evenly-spaced parameter locations at which to evaluate the derivative. Default: 10
perp (bool) – Whether to evaluate the cross-derivative. If
False, the derivative along the parameter direction parallel to the edge will be evaluated instead. Default:True
- Returns:
2-D array of size \(n_\text{points} \times 3\)
- Return type:
- get_first_derivs_along_edge(edge: SurfaceEdge, n_points: int = 10, perp: bool = True) ndarray[source]#
Evaluates the parallel or perpendicular derivative along a surface edge at
n_pointsparameter locations. The derivative represents either \(\frac{\partial \mathbf{S}(u,v)}{\partial u}\) or \(\frac{\partial \mathbf{S}(u,v)}{\partial v}\) depending on which edge is selected and which value is assigned toperp.- Parameters:
edge (SurfaceEdge) – Edge along which to evaluate
n_points (int) – Number of evenly-spaced parameter locations at which to evaluate the derivative. Default: 10
perp (bool) – Whether to evaluate the cross-derivative. If
False, the derivative along the parameter direction parallel to the edge will be evaluated instead. Default:True
- Returns:
2-D array of size \(n_\text{points} \times 3\)
- Return type:
- get_parallel_degree(surface_edge: SurfaceEdge) int[source]#
Gets the degree of the curve corresponding to the input surface edge.
- Parameters:
surface_edge (SurfaceEdge) – Edge along which the parallel degree is evaluated
- Returns:
Degree parallel to the edge
- Return type:
- get_parallel_n_points(surface_edge: SurfaceEdge) int[source]#
Gets the number of control points in the parametric direction parallel to the input surface edge.
- Parameters:
surface_edge (SurfaceEdge) – Edge along which the parallel number of control points is evaluated
- Returns:
Number of control points parallel to the edge
- Return type:
- get_perpendicular_degree(surface_edge: SurfaceEdge) int[source]#
Gets the degree of the curve in the parametric direction perpendicular to the input surface edge.
- Parameters:
surface_edge (SurfaceEdge) – Edge along which the perpendicular degree is evaluated
- Returns:
Degree perpendicular to the edge
- Return type:
- get_perpendicular_n_points(surface_edge: SurfaceEdge) int[source]#
Gets the number of control points in the parametric direction perpendicular to the input surface edge.
- Parameters:
surface_edge (SurfaceEdge) – Edge along which the perpendicular number of control points is evaluated
- Returns:
Number of control points perpendicular to the edge
- Return type:
- get_point(row_index: int, continuity_index: int, surface_edge: SurfaceEdge) Point3D[source]#
Gets the point corresponding to a particular index along the edge curve with perpendicular index corresponding to the level of continuity being applied. For example, for a \(6 \times 5\) Bézier surface, the following code
p = surf.get_point(2, 1, ac.SurfaceEdge.v0)
returns the point \(\mathbf{P}_{2,1}\) and
p = surf.get_point(2, 1, ac.SurfaceEdge.u1)
returns the point \(\mathbf{P}_{6-1,2} = \mathbf{P}_{5,2}\).
See also
set_pointSetter equivalent of this method
- Parameters:
row_index (int) – Index along the surface edge control points
continuity_index (int) – Index in the parametric direction perpendicular to the surface edge. Normally either
0,1, or2surface_edge (SurfaceEdge) – Edge of the surface along which to retrieve the control point
- Returns:
Point used to enforce \(G^x\) continuity, where \(x\) is the value of
continuity_index- Return type:
- get_point_ij(row_index: int, continuity_index: int, surface_edge: ~aerocaps.geom.surfaces.SurfaceEdge) -> (<class 'int'>, <class 'int'>)[source]#
Gets the point indices corresponding to a particular index along the edge curve with perpendicular index corresponding to the level of continuity being applied.
- Parameters:
row_index (int) – Index along the surface edge control points
continuity_index (int) – Index in the parametric direction perpendicular to the surface edge. Normally either
0,1, or2surface_edge (SurfaceEdge) – Edge of the surface along which to retrieve the control point
- Returns:
Point indices used to enforce \(G^x\) continuity, where \(x\) is the value of
continuity_index- Return type:
- get_second_deriv_cp_sens_along_edge(edge: SurfaceEdge, i: int, j: int, n_points: int = 10, perp: bool = True) ndarray[source]#
Gets the sensitivity of the second \(u\)- or \(v\)-derivative along an edge with respect to control point \(\mathbf{P}_{i,j}\)
- Parameters:
edge (SurfaceEdge) – Edge along which to evaluate
i (int) – \(i\)-index of the control point
j (int) – \(j\)-index of the control point
n_points (int) – Number of evenly-spaced parameter locations at which to evaluate the derivative. Default: 10
perp (bool) – Whether to evaluate the cross-derivative. If
False, the derivative along the parameter direction parallel to the edge will be evaluated instead. Default:True
- Returns:
2-D array of size \(n_\text{points} \times 3\)
- Return type:
- get_second_derivs_along_edge(edge: SurfaceEdge, n_points: int = 10, perp: bool = True) ndarray[source]#
Evaluates the parallel or perpendicular second derivative along a surface edge at
n_pointsparameter locations. The derivative represents either \(\frac{\partial^2 \mathbf{S}(u,v)}{\partial u^2}\) or \(\frac{\partial^2 \mathbf{S}(u,v)}{\partial v^2}\) depending on which edge is selected and which value is assigned toperp.- Parameters:
edge (SurfaceEdge) – Edge along which to evaluate
n_points (int) – Number of evenly-spaced parameter locations at which to evaluate the second derivative. Default: 10
perp (bool) – Whether to evaluate the cross-derivative. If
False, the second derivative along the parameter direction parallel to the edge will be evaluated instead. Default:True
- Returns:
2-D array of size \(n_\text{points} \times 3\)
- Return type:
- get_u_or_v_given_uvxyz(u: float = None, v: float = None, uv_guess: float = 0.5, x: Length = None, y: Length = None, z: Length = None) float[source]#
Computes one parametric value given the other and a specified \(x\)-, \(y\)-, or \(z\)-location. As an example, given a
BezierSurfaceobject assigned to the variablesurf, the \(u\)-parameter corresponding to \(y=1.4\) along the \(v=0.8\) isoparametric curve can be computed usingu = surf.get_u_or_v_given_uvxyz(v=0.8, y=1.4)
Note that the inputs are keyword arguments to avoid having to specify
Nonefor each of the arguments not used.- Parameters:
u (float or None) – Value of \(u\) to solve for or specify. If left as
None, this parameter will be solved for. IfNone, \(v\) must be specified. Default:Nonev (float or None) – Value of \(v\) to solve for or specify. If left as
None, this parameter will be solved for. IfNone, \(u\) must be specified. Default:Noneuv_guess (float) – Starting guess for the unsolved \(u\) or \(v\) parameter. Default:
0.5x (Length or None) – \(x\)-location corresponding to the \(u\) or \(v\) parameter to be solved. If this value is outside the surface geometry, the root-finder will fail and an error will be raised. If unspecified, either \(y\) or \(z\) must be specified. Default:
Noney (Length or None) – \(y\)-location corresponding to the \(u\) or \(v\) parameter to be solved. If this value is outside the surface geometry, the root-finder will fail and an error will be raised. If unspecified, either \(x\) or \(z\) must be specified. Default:
Nonez (Length or None) – \(z\)-location corresponding to the \(u\) or \(v\) parameter to be solved. If this value is outside the surface geometry, the root-finder will fail and an error will be raised. If unspecified, either \(x\) or \(y\) must be specified. Default:
None
- Returns:
The value of \(u\) if \(v\) is specified or \(v\) if \(u\) is specified
- Return type:
- property m: int#
Shorthand for
degree_v- Returns:
Surface degree in the \(v\)-parametric direction
- Return type:
- property n: int#
Shorthand for
degree_u- Returns:
Surface degree in the \(u\)-parametric direction
- Return type:
- plot_control_point_mesh_lines(plot: Plotter, **line_kwargs) Actor[source]#
Plots the network of lines connecting the Bézier surface control points using the pyvista library
- Parameters:
plot –
pyvista.Plotterinstanceline_kwargs – Keyword arguments to pass to the
pyvista.Plotter.add_lines
- Returns:
The lines actor
- Return type:
pv.Actor
- plot_control_points(plot: Plotter, **point_kwargs) Actor[source]#
Plots the Bézier surface control points using the pyvista library
- Parameters:
plot –
pyvista.Plotterinstancepoint_kwargs – Keyword arguments to pass to the
pyvista.Plotter.add_points
- Returns:
The points actor
- Return type:
pv.Actor
- plot_surface(plot: Plotter, Nu: int = 50, Nv: int = 50, **mesh_kwargs) StructuredGrid[source]#
Plots the Bézier surface using the pyvista library
- Parameters:
plot –
pyvista.PlotterinstanceNu (int) – Number of points to evaluate in the \(u\)-parametric direction. Default:
50Nv (int) – Number of points to evaluate in the \(v\)-parametric direction. Default:
50mesh_kwargs – Keyword arguments to pass to
pyvista.Plotter.add_mesh
- Returns:
The evaluated Bézier surface
- Return type:
- set_point(point: Point3D, row_index: int, continuity_index: int, surface_edge: SurfaceEdge)[source]#
Sets the point corresponding to a particular index along the edge curve with perpendicular index corresponding to the level of continuity being applied. For example, for a \(6 \times 5\) Bézier surface, the following code
p = ac.Point3D.from_array(np.array([3.0, 4.0, 5.0])) surf.set_point(p, 2, 1, ac.SurfaceEdge.v0)
sets the value of point \(\mathbf{P}_{2,1}\) to \([3,4,5]^T\) and
p = ac.Point3D.from_array(np.array([3.0, 4.0, 5.0])) surf.set_point(p, 2, 1, ac.SurfaceEdge.u1)
sets the value of point \(\mathbf{P}_{6-1,2} = \mathbf{P}_{5,2}\) to \([3,4,5]^T\).
See also
get_pointGetter equivalent of this method
- Parameters:
point (Point3D) – Point object to apply at the specified indices
row_index (int) – Index along the surface edge control points
continuity_index (int) – Index in the parametric direction perpendicular to the surface edge. Normally either
0,1, or2surface_edge (SurfaceEdge) – Edge of the surface along which to retrieve the control point
- split_at_u(u0: float)[source]#
Splits the Bézier surface at \(u=u_0\) along the \(v\)-parametric direction.
- split_at_v(v0: float)[source]#
Splits the Bézier surface at \(v=v_0\) along the \(u\)-parametric direction.
- to_iges(*args, **kwargs) IGESEntity[source]#
Converts the Bézier surface to an IGES entity. To add this IGES entity to an
.igsfile, use anIGESGenerator.
- to_rational_bezier_surface() RationalBezierSurface[source]#
Converts the current non-rational Bézier surface to a rational Bézier surface by setting all weights to unity.
- Returns:
Converted surface
- Return type:
- transform(**transformation_kwargs) BezierSurface[source]#
Creates a transformed copy of the surface by transforming each of the control points
- Parameters:
transformation_kwargs – Keyword arguments passed to
Transformation3D- Returns:
Transformed surface
- Return type:
- verify_g0(other: BezierSurface, surface_edge: SurfaceEdge, other_surface_edge: SurfaceEdge, n_points: int = 10)[source]#
Verifies that two Bézier surfaces are \(G^0\)-continuous along their shared edge
- verify_g1(other: BezierSurface, surface_edge: SurfaceEdge, other_surface_edge: SurfaceEdge, n_points: int = 10)[source]#
Verifies that two Bézier surfaces are \(G^1\)-continuous along their shared edge
- verify_g2(other: BezierSurface, surface_edge: SurfaceEdge, other_surface_edge: SurfaceEdge, n_points: int = 10)[source]#
Verifies that two Bézier surfaces are \(G^2\)-continuous along their shared edge