PyTurbo Helper Functions
- pyturbo.helper.arc.arclen(x, y)[source]
Computes the length between points Inputs
x,y - this can be a list or a numpy array but not a scalar
- pyturbo.helper.arc.arclen3(x, y, z)[source]
Equally space points along a bezier curve using arc length
- class pyturbo.helper.bezier.bezier(x, y)[source]
- __equal_space__(t: ndarray, x, y)[source]
Equally space points along a bezier curve using arc length Inputs
- get_point(t, equal_space=False)[source]
Get a point or points along a bezier curve Inputs:
t - scalar, list, or numpy array equal_space - try to space points equally
- Outputs:
Bx, By - scalar or numpy array
- class pyturbo.helper.bezier.bezier3(x, y, z)[source]
- __equal_space__(t: ndarray, x: ndarray, y: ndarray, z: ndarray)[source]
Equally space points along a bezier curve using arc length
- Parameters:
t (np.ndarray) – position along bezier curve. Example: t = np.linspace(0,1,100)
x (np.ndarray) – x-coordinate as numpy array
y (np.ndarray) – y-coordinates as numpy array
z (np.ndarray) – z-coordinates as numpy array
- Returns:
- containing
x (np.ndarray): new values of x that are equally spaced
y (np.ndarray): new values of y that are equally spaced
- Return type:
(Tuple)
- get_point(t, equal_space=True)[source]
Gets the point(s) at a certain percentage along the piecewise bezier curve
- Parameters:
t (Union[List[float],float,np.ndarray]) – percentage(s) along a bezier curve. You can specify a float, List[float], or a numpy array
equal_space (bool, optional) – Equally space points using arc length. Defaults to False.
- Returns:
- containing
x (np.ndarray): x-coordinates
y (np.ndarray): y-coordinates
- Return type:
(Tuple)
- class pyturbo.helper.bezier.pw_bezier2D(array: List[bezier])[source]
- __equal_space__(t: ndarray, x: ndarray, y: ndarray)[source]
Equally space points along a bezier curve using arc length
- Parameters:
t (np.ndarray) – position along bezier curve. Example: t = np.linspace(0,1,100)
x (np.ndarray) – x-coordinate as numpy array
y (np.ndarray) – y-coordinates as numpy array
- Returns:
- containing
x (np.ndarray): new values of x that are equally spaced
y (np.ndarray): new values of y that are equally spaced
- Return type:
(Tuple)
- get_point(t: List[float] | float | ndarray, equal_space: bool = False)[source]
Gets the point(s) at a certain percentage along the piecewise bezier curve
- Parameters:
t (Union[List[float],float,np.ndarray]) – percentage(s) along a bezier curve. You can specify a float, List[float], or a numpy array
equal_space (bool, optional) – Equally space points using arc length. Defaults to False.
- Returns:
- containing
x (np.ndarray): x-coordinates
y (np.ndarray): y-coordinates
- Return type:
(Tuple)
- pyturbo.helper.bisect.bisect(func, lb, ub, tol, verbose=True, **kwargs)[source]
Bisection method, solves for 0 given a function, lower bound, upper bound inputs:
func - function handle lb - lower bound ub - upper bound tol - tolerance, when to stop the minimization *args - arguments that will be passed in addition to the function
- returns
x - value that minimizes the function flag = 1 (good,passed) -1 (max iterations reached)
- pyturbo.helper.convert_to_ndarray.convert_to_ndarray(t)[source]
converts a scalar or list to numpy array
- pyturbo.helper.csapi.csapi(x: ndarray, y: ndarray, xx: ndarray)[source]
similar to matlab’s cubic spline interpolator
- Parameters:
x (numpy.ndarray) – n x 1 array example [1,2,3,4]
y (numpy.ndarray) – n x 1 array
xx (numpy.ndarray) – n x 1 array of where you want to estimate y
- Returns:
spline estimated values where xx is specified
- Return type:
(numpy.ndarray)
- pyturbo.helper.derivative.derivative_1(t, x)[source]
derivative_1 Summary of this function goes here Detailed explanation goes here
- pyturbo.helper.derivative.derivative_2(t, x)[source]
derivative_2 Summary of this function goes here Detailed explanation goes here
- pyturbo.helper.exp_ratio.exp_ratio(ratio, npoints, maxvalue=1)[source]
Expansion Ratio Inputs:
ratio - 1 = no epxansion simple linspace 1.2 or 1.4 probably max npoints - number of points to use max - max value
- class pyturbo.helper.line2D.line2D(pt1, pt2)[source]
-
- __hash__ = None
- fillet(prev_line, filletR: float)[source]
Creates a fillet with the previous line, how the line terminates doesn’t matter inputs:
prev_line - Line2D class filletR - fillet radius
- Returns:
prev_line - previous line fillet
- get_point(t: ndarray | float)[source]
Gets the point given a value between 0 and 1
- Parameters:
t (Union[np.ndarray,float]) – numpy array linspace(0,1,10) or any float value between 0 and 1
- Returns:
either a single value or an array of values
- Return type:
Union[np.ndarray,float]
- get_points2(n: int)[source]
Get n number of points along a line
- Parameters:
n (int) – _description_
- Returns:
either a single value or an array of values
- Return type:
Union[np.ndarray,float]
- get_y(x: ndarray | float)[source]
Given an x value, output a y value
- Parameters:
x (Union[np.ndarray,float]) – any value
- Returns:
either a single value or an array of values
- Return type:
Union[np.ndarray,float]
- intersect_check(line2)[source]
Intersect check returns true if line segment ‘p1q1’ and ‘p2q2’ intersect.
- pyturbo.helper.min_max_check.create_cubic_bounding_box(xmax, xmin, ymax, ymin, zmax, zmin)[source]
Creates a cubic bounding box around a blade This is useful for plotting purposes.
- Inputs:
xmax (float) xmin (float) ymax (float) ymin (float) zmax (float) zmin (float)
- Returns:
Xb - numpy matrix Yb - numpy matrix Zb - numpy matrix
- class pyturbo.helper.pspline.pspline(px, py, pz=[], method=spline_type.pchip)[source]
Percentage Spline - fits a spline on a curve and allows you to extract points with a percentage as input
- class pyturbo.helper.pspline.pspline(px, py, pz=[], method=spline_type.pchip)[source]
Percentage Spline - fits a spline on a curve and allows you to extract points with a percentage as input
- pyturbo.helper.rotate_array_values.rotate_array_vals(array_values, rot_angle, min_max)[source]
Rotate array values by their min and max values