PyTurbo Helper Functions

class pyturbo.helper.arc.arc(xc, yc, radius, alpha_start, alpha_stop)[source]
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

flip()[source]

Reverses the direction of the bezier curve :returns: flipped bezier curve

get_curve_length() float[source]

Gets the curve length

Returns:

curve length

Return type:

float

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

get_point_dt(t)[source]

Gets the derivative

plot2D(equal_space=False)[source]

Creates a 2D Plot of a bezier curve

Parameters:
  • equal_space (bool, optional) – Equally spaces the points using arc length. Defaults to False.

  • figure_num (int, optional) – if you want plots to be on the same figure. Defaults to None.

rotate(angle: float)[source]

Rotate

Parameters:

angle (float) – _description_

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)

get_point_dt(t: float | List[float] | ndarray)[source]

Returns the derivative at a particular percentage

Parameters:

t (Union[float,List[float],np.ndarray]) – Percentage from 0 to 1

Returns:

containing
  • dx (np.ndarray): dx_dt

  • dy (np.ndarray): dy_dt

  • dz (np.ndarray): dz_dt

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]
__eq__(line2)[source]

Check if two lines are equal

Parameters:

line2 (line2D) – second line

__hash__ = None
add_length(len)[source]

Increase the length of the line by a percent

average(new_line)[source]

averages the line with another line

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

flip()[source]

reverses the direction of the line

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.

intersect_ray(r2: ray2D)[source]

INTERSECTRAY - CHECK IF A RAY WILL INTERSECT THE LINE

line_intersect(line2)[source]

line_intersect - used to be called rayintersect but that’s kind of misleading. Output changed to return the point of intersection and t1, t2

Returns [x,y,t1,t2,bIntersect]

shrink_end(shrink_len)[source]

Calculates the new end point

shrink_start(shrink_len)[source]

Calculates the new starting point

to_bezier()[source]

returns a bezier version of a line

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

__call__(t)[source]

Call self as a function.

get_point(t)[source]
Inputs:

t is from 0 to 1

Returns:

x,y,(z) of the spline curve

pyturbo.helper.pspline.convert_to_ndarray(t)[source]

converts a scalar or list to numpy array

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

__call__(t)[source]

Call self as a function.

get_point(t)[source]
Inputs:

t is from 0 to 1

Returns:

x,y,(z) of the spline curve

class pyturbo.helper.pspline.spline_type(value)[source]

An enumeration.

class pyturbo.helper.pspline.spline_type(value)[source]

An enumeration.

class pyturbo.helper.ray.ray2D(x, y, dx, dy)[source]
class pyturbo.helper.ray.ray3D(x, y, z, dx, dy, dz)[source]
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)[source]

This is used to control a wave’s starting ending location as well as invert the wave Invert - wave starts on the outside of the end points

wave_____________wave

NoInvert - wave starts between the bounds

___wave_wave___

get_wave(percent_start=0, percent_end=1, bInverse=False)[source]

Returns the wave back as a percent