emopt.geometry¶
-
class
emopt.geometry.FourierDisplacer(xs, ys, Rmin)¶ Bases:
future.types.newobject.newobjectDisplace a points which define a path using a radius-of-curvature-limited Fourier series.
-
Nf¶
-
get_x(Ax)¶ Calculate the displaced x coordinates.
Parameters: Ax (numpy.ndarray) – The list of Fourier coefficients used for x displacements. This list should have length equal to Nf. Returns: The list of displaced x coordinates. Return type: numpy.ndarray
-
get_y(Ay)¶ Calculate the displaced y coordinates.
Parameters: Ay (numpy.ndarray) – The list of Fourier coefficients used for y displacements. This list should have length equal to Nf. Returns: The list of displaced y coordinates. Return type: numpy.ndarray
-
max_amplitude¶
-
periods¶
-
xs¶
-
ys¶
-
-
class
emopt.geometry.IndexSet(x, y)¶ Bases:
future.types.newobject.newobject-
append(xmin, xmax, ymin, ymax, reverse=False)¶
-
clear()¶
-
indices¶
-
remove(xmin, xmax, ymin, ymax)¶
-
x¶
-
y¶
-
-
class
emopt.geometry.NURBS(x, y, degree=3, w=None)¶ Bases:
future.types.newobject.newobjectCreate a NURBS curve.
This class wraps a NURBS-python NURBS object and provides some additional useful functionality (like radius of curvature calculation).
Notes
The underlying NURBS object can be accessed at any time using the curve attribute.
-
x¶ The x coordinates of the control points (array of size N).
Type: numpy.ndarray
-
y¶ The y coordinates of the control points (array of size N).
Type: numpy.ndarray
-
w¶ Weight values (array of size N).
Type: numpy.ndarray
-
curve¶ The wrapped NURBS object
Type: geomdl.NURBS.Curve
Parameters: - x (numpy.ndarray) – The x coordinates of the control points (array of size N).
- y (numpy.ndarray) – The y coordinates of the control points (array of size N).
- w (numpy.ndarray (optional)) – Weight values (array of size N). By default, uniform unity weights are used. (default = None)
- degree (int (optional)) – The degree of the curve. Recommended: degree >= 3 (default = 3)
-
N
-
bbox¶
-
curve
-
degree
-
evaluate(u=None, Neval=10)¶ Evaluate the NURBS curve.
The NURBS curve can be evaluated either at a single specified value or at a specified number of values which span the whole curve. If a single value is provided, then the curve is evaluated at that single point. Otherwise, the curve is evaluated at the specified Neval points.
Parameters: Returns: The x,y coordinate(s) of the evaluated curve
Return type:
-
evaluate_tangent(u=None, Neval=None)¶ Evaluate the tangent direction along the curve.
Notes
- This is the normalized first derivative of x(u) and y(u)
Returns: The tangential vectors at each point Return type: numpy.ndarray, numpy.ndarray
-
knot_vec
-
radius_of_curvature(u=None, Neval=10)¶ Evaluate the radius of curvature along the NURBS curve.
The ROC can be evaluated either at a single specified value or at a specified number of values which span the whole curve. If a single value is provided, then the ROC is evaluated at that single point. Otherwise, the curve is evaluated at the specified Neval points.
Parameters: Returns: The radius of curvature evaluated along the curve.
Return type: float or numpy.ndarray
-
set_cpoints(x, y)¶ Set new control points
Parameters: - x (numpy.ndarray) – The new x coordinates.
- y (numpy.ndarray) – The new y coordinates.
-
w
-
x
-
y
-
-
emopt.geometry.fillet(x, y, R, make_round=None, points_per_90=10, equal_thresh=1e-08, ignore_roc_lim=False, points_per_bend=None)¶ Round corners of a polygon.
This function replaces sharp corners with circular arcs. The radius of these arcs will be equal to the specified radius as long as the line segments which make up the corner are sufficiently long. If they are too short, the arc will be made with a smaller radius.
If a non-closed polygon is supplied, the end points will be ignored. A polygon is considered closed if the first and last point in the provided x,y coordinate lists are the same.
Parameters: - x (list) – The x coordinates of the chain of line segments to round.
- y (list) – The y coordinates of the chain of line segments to round.
- R (float) – The desired fillet radius
- make_round (list or None (optional)) – A list of boolean values which specifies which points should be rounded. If None, then all roundable points are rounded. If supplying a list, the list must have the same length as x and y. (default = None)
- points_per_90 (int (optional)) – The number of points to generate per 90 degrees of the arc. (default = 10)
- equal_thresh (float) – The threshold used for comparing values. If the |difference| between two values is less than this value, they are considered equal.
- points_per_bend (int (optional)) – The number of points to use to define the bend. This parameter overrides points_per_90. Use this if you need the number of points in a fillet to remain fixed regardless of the corner angle.
Returns: The x and y coordinates of the new set of lines segments or polygon.
Return type:
-
emopt.geometry.populate_lines(xs, ys, ds, refine_box=None)¶ Populate a chain of line segments with additional points.
Given a set of connected line segments, add evenly distributed points to the line segments. This is currently done in a very approximate manner.
Parameters: - xs (list or numpy.array) – The list of x coordinates of the line segments.
- ys (list or numpy.array) – The list of y coordinates of the line segments.
- ds (float) – The approximate spacing of the populated points.
- refine_box (list of tuple) – Only populate points within the box [xmin, xmax, ymin, ymax]. If None, populate all lines (default = None)
Returns: The x and y coordinates of the newly populated line segments.
Return type: numpy.array, numpy.array