PyTurbo Helper Functions
- class pyturbo.helper.arc.arc(xc: float, yc: float, radius: float, alpha_start: float, alpha_stop: float)[source]
- pyturbo.helper.arc.arclen(x: ndarray[tuple[Any, ...], dtype[_ScalarT]], y: ndarray[tuple[Any, ...], dtype[_ScalarT]]) float | ndarray[tuple[Any, ...], dtype[_ScalarT]] [source]
Calculates the arc length
- Parameters:
x (npt.NDArray) – array of x values
y (npt.NDArray) – array of y values
- Returns:
arc length
- Return type:
float
- pyturbo.helper.arc.arclen3(x: ndarray[tuple[Any, ...], dtype[_ScalarT]], y: ndarray[tuple[Any, ...], dtype[_ScalarT]], z: ndarray[tuple[Any, ...], dtype[_ScalarT]]) float | ndarray[tuple[Any, ...], dtype[_ScalarT]] [source]
Computes the arc length in 3D
- Parameters:
x (npt.NDArray) – array of x values
y (npt.NDArray) – array of y values
z (npt.NDArray) – array of z values
- Returns:
arc length
- Return type:
Union[float,npt.NDArray]
- class pyturbo.helper.bezier.bezier(x: List[float] | ndarray[tuple[Any, ...], dtype[_ScalarT]], y: List[float] | ndarray[tuple[Any, ...], dtype[_ScalarT]])[source]
- __call__(t: float | ndarray[tuple[Any, ...], dtype[_ScalarT]], equally_space_pts: bool = False)[source]
Call self as a function.
- flip()[source]
Reverses the direction of the bezier curve
- Returns:
flipped bezier curve
- Return type:
- get_point(t: float | ndarray[tuple[Any, ...], dtype[_ScalarT]] | List[float], equally_space_pts: bool = False) Tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]]] [source]
Get a point or points along a bezier curve
- Parameters:
t (Union[float,npt.NDArray]) – scalar, list, or numpy array
equally_space_pts (bool, optional) – True = space points equally. Defaults to False.
- Returns:
containing x and y points
- Return type:
Tuple
- get_point_dt(t: float | ndarray[tuple[Any, ...], dtype[_ScalarT]])[source]
Gets the derivative dx,dy as a function of t
- Parameters:
t (Union[np.ndarray]) – Array or float from 0 to 1
- Returns:
containing
dx (npt.NDArray): Derivative of x as a function of t dy (npt.NDArray): Derivative of y as a function of t
- Return type:
tuple
- class pyturbo.helper.bezier.bezier3(x, y, z)[source]
- __call__(t: float | ndarray[tuple[Any, ...], dtype[_ScalarT]], equally_space_pts: bool = False)[source]
Call self as a function.
- get_point(t: float | ndarray[tuple[Any, ...], dtype[_ScalarT]], equally_space_pts=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)
- get_point_dt(t: float | ndarray[tuple[Any, ...], dtype[_ScalarT]])[source]
Gets the derivative dx,dy as a function of t
- Parameters:
t (Union[float,npt.NDArray]) – Array or float from 0 to 1
- Returns:
containing
dx (npt.NDArray): Derivative of x as a function of t dy (npt.NDArray): Derivative of y as a function of t dz (npt.NDArray): Derivative of z as a function of t
- Return type:
tuple
- class pyturbo.helper.bezier.pw_bezier2D(array: List[bezier])[source]
- get_point(t: List[float] | float | ndarray, equally_space_pts: 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
equally_space_pts (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: float, ub: float, tol: float = 1e-05, verbose: bool = 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: float | ndarray[tuple[Any, ...], dtype[_ScalarT]] | List[float]) ndarray[tuple[Any, ...], dtype[_ScalarT]] [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: float, npoints: int, maxvalue: float = 1, flip_direction: bool = False) ndarray[tuple[Any, ...], dtype[_ScalarT]] [source]
_summary_
- Parameters:
ratio (float) – _description_
npoints (int) – _description_
maxvalue (float, optional) – _description_. Defaults to 1.
flip_direction (bool, optional) – _description_. Defaults to False.
- Returns:
_description_
- Return type:
_type_
- class pyturbo.helper.line2D.line2D(pt1: Tuple[float, float], pt2: Tuple[float, float])[source]
-
- __hash__ = None
- add_length(len: float)[source]
_Increase the length of the line
- Parameters:
len (float) – new length
- angle_between(line2) float [source]
Returns the angle between two lines
- Parameters:
line2 (line2D) – another line
- Returns:
angle between two lines in degrees
- Return type:
float
- average(new_line)[source]
Averages the line with another line
- Parameters:
new_line (line2D) – new line
- fillet(prev_line, filletR: float) Tuple[bezier, bezier] [source]
Creates a fillet with the previous line, how the line terminates doesn’t matter
- 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_t(length: float) float | ndarray[tuple[Any, ...], dtype[_ScalarT]] [source]
Returns the t that give a certain length
- Parameters:
length (float) – length of line
- Returns:
time
- Return type:
Union[float, npt.NDArray]
- 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) bool [source]
Checks for intersection with another line
- Parameters:
line2 (line2D) – another line
- Returns:
True - intersects, False - no intersection
- Return type:
bool
- intersect_ray(r2: ray2D)[source]
Check if ray will intersect
- Parameters:
r2 (ray2D) – ray
- Returns:
t (float): t value of ray bIntersect (bool): True = intersect, False, no intersection
- Return type:
Tuple containing
- line_intersect(line2) bool [source]
Checks if two lines intersect
- Parameters:
line2 (line2D) – another line
- Returns:
True if intersect
- Return type:
(bool)
- shrink_end(shrink_len: float)[source]
Calculates new end point by shrinking hte line
- Parameters:
shrink_len (float) – amount to shrink the line by
- 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: ndarray[tuple[Any, ...], dtype[_ScalarT]] | List[float], py: ndarray[tuple[Any, ...], dtype[_ScalarT]] | List[float], pz: ndarray[tuple[Any, ...], dtype[_ScalarT]] | List[float] | None = [], method=spline_type.pchip)[source]
fits a spline on a curve and allows you to extract points with a percentage as input
- get_point(t: float | List[float] | ndarray[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[_ScalarT]] [source]
Gets the points anywhere along the spline
- Parameters:
t (Union[float,List[float]]) – array or float from 0 to 1
- Returns:
(npt.NDArray): x,y,z value of the spline (npt.NDArray): dudt - derivative with time
- Return type:
Tuple containing
- class pyturbo.helper.pspline.pspline(px: ndarray[tuple[Any, ...], dtype[_ScalarT]] | List[float], py: ndarray[tuple[Any, ...], dtype[_ScalarT]] | List[float], pz: ndarray[tuple[Any, ...], dtype[_ScalarT]] | List[float] | None = [], method=spline_type.pchip)[source]
fits a spline on a curve and allows you to extract points with a percentage as input
- get_point(t: float | List[float] | ndarray[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[_ScalarT]] [source]
Gets the points anywhere along the spline
- Parameters:
t (Union[float,List[float]]) – array or float from 0 to 1
- Returns:
(npt.NDArray): x,y,z value of the spline (npt.NDArray): dudt - derivative with time
- Return type:
Tuple containing
- class pyturbo.helper.ray.ray2D(x, y, dx, dy)[source]
- perpendicular(x: float | ndarray[tuple[Any, ...], dtype[_ScalarT]], y: float | ndarray[tuple[Any, ...], dtype[_ScalarT]])[source]
this function finds the t where the ray is perpendicular to a point given a point in space
- Parameters:
x (float) – x coordinate of a point
y (float) – y coordinate of a point
- pyturbo.helper.rotate_array_values.rotate_array_vals(array_values, rot_angle, min_max)[source]
Rotate array values by their min and max values
- class pyturbo.helper.wave.wave_control(wave_array: List[float])[source]
This is used to control a wave’s starting ending location as well as invert the wave
- get_wave(percent_start=0, percent_end=1, bInverse=False)[source]
Get the normalized value of the waves
- Parameters:
percent_start (int, optional) – _description_. Defaults to 0.
percent_end (int, optional) – _description_. Defaults to 1.
bInverse (bool, optional) – True - wave starts on the outside of the end points. False - wave starts between the bounds. Defaults to False.
- Returns:
array containing the wave
- Return type:
npt.NDArray