py_gearworks package
Module contents
Submodules
py_gearworks.curve module
Module for representing curves in 3D space.
- class py_gearworks.curve.Curve(curve_function, active=True, t0=0.0, t1=1.0, params=None, enable_vectorize=True, lenght_approx_ndiv=21)[source]
Bases:
objectA class to represent a curve in space.
Calling a Curve object with a parameter (s) will return the point on the curve at that parameter. The parameter (s) is in the range [0, 1] and is lenght-equalized, meaning equally distributed (s) values will result in (approximately) equally distanced points in space. s=0 is considered the start and s=1 is considered the end of the curve. Extrapolation outside this range is possible, but not recommended.
- Parameters:
curve_function (callable) –
- curve_function
The mathematical function to generate curve points. Has to have 1 input argument, but can have multiple keyword arguments. Has to return one or more points in 3D space. Points has to correspond to the input argument.
- Type:
callable
- enable_vectorize
Vectorize feature is used to iterate over np.array inputs, to eg. generate 100 points on the curve with np.linspace. If curve_function already handles array inputs (common for numpy functions), this can be disabled.
- Type:
- update_lengths()[source]
Update the length of the curve and the length-proportional parameter lookup.
- derivative(t, direction=0, n=1, delta=1e-06)[source]
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- set_start_and_end_on(s0, s1)[source]
Set the start and end of the curve in length-proportional parameter s.
- property is_closed
Property to check if the curve starts and ends on the same point.
- class py_gearworks.curve.CurveChain(*curves, active=True, **kwargs)[source]
Bases:
CurveA class to represent a kind of polyline made up of Curves. Also can behave like a Curve.
- Parameters:
curves (Curve) –
- property active
A CurveChain is active if its own _active attribute is True and has at least 1 subcurve that is active.
- property active_list
List of active statuses of the curves in the chain.
- update_lengths()[source]
Update the length of the curve and the length-proportional parameter lookup.
- property num_curves
- property length_array
Return the lengths of each curve in the chain in an array.
- property length
- property idx_active_min
Find the first active curve in the chain.
- property idx_active_max
Find the last active curve in the chain.
- get_length_portions()[source]
Return an array of lenght-parameters of the curve starting and ending points.
- get_curves(lerp_inactive=False)[source]
Return the list of curves in the chain. Flattens the array structure if there are nested chains.
- set_start_and_end_on(s0, s1, preserve_inactive_curves=False)[source]
Set the start and end of the chain in length-proportional parameter s.
- Parameters:
s0 (float) – Start of the chain in length-proportional parameter s.
s1 (float) – End of the chain in length-proportional parameter s.
preserve_inactive_curves (bool) – If True, curves that are not part of the range will remain in the curves array of the chain, with active=False status. If False, curves outside of the range get removed.
- set_start_on(s0, preserve_inactive_curves=False)[source]
Set the start of the chain in length-proportional parameter s.
- Parameters:
s0 (float) – Start of the chain in length-proportional parameter s.
s1 (float) – End of the chain in length-proportional parameter s.
preserve_inactive_curves (bool) – If True, curves that are not part of the range will remain in the curves array of the chain, with active=False status. If False, curves outside of the range get removed.
- set_end_on(s1, preserve_inactive_curves=False)[source]
Set the end of the chain in length-proportional parameter s.
- Parameters:
s0 (float) – Start of the chain in length-proportional parameter s.
s1 (float) – End of the chain in length-proportional parameter s.
preserve_inactive_curves (bool) – If True, curves that are not part of the range will remain in the curves array of the chain, with active=False status. If False, curves outside of the range get removed.
- fillet_at_locations(radius, locations=[0.5, 0.6])[source]
Add a fillet (tangent arc) to the curve chain near the specified locations.
Suitable points for tangent arc are searched with starting points at the specified locations.
- fillet(radius, location=0.5)[source]
Add a fillet (tangent arc) to the curve chain at the specified location.
Suitable points for tangent arc are searched with starting points at the specified single location.
- property continuity_list
A list of booleans showing if the curves in the chain are continuous with each other.
The last value shows if the curve is closed (continuity between last and first curve). Inactive curves count as continuous.
- property is_continuous
- property is_closed
Property to check if the curve starts and ends on the same point.
- copy()
Deepcopy of the curve
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- class py_gearworks.curve.IntersectMethod(value)[source]
Bases:
EnumAn enumeration.
- EQUALITY = 1
- MINDISTANCE = 2
- py_gearworks.curve.find_curve_intersect(curve1, curve2, guess=[0.5, 0.5], method=IntersectMethod.EQUALITY)[source]
Find the intersection point of two curves.
- Parameters:
curve1 (Curve) –
curve2 (Curve) –
method (IntersectMethod) –
- py_gearworks.curve.find_curve_line_intersect(curve, offset=array([0., 0., 0.]), line_direction=array([1., 0., 0.]), guess=0)[source]
Find the intersection point of a curve and a line.
- py_gearworks.curve.find_curve_plane_intersect(curve, plane_normal=array([0., 0., 1.]), offset=array([0., 0., 0.]), guess=0, method=IntersectMethod.EQUALITY)[source]
Find the intersection point of a curve and a plane.
- py_gearworks.curve.find_curve_nearest_point(curve, point, guesses=[0.5])[source]
Find the curve parameter where the curve is closest to a point.
- Parameters:
curve (Curve) –
- py_gearworks.curve.fit_bezier_hermite_cubic(target_curve)[source]
Fit a cubic bezier curve to a curve using Hermite interpolation.
- Parameters:
target_curve (Curve) –
- py_gearworks.curve.fit_bezier_hermite_quadratic(target_curve)[source]
Fit a quadratic bezier curve to a curve using Hermite interpolation.
- Parameters:
target_curve (Curve) –
- py_gearworks.curve.fit_nurb_points(target_points, n_points=4, force_2D=False, initpoints=None)[source]
- Parameters:
target_points (ndarray) –
- py_gearworks.curve.fit_nurb_optim(target_curve, n_points=4, force_2D=False, samp_ratio=1.5, initguess=None)[source]
- Parameters:
target_curve (Curve) –
- py_gearworks.curve.convert_curve_nurbezier(input_curve, skip_inactive=True, **kwargs)[source]
Convert a curve to a NURBS curve.
If the input is a single Curve, it is converted to a NURB curve. If the input is a CurveChain, it is converted to NURBS. If the input is an arc (ArcCurve) shorter tha 180deg, it is converted to a 3-point NURB with exact solution. If the input is a LineCurve, it is converted to a 2-point NURB. Otherwise conversion is done via approximation using optimization.
- Parameters:
input_curve (Curve) –
- py_gearworks.curve.calc_tangent_arc(curve1, curve2, radius, start_locations=[1, 0], method=IntersectMethod.EQUALITY)[source]
- py_gearworks.curve.fillet_curve(input_curves, radius, start_locations=[0.5, 0.5])[source]
- Parameters:
input_curves (CurveChain) –
radius (float) –
- py_gearworks.curve.curve_index(curve, center=array([0., 0., 0.]), n_points=1000)[source]
Calculate the index (winding number) of a curve around a point or points.
- Parameters:
curve (Curve) –
center (ndarray) –
- class py_gearworks.curve.LineCurve(p0=array([0., 0., 0.]), p1=array([0., 0., 0.]), active=True, enable_vectorize=False)[source]
Bases:
CurveClass to represent a line as a Curve.
- update_lengths()[source]
Update the length of the curve and the length-proportional parameter lookup.
- set_start_and_end_on(s0, s1)[source]
Set the start and end of the curve in length-proportional parameter s.
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- class py_gearworks.curve.ArcCurve(radius=1.0, angle=1.5707963267948966, center=array([0., 0., 0.]), yaw=0.0, pitch=0.0, roll=0.0, active=True)[source]
Bases:
CurveClass to represent an arc as a Curve.
- update_lengths()[source]
Update the length of the curve and the length-proportional parameter lookup.
- property radius
- property r
- property angle
- property center
- property p0
- property p1
- property curvature
- property revolutions
- property axis
- property roll
- property pitch
- property yaw
- property rotmat
- classmethod from_2_point_center(p0=array([1., 0., 0.]), p1=array([0., 1., 0.]), center=array([0., 0., 0.]), revolutions=0, active=True)[source]
- classmethod from_2_point_curvature(p0=array([1., 0., 0.]), p1=array([0., 1., 0.]), curvature=1, axis=array([0., 0., 1.]), revolutions=0, active=True)[source]
- classmethod from_point_center_angle(p0=array([1., 0., 0.]), center=array([0., 0., 0.]), angle=1.5707963267948966, axis=array([0., 0., 1.]), active=True)[source]
- classmethod from_radius_center_angle(radius=1, center=array([0., 0., 0.]), angle_start=0.0, angle_end=1.5707963267948966, axis=array([0., 0., 1.]), active=True)[source]
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1)
Set the end of the curve in length-proportional parameter s.
- set_start_and_end_on(s0, s1)
Set the start and end of the curve in length-proportional parameter s.
- set_start_on(s0)
Set the start of the curve in length-proportional parameter s.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- class py_gearworks.curve.InvoluteCurve(r=1, t0=0, t1=1, angle=0, v_offs=array([0., 0., 0.]), z_offs=0, active=True, enable_vectorize=True)[source]
Bases:
CurveClass to represent an involute curve as a Curve.
- property base_radius
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1)
Set the end of the curve in length-proportional parameter s.
- set_start_and_end_on(s0, s1)
Set the start and end of the curve in length-proportional parameter s.
- set_start_on(s0)
Set the start of the curve in length-proportional parameter s.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- update_lengths()
Update the length of the curve and the length-proportional parameter lookup.
- class py_gearworks.curve.SphericalInvoluteCurve(r=1, t0=0, t1=1, angle=0, c_sphere=1, v_offs=array([0., 0., 0.]), z_offs=0, active=True, enable_vectorize=True)[source]
Bases:
CurveClass to represent a spherical involute curve as a Curve.
- property center
- property center_sphere
- property R
- property base_radius
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1)
Set the end of the curve in length-proportional parameter s.
- set_start_and_end_on(s0, s1)
Set the start and end of the curve in length-proportional parameter s.
- set_start_on(s0)
Set the start of the curve in length-proportional parameter s.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- update_lengths()
Update the length of the curve and the length-proportional parameter lookup.
- class py_gearworks.curve.OctoidCurve(r=1.0, t0=0.0, t1=1.0, angle=0.0, c_sphere=1.0, alpha=0.3490658503988659, v_offs=array([0., 0., 0.]), z_offs=0.0, active=True, enable_vectorize=True)[source]
Bases:
Curve- property center
- property center_sphere
- property R
- property base_radius
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1)
Set the end of the curve in length-proportional parameter s.
- set_start_and_end_on(s0, s1)
Set the start and end of the curve in length-proportional parameter s.
- set_start_on(s0)
Set the start of the curve in length-proportional parameter s.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- update_lengths()
Update the length of the curve and the length-proportional parameter lookup.
- class py_gearworks.curve.TransformedCurve(transform, curve, t0=0, t1=1, params=None, enable_vectorize=False, active=True)[source]
Bases:
CurveClass for applying simple transformations to a Curve and using the result as a Curve.
- Parameters:
transform (callable) –
curve (Curve) –
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1)
Set the end of the curve in length-proportional parameter s.
- set_start_and_end_on(s0, s1)
Set the start and end of the curve in length-proportional parameter s.
- set_start_on(s0)
Set the start of the curve in length-proportional parameter s.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- update_lengths()
Update the length of the curve and the length-proportional parameter lookup.
- class py_gearworks.curve.MirroredCurve(curve, plane_normal=array([1., 0., 0.]), center=array([0., 0., 0.]))[source]
Bases:
TransformedCurveClass for mirroring a Curve across a plane.
- Parameters:
curve (Curve) –
- apply_transform(point)
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1)
Set the end of the curve in length-proportional parameter s.
- set_start_and_end_on(s0, s1)
Set the start and end of the curve in length-proportional parameter s.
- set_start_on(s0)
Set the start of the curve in length-proportional parameter s.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- transformed_value(t)
- update_lengths()
Update the length of the curve and the length-proportional parameter lookup.
- class py_gearworks.curve.RotatedCurve(curve, angle=0.0, axis=array([0., 0., 1.]), center=array([0., 0., 0.]))[source]
Bases:
TransformedCurveClass for rotating a Curve around an axis.
- Parameters:
curve (Curve) –
- apply_transform(point)
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1)
Set the end of the curve in length-proportional parameter s.
- set_start_and_end_on(s0, s1)
Set the start and end of the curve in length-proportional parameter s.
- set_start_on(s0)
Set the start of the curve in length-proportional parameter s.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- transformed_value(t)
- update_lengths()
Update the length of the curve and the length-proportional parameter lookup.
- class py_gearworks.curve.NurbCurve(points, weights, active=True)[source]
Bases:
CurveClass to represent a NURB (a single piece of non-universial rational bezier) curve as a Curve.
- property n_points
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1)
Set the end of the curve in length-proportional parameter s.
- set_start_and_end_on(s0, s1)
Set the start and end of the curve in length-proportional parameter s.
- set_start_on(s0)
Set the start of the curve in length-proportional parameter s.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- update_lengths()
Update the length of the curve and the length-proportional parameter lookup.
- class py_gearworks.curve.NURBSCurve(*curves, active=True, **kwargs)[source]
Bases:
CurveChainClass to represent a NURBS curve chain as a CurveChain of NURB curves.
- Parameters:
curves (NurbCurve) –
- property n_points
- property points
- property weights
- property knots
- classmethod from_curve_chain(curve_chain)[source]
- Parameters:
curve_chain (CurveChain) –
- property active
A CurveChain is active if its own _active attribute is True and has at least 1 subcurve that is active.
- property active_list
List of active statuses of the curves in the chain.
- append(value)
- clear()
- property continuity_list
A list of booleans showing if the curves in the chain are continuous with each other.
The last value shows if the curve is closed (continuity between last and first curve). Inactive curves count as continuous.
- copy()
Deepcopy of the curve
- curve_list_eval(s)
Return the point corresponding to length-proportional parameter s.
- cut(t, preserve_inactive_curves=False)
Cut the chain at t and return two new chains.
- del_inactive_curves()
Remove inactive curves from the chain.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- extend(iterable)
- fillet(radius, location=0.5)
Add a fillet (tangent arc) to the curve chain at the specified location.
Suitable points for tangent arc are searched with starting points at the specified single location.
- fillet_at_index(radius, index)
- fillet_at_locations(radius, locations=[0.5, 0.6])
Add a fillet (tangent arc) to the curve chain near the specified locations.
Suitable points for tangent arc are searched with starting points at the specified locations.
- get_curves(lerp_inactive=False)
Return the list of curves in the chain. Flattens the array structure if there are nested chains.
- get_length_portions()
Return an array of lenght-parameters of the curve starting and ending points.
- get_s_index(s)
Find which curve index s belongs to and how far along it is in the curve.
- get_t_for_index(idx)
- property idx_active_max
Find the last active curve in the chain.
- property idx_active_min
Find the first active curve in the chain.
- insert(index, value)
- property is_closed
Property to check if the curve starts and ends on the same point.
- property is_continuous
- property length
- property length_array
Return the lengths of each curve in the chain in an array.
- property num_curves
- pop(index=-1)
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1, preserve_inactive_curves=False)
Set the end of the chain in length-proportional parameter s.
- Parameters:
s0 (float) – Start of the chain in length-proportional parameter s.
s1 (float) – End of the chain in length-proportional parameter s.
preserve_inactive_curves (bool) – If True, curves that are not part of the range will remain in the curves array of the chain, with active=False status. If False, curves outside of the range get removed.
- set_start_and_end_on(s0, s1, preserve_inactive_curves=False)
Set the start and end of the chain in length-proportional parameter s.
- Parameters:
s0 (float) – Start of the chain in length-proportional parameter s.
s1 (float) – End of the chain in length-proportional parameter s.
preserve_inactive_curves (bool) – If True, curves that are not part of the range will remain in the curves array of the chain, with active=False status. If False, curves outside of the range get removed.
- set_start_on(s0, preserve_inactive_curves=False)
Set the start of the chain in length-proportional parameter s.
- Parameters:
s0 (float) – Start of the chain in length-proportional parameter s.
s1 (float) – End of the chain in length-proportional parameter s.
preserve_inactive_curves (bool) – If True, curves that are not part of the range will remain in the curves array of the chain, with active=False status. If False, curves outside of the range get removed.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- update_lengths()
Update the length of the curve and the length-proportional parameter lookup.
- class py_gearworks.curve.CycloidCurve(rb=1, rc=1, angle=0, v_offs=array([0., 0., 0.]), z_offs=0, t0=0, t1=1, active=True, enable_vectorize=True)[source]
Bases:
CurveClass to represent a cycloid curve as a Curve.
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1)
Set the end of the curve in length-proportional parameter s.
- set_start_and_end_on(s0, s1)
Set the start and end of the curve in length-proportional parameter s.
- set_start_on(s0)
Set the start of the curve in length-proportional parameter s.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- update_lengths()
Update the length of the curve and the length-proportional parameter lookup.
- class py_gearworks.curve.CycloidConicCurve(rb=1, rc=1, angle=0, C=0.5, v_offs=array([0., 0., 0.]), z_offs=0, t0=0, t1=1, active=True, enable_vectorize=True)[source]
Bases:
CurveClass to represent a cycloid curve as a Curve.
- copy()
Deepcopy of the curve
- cut(t)
Cut the curve at t and return two new curves.
- derivative(t, direction=0, n=1, delta=1e-06)
Numerically approximate the curve gradient at t.
- Parameters:
t (float) – curve parameter where the derivative is evaluated at.
direction (int) – 1: forward, -1: backward, 0: balanced derivative.
n (int) – derivative order (n=2: second derivative, etc.) 0 and negative value (integral) does not work.
delta (float) – small value used for numeric differentiation. Hint: consider using larger deltas for higher order derivatives, it is easy to run into floating point issues even on double precision.
- get_curves()
- property is_closed
Property to check if the curve starts and ends on the same point.
- reverse()
Reverse the curve in place.
- s2t(s)
Convert length-proportional parameter s to natural parameter t.
- set_end_on(s1)
Set the end of the curve in length-proportional parameter s.
- set_start_and_end_on(s0, s1)
Set the start and end of the curve in length-proportional parameter s.
- set_start_on(s0)
Set the start of the curve in length-proportional parameter s.
- t2s(t)
Convert natural parameter t to length-proportional parameter s.
- update_lengths()
Update the length of the curve and the length-proportional parameter lookup.
- property R
py_gearworks.defs module
- py_gearworks.defs.ORIGIN = array([0., 0., 0.])
The center of the coordinate system.
- py_gearworks.defs.UP = array([0., 1., 0.])
One unit step in the positive Y direction.
- py_gearworks.defs.DOWN = array([ 0., -1., 0.])
One unit step in the negative Y direction.
- py_gearworks.defs.RIGHT = array([1., 0., 0.])
One unit step in the positive X direction.
- py_gearworks.defs.LEFT = array([-1., 0., 0.])
One unit step in the negative X direction.
- py_gearworks.defs.IN = array([ 0., 0., -1.])
One unit step in the negative Z direction.
- py_gearworks.defs.OUT = array([0., 0., 1.])
One unit step in the positive Z direction.
py_gearworks.function_generators module
- py_gearworks.function_generators.involute_func(t, r, a=0, rad_offs=0, tan_offs=0, z_offs=0, csph=0)[source]
Returns the x-y-z values of the involute function. t: input angle r: base circle radius a: offset angle, angle of the starting point of the involute on the base circle rad_offs, tan_offs: radial and tangential offset values to generate the trochoid of the undercut curve. csph: curvature of spherical involute for bevel gears. Zero curvature means straight (spur) gear.
- py_gearworks.function_generators.involute_circle(t, r=1, angle=0, v_offs=array([0., 0., 0.]), z_offs=0)[source]
Returns the x-y-z values of the involute function. t: input angle r: base circle radius a: offset angle, angle of the starting point of the involute on the base circle v_offs: offset vector used for trochoid (undercut) curve generation. The offset rotates with the tangent line of the involute. z_offs: offset value applied in the z direction
- py_gearworks.function_generators.involute_sphere(t, r=1, C=0.5, angle=0, v_offs=array([0., 0., 0.]), z_offs=0)[source]
Returns the x-y-z values of the involute function. The base circle is positioned in the x-y plane, the spherical center is placed in the positive Z direction for positive C values. t: input angle r: base circle radius C: spherical curvature. C=1/R, R is the sphere radius. Curvature is used for supporting C==0 or infinite R, reverting to circle invoulte. Negative values result in a cone with a center in negative Z direction. abs(C)<=1/r should be kept. a: offset angle, angle of the starting point of the involute on the base circle v_offs: offset vector used for trochoid (undercut) curve generation. The offset rotates with the tangent line of the involute. z_offs: offset value applied in the z direction
- py_gearworks.function_generators.cycloid_circle(t, rb=1, rc=1, angle=0, v_offs=array([0., 0., 0.]), z_offs=0)[source]
Returns the x-y-z values of the cycloid function.
The cycloid is calculated for a circle of rc rolling on the outside of a circle of rb. If negative radius is supplied for rc, the circle rolls on the inside of the base circle.
t: input angle rb: base circle radius rc: rolling circle radius a: offset angle, angle of the starting point of the involute on the base circle v_offs: offset vector used for trochoid curve generation. The offset rotates with the rolling circle. z_offs: offset value applied in the z direction
- py_gearworks.function_generators.cycloid_line(t, rc=1, angle=0, v_offs=array([0., 0., 0.]), z_offs=0)[source]
- py_gearworks.function_generators.cycloid_cone(t, rb=1, rc=1, C=0.5, angle=0, v_offs=array([0., 0., 0.]), z_offs=0)[source]
Returns the x-y-z values of the cycloid function. The base circle is positioned in the x-y plane, the spherical center is placed in the positive Z direction for positive C values. t: input angle rb: base circle radius rc: rolling circle radius C: spherical curvature. C=1/R, R is the sphere radius. Curvature is used for supporting C==0 or infinite R, reverting to circle cycloid. Negative values result in a cone with a center in negative Z direction. abs(C)<=1/rb should be kept. a: offset angle, angle of the starting point of the involute on the base circle v_offs: offset vector used for trochoid curve generation. The offset rotates with the tangent line of the involute. z_offs: offset value applied in the z direction
- py_gearworks.function_generators.arc_from_2_point(t, p0=array([1., 0., 0.]), p1=array([0., 1., 0.]), curvature=1.0, axis=array([0., 0., 1.]), revolutions=0.0)[source]
- py_gearworks.function_generators.arc_from_2_point_center(t, p0=array([1., 0., 0.]), p1=array([0., 1., 0.]), center=array([0., 0., 0.]), revolutions=0.0)[source]
- py_gearworks.function_generators.bezierdc(t, points)[source]
Bezier curve evaluation using decasteljau algorithm. Works faster for arrays of t than iterating naive Bezier algorithm with bernstein polynomials. t: float or np 1darray points: 2d array of control points
- Parameters:
points (ndarray) –
- Return type:
ndarray
- py_gearworks.function_generators.nurbezier_diff_t(t, points, weights)[source]
Derivative of a NURB segment by t
- py_gearworks.function_generators.bezier_diff_p(t, n)[source]
The coefficients of points for a bezier same as differentiation by points
- py_gearworks.function_generators.nurbezier_diff_points(t, n, weights)[source]
the derivative of a nurb segment by points
- py_gearworks.function_generators.nurbezier_diff_weights(t, points, weights)[source]
Derivative of a NURB segment by weights
- py_gearworks.function_generators.xyz_to_spherical(v, center=array([0., 0., 0.]))[source]
Convert to spherical coordinates. Spherical center can be set as kwarg. Zero angles are at the north pole and along the x axis. Returns: r: radius, phi: azimuth angle (rotation around z), theta: polar angle (altitude angle)
- py_gearworks.function_generators.spherical_to_xyz(s, center=array([0., 0., 0.]))[source]
Convert to cartesian coordinates. Spherical center can be set as kwarg. Zero angles are at the north pole and along the x axis. Input convention: s= [r, phi, theta] (radius, azimuth angle, polar angle) Returns: x, y, z coordinates
- py_gearworks.function_generators.xyz_to_cylindrical(v, center=array([0., 0., 0.]))[source]
Convert to cylindrical coordinates. Cylindrical center can be set as kwarg. Zero angles are at the x axis. Returns: r: radius, phi: azimuth angle (rotation around z), z: height
- py_gearworks.function_generators.cylindrical_to_xyz(c, center=array([0., 0., 0.]))[source]
Convert to cartesian coordinates. Cylindrical center can be set as kwarg. Zero angles are at the x axis. Input convention: c= [r, phi, z] Returns: x, y, z coordinates
py_gearworks.conv_build123d module
Copyright 2024 Gergely Bencsik Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- class py_gearworks.conv_build123d.GearBuilder(gear, n_points_hz=4, n_points_vert=4, oversampling_ratio=3, side_surface_extension_ratio=0.01)[source]
Bases:
GearToNurbsA class for building build123d Part objects from gear profiles.
The class inherits from GearToNurbs, which is responsible for generating the NURBS surface points and weights, this class is responsible for converting to build123d. Conversion happens in a reference space, with scaling of 1 (module of 1) and on the XY plane, default orientation. A transformation is applied after conversion to represent the final part.
- Parameters:
gear (pgw.Gear) – The gear object to build.
n_points_hz (int, optional) – Number of points used for spline approximation for each segment of the 2D gear profile that is not a line or an arc. Lines and arcs use exact NURB representation with 2 and 3 points, respectively. The default is 4.
n_points_vert (int, optional) – Number of 2D profile slices used for generating 3D surfaces. The default is 4.
oversampling_ratio (float, optional) – Ratio of the number of evaluations of analytical functions to the number of unknown points in spline approximation. Affects both horizontal points and vertical slices. For spline approximation, the endpoints are fixed, so the unkown points are the mid-points. Minimum value is 2, the default is 3. When fractional, the number of evaluations is rounded up. Example: for a 3-point spline and oversampling of 3, the unkown point is the middle one, the number of evaluations are the 2 end points + 3 in the middle, so 5 in total.
side_surface_extension_ratio (float) –
- generate_cover(nurb_stack, gear_stack)[source]
- Parameters:
nurb_stack (GearRefProfileExtended) –
gear_stack (GearRefProfileExtended) –
- generate_gear_stacks()
- Return type:
- generate_nurbs()
- generate_surface_points_sides()
- solve_surface(target_points, n_points_vert=4, t_weight=0.01, init_points=None)
- solve_surface_fast(target_points, n_points_vert=4)
- class py_gearworks.conv_build123d.GearBuilder_old(gear, n_points_hz=4, n_points_vert=4, oversampling_ratio=2.5, add_plug=False)[source]
Bases:
GearToNurbsA class for building Part objects from gear profiles.
- Parameters:
gear (Gear) –
- generate_gear_stacks()
- Return type:
- generate_nurbs()
- generate_surface_points_sides()
- solve_surface(target_points, n_points_vert=4, t_weight=0.01, init_points=None)
- solve_surface_fast(target_points, n_points_vert=4)
- py_gearworks.conv_build123d.apply_transform_part(part, transform)[source]
- Parameters:
part (Part) –
transform (GearTransform) –
- py_gearworks.conv_build123d.transform2Location(transform)[source]
- Parameters:
transform (GearTransform) –
- py_gearworks.conv_build123d.generate_boundary_edges(nurbprofile, transform=None, angle_range=6.283185307179586)[source]
- Parameters:
nurbprofile (GearRefProfile) –
transform (GearTransform | None) –
angle_range (float) –
- py_gearworks.conv_build123d.arc_to_b123d(arc)[source]
Converts a py_gearworks ArcCurve to a build123d Edge object.
- Parameters:
arc (ArcCurve) –
- Return type:
Edge
py_gearworks.conv_spline module
- class py_gearworks.conv_spline.GearToNurbs(gear, n_points_hz=4, n_points_vert=4, oversampling_ratio=3)[source]
Bases:
objectA class to manage the conversion of gear profile curves into NURBS surfaces.
- Parameters:
gear (pgw.Gear) – The gear object to build.
n_points_hz (int, optional) – Number of points used for spline approximation for each segment of the 2D gear profile that is not a line or an arc. Lines and arcs use exact NURB representation with 2 and 3 points, respectively. The default is 4.
n_points_vert (int, optional) – Number of 2D profile slices used for generating 3D surfaces. The default is 4.
oversampling_ratio (float, optional) – Ratio of the number of evaluations of analytical functions to the number of unknown points in spline approximation. Affects both horizontal points and vertical slices. For spline approximation, the endpoints are fixed, so the unkown points are the mid-points. Minimum value is 2, the default is 3. When fractional, the number of evaluations is rounded up. Example: for a 3-point spline and oversampling of 3, the unkown point is the middle one, the number of evaluations are the 2 end points + 3 in the middle, so 5 in total.
- class py_gearworks.conv_spline.NurbSurfaceData(points, weights, knots, n_points_vert=4)[source]
Bases:
objectDataclass for storing surface data of b-spline strips.
- Parameters:
points (ndarray) –
weights (ndarray) –
knots (ndarray) –
n_points_vert (int) –
- points: ndarray
- weights: ndarray
- knots: ndarray
- py_gearworks.conv_spline.gearprofile_to_nurb(gearprofile, n_points=4, oversamp_ratio=2, pad_inactive=False)[source]
- Parameters:
gearprofile (GearRefProfile) –
pad_inactive (bool) –
py_gearworks.core module
- class py_gearworks.core.GearPolarTransform(cone_angle=0, base_radius=1)[source]
Bases:
ConicDataCallable class for polar transformation of points.
Uses a cylindric transform for 0 cone angle, otherwise spherical polar transform.
- transform: TransformData
- polar_transform(point)[source]
Return polar coordinates helpful for gear generation.
- Parameters:
point (np.ndarray) – A 3D point to be transformed.
- Returns:
The transformed point in polar coordinates. Convention: [out - angle - height] “out” is the quasi radial coordinate, the gear teeth grow in this direction. “angle” is the angle around the gear. “height” is the 3rd direction, typically the extrusion direction.
- Return type:
np.ndarray
- circle_from_point(point)[source]
Generate a circle aligned with the cone axis, at the given point.
- Parameters:
point (ndarray) –
- Return type:
- great_circle_from_point(point)[source]
Generate a great circle (centered at cone center) at the given point.
- Parameters:
point (ndarray) –
- Return type:
- property R
- property center
Spherical center (tip) of the cone.
- property center_base
Center of the base circle of the cone.
- property center_untransformed
Spherical center (tip) of the cone without transformation.
- property gamma
- property height
- property r
- property spherical_radius
Radius of the sphere that is concentric with the cone and contains the base circle. Always positive.
- property spherical_radius_untransformed
Radius of the sphere that is concentric with the cone and contains the base circle without transformation. Always positive.
- class py_gearworks.core.FilletParam(tip_fillet=0.0, root_fillet=0.0, tip_reduction=0.0)[source]
Bases:
objectData class for tooth tip and root modification parameters.
- py_gearworks.core.generate_reference_circles(pitch_radius, limitparam, coneparam)[source]
Generates reference circles as Curve objects for a gear tooth.
- Parameters:
limitparam (ToothLimitParam) –
coneparam (GearPolarTransform) –
- Return type:
GearRefCircles
- py_gearworks.core.generate_reference_lines(limitparam)[source]
- Parameters:
limitparam (ToothLimitParam) –
- Return type:
RackRefLines
- py_gearworks.core.apply_tip_reduction(tooth_curve, addendum_height, dedendum_height, tip_reduction, polar_transformer)[source]
Apply tip reduction feature and return radius.
Checks if tip reduction is necessary (due to sharp point tip) and returns the reduced addendum radius to be used for truncated tip.
- Returns:
The reduced addendum radius.
- Return type:
- Parameters:
tooth_curve (CurveChain) –
addendum_height (float) –
dedendum_height (float) –
tip_reduction (float) –
polar_transformer (GearPolarTransform) –
- py_gearworks.core.apply_fillet(tooth_curve, pitch_angle, target_circle, fillet_radius, direction=1)[source]
Apply fillet to the tooth curve.
- Parameters:
tooth_curve (crv.CurveChain) – The tooth curve to be filleted.
pitch_angle (float) – The pitch angle of the gear in radians.
target_circle (crv.ArcCurve) – The circle to be filleted to. Either addendum or dedendum circle.
fillet_radius (float) – The radius of the fillet.
direction (int) – Use -1 for tip fillet, 1 for root fillet.
- Return type:
- class py_gearworks.core.GearRefProfile(ra_curve, rd_curve, ro_curve, tooth_curve, tooth_curve_mirror, pitch_angle, transform)[source]
Bases:
objectData class collecting all curve segments for a single tooth’s profile.
This class should contain all data necessary to construct a single tooth’s profile, which is 1 unit of the repeating pattern making up the gear.
- Parameters:
- tooth_curve_mirror: MirroredCurve
- transform: GearTransform
- property profile
- class py_gearworks.core.GearRefProfileExtended(ra_curve, rd_curve, ro_curve, tooth_curve, tooth_curve_mirror, pitch_angle, transform, ro_connector_0, ro_connector_1, ro_connector_2, rd_connector, ra_connector, ro_curve_tooth, ro_curve_dedendum, tooth_centerline)[source]
Bases:
GearRefProfileData class with additional curve segments around the tooth profile, such as connectors to the outside ring.
- Parameters:
ra_curve (ArcCurve) –
rd_curve (ArcCurve) –
ro_curve (ArcCurve) –
tooth_curve (Curve) –
tooth_curve_mirror (MirroredCurve) –
pitch_angle (float) –
transform (GearTransform) –
ro_connector_0 (Curve) –
ro_connector_1 (Curve) –
ro_connector_2 (Curve) –
rd_connector (Curve) –
ra_connector (Curve) –
ro_curve_tooth (Curve) –
ro_curve_dedendum (Curve) –
tooth_centerline (Curve) –
- property profile_closed
Closed curve chain that includes the tooth and the dedendum arc, returns via the outside (or inside) ring.
- property tooth_profile_closed
Closed curve chain that includes just the tooth, closes at the root of the tooth with an arc.
- property tooth_profile_closed_outer
Closed curve chain that includes just the tooth as it were part of an outside-ring gear, closing at the addendum arc.
- property tooth_profile_closed_ring
Closed curve chain that includes just the tooth, closes at the outside (or inside) ring.
- classmethod from_refprofile(profile, cone)[source]
- Parameters:
profile (GearRefProfile) –
cone (ConicData) –
- property profile
- tooth_curve_mirror: MirroredCurve
- transform: GearTransform
- py_gearworks.core.trim_reference_profile(tooth_curve, ref_curves, fillet, pitch_angle)[source]
Find intersections of tooth curve and reference curves and trim them.
- Parameters:
tooth_curve (Curve) –
ref_curves (GearRefCircles) –
fillet (FilletParam) –
pitch_angle (float) –
- Return type:
- class py_gearworks.core.GearProfileDataCollector(tooth_generator, cone, limits, pitch_angle, transform, fillet)[source]
Bases:
objectAll input data collected to be able to generate 1 reference profile for an involute gear.
- Parameters:
tooth_generator (GearToothConicGenerator) –
cone (ConicData) –
limits (ToothLimitParam) –
pitch_angle (float) –
transform (GearTransformData) –
fillet (FilletParam) –
- tooth_generator: GearToothConicGenerator
- cone: ConicData
- limits: ToothLimitParam
- transform: GearTransformData
- fillet: FilletParam
- py_gearworks.core.generate_reference_profile(inputdata)[source]
Perform all steps to generate a single tooth profile for an involute gear.
- Parameters:
inputdata (GearProfileDataCollector) –
- Return type:
- py_gearworks.core.generate_profile_extensions(profile, cone_data)[source]
Generate additional curve segments around the tooth profile, such as connectors
- Parameters:
profile (GearRefProfile) –
cone_data (ConicData) –
- Return type:
- py_gearworks.core.generate_profile_closed(profile, cone_data)[source]
Generate a closed profile for a gear tooth.
The profile contains 2 tooth flanks, 1 addendum and 1 dedendum curve segments, the outside (or inside) ring curve segment, and 2 connector curves. Ordering: dedendum->tooth->addendum->tooth_mirror->connector_1->outside_ring->connector_0.
- Parameters:
profile (GearRefProfile) –
cone_data (ConicData) –
- py_gearworks.core.generate_boundary_chain(profile, toothdata)[source]
Create gear boundary by repeating reference profile in a CurveChain.
- Parameters:
profile (GearRefProfile) –
toothdata (GearToothParam) –
- Return type:
- py_gearworks.core.generate_boundary(profile, toothdata)[source]
Create gear boundary by defining custom repeating function for the profile.
- Parameters:
profile (GearRefProfile) –
toothdata (GearToothParam) –
- Return type:
- class py_gearworks.core.GearProfileRecipe(tooth_generator, cone, limits, pitch_angle, transform, fillet)[source]
Bases:
GearProfileDataCollector,ZFunctionMixin- Parameters:
tooth_generator (GearToothConicGenerator) –
cone (ConicData) –
limits (ToothLimitParam) –
pitch_angle (float) –
transform (GearTransformData) –
fillet (FilletParam) –
- tooth_generator: GearToothConicGenerator
- cone: ConicData
- limits: ToothLimitParam
- transform: GearTransformData
- fillet: FilletParam
- class py_gearworks.core.ConicDataRecipe(cone_angle=0, base_radius=1, transform=<factory>)[source]
Bases:
ConicData,ZFunctionMixin- property R
- property center
Spherical center (tip) of the cone.
- property center_base
Center of the base circle of the cone.
- property center_untransformed
Spherical center (tip) of the cone without transformation.
- property gamma
- property height
- property r
- property spherical_radius
Radius of the sphere that is concentric with the cone and contains the base circle. Always positive.
- property spherical_radius_untransformed
Radius of the sphere that is concentric with the cone and contains the base circle without transformation. Always positive.
- transform: TransformData
- class py_gearworks.core.ToothLimitParamRecipe(h_a=1, h_d=1.2, h_o=2)[source]
Bases:
ToothLimitParam,ZFunctionMixin
- class py_gearworks.core.GearTransformRecipe(center=<factory>, orientation=<factory>, scale=1.0, angle=0)[source]
Bases:
GearTransformData,ZFunctionMixin- property affine_matrix
- property inverse
- invert()
Invert the transformation.
- property x_axis
- property y_axis
- property z_axis
- center: ndarray
- orientation: ndarray
- class py_gearworks.core.FilletDataRecipe(tip_fillet=0.0, root_fillet=0.0, tip_reduction=0.0)[source]
Bases:
FilletParam,ZFunctionMixin
- py_gearworks.core.default_gear_recipe(teeth_data, tooth_generator, cone_angle=0)[source]
This creates the default recipe for a 3D gear tooth profile.
Recipe refers to a collection of parameter-generator callable functions that describe how the tooth profile changes along the extrusion direction (z axis). This function creates a recipe considering cone angle and number of teeth.
- Parameters:
teeth_data (GearToothParam) –
tooth_generator (GearToothConicGenerator) –
cone_angle (float) –
- Return type:
- py_gearworks.core.gear_recipe_from_curve(teeth_data, tooth_generator, ref_curve, ref_curve_scaling_function=<function <lambda>>, gamma_rounding=1e-06)[source]
This creates a recipe for a 3D gear based on a reference curve that defines the path of 1 tooth.
- Parameters:
- Return type:
- class py_gearworks.core.Gear(z_vals=array([0, 1]), module=1, tooth_param=None, tooth_generator=None, shape_recipe=None, transform=None, cone=None)[source]
Bases:
objectManager class that pulls everything together to generate a 3D gear.
- Parameters:
z_vals (ndarray) –
module (float) –
tooth_param (GearToothParam) –
tooth_generator (GearToothGenerator) –
shape_recipe (GearProfileRecipe) –
transform (GearTransform) –
cone (ConicData) –
- property cone
- property rp
- property R
- property pitch_angle
- property center
- property center_sphere
py_gearworks.gearmath module
- py_gearworks.gearmath.cone_angle_from_teeth(num_teeth_1, num_teeth_2, axis_angle=1.5707963267948966)[source]
Calculate the cone angles for two bevel gears based on their number of teeth and the prescribed angle between their axes.
- Parameters:
- Returns:
Array containing the cone angles (in radians) for gear 1 and gear 2.
- Return type:
np.ndarray
- py_gearworks.gearmath.calc_involute_mesh_distance(r_base_1, r_base_2, angle_base_1, angle_base_2, pitch_angle_2, inside_ring=False, backlash=0.0)[source]
Calculate the required axial distance for two involute gears to mesh, taking into account prescribed backlash.
- Parameters:
r_base_1 (float) – Base radius of the involute curve of gear 1.
r_base_2 (float) – Base radius of the involute curve of gear 2.
angle_base_1 (float) – Angular coordinate of the base of the involute curve of gear 1 (in radians).
angle_base_2 (float) – Angular coordinate of the base of the involute curve of gear 2 (in radians).
pitch_angle_2 (float) – Pitch angle of gear 2 (in radians).
inside_ring (bool, optional) – Any of the 2 gears is an inside-ring gear, by default False
backlash (float, optional) – Prescribed backlash between the gears, by default 0.0 Backlash is defined as the distance along the line of action between the inactive flanks of the two gears. Angular backlash can be derived as backlash / base radius.
- Returns:
Dist – Required axial distance for the two gears to mesh with the specified backlash.
- Return type:
- py_gearworks.gearmath.backlash_from_ax_distance(Distance, r_base_1, r_base_2, angle_base_1, angle_base_2, pitch_angle_2, inside_ring=False)[source]
Calculate the backlash between two involute gears based on their axial distance. Inverse of calc_involute_mesh_distance.
- Parameters:
Distance (float) – Axial distance between the two gears.
r_base_1 (float) – Base radius of the involute curve of gear 1.
r_base_2 (float) – Base radius of the involute curve of gear 2.
angle_base_1 (float) – Angular coordinate of the base of the involute curve of gear 1 (in radians).
angle_base_2 (float) – Angular coordinate of the base of the involute curve of gear 2 (in radians).
pitch_angle_2 (float) – Pitch angle of gear 2 (in radians).
inside_ring (bool, optional) – Any of the 2 gears is an inside-ring gear, by default False
- Returns:
backlash – Backlash between the two gears.
- Return type:
- py_gearworks.gearmath.calc_nominal_mesh_distance(pitch_radius_1, pitch_radius_2, profile_shift_1, profile_shift_2, module, inside_ring_1=False, inside_ring_2=False)[source]
Calculate the nominal mesh distance for two gears, taking into account profile shifts and whether any gear is an inside-ring gear.
- Parameters:
pitch_radius_1 (float) – Pitch radius of gear 1.
pitch_radius_2 (float) – Pitch radius of gear 2.
profile_shift_1 (float) – Profile shift of gear 1.
profile_shift_2 (float) – Profile shift of gear 2.
module (float) – Module of the gears.
inside_ring_1 (bool, optional) – Whether gear 1 is an inside-ring gear, by default False
inside_ring_2 (bool, optional) – Whether gear 2 is an inside-ring gear, by default False
- Returns:
Distance
- Return type:
- py_gearworks.gearmath.calc_mesh_angle(geartransform_1, geartransform_2, pitch_angle_1, pitch_angle_2, gear1_inside_ring=False, gear2_inside_ring=False)[source]
Calculate the rotation angle for this gear to mesh with the other gear. A bias value can be used for positioning within backlash.
- Parameters:
geartransform_1 (GearTransform) – Transform-data of gear 1.
geartransform_2 (GearTransform) – Transform-data of gear 2.
pitch_angle_1 (float) – Pitch angle of gear 1 (in radians).
pitch_angle_2 (float) – Pitch angle of gear 2 (in radians).
gear1_inside_ring (bool, optional) – Whether gear 1 is an inside-ring gear, by default False
gear2_inside_ring (bool, optional) – Whether gear 2 is an inside-ring gear, by default False
- Returns:
angle – Rotation angle for gear 1 to mesh with gear 2 (in radians).
- Return type:
- py_gearworks.gearmath.calc_mesh_orientation(gear_1_cone_angle, gear_2_cone_angle, R, gear2, inside_ring_1=False, inside_ring_2=False, target_dir=array([1., 0., 0.]), offset=0)[source]
Calculate the orientation matrix for gear1 to mesh with gear 2. Meant ot be used with bevel gears, returns exact orientation of gear2 for cylindrical gears.
- Parameters:
gear_1_cone_angle (float) – The full cone angle of gear 1 in radians
gear_2_cone_angle (float) – The full cone angle of gear 2 in radians
R (float) – The spherical radius of bevel gears
gear2 (GearTransform) – Transform object containing the position and orientation of gear 2
inside_ring_1 (bool, optional) – Whether gear 1 is an internal ring gear, by default False
inside_ring_2 (bool, optional) – Whether gear 2 is an internal ring gear, by default False
target_dir (np.ndarray, optional) – Target direction vector for mesh alignment, by default RIGHT
offset (float, optional) – Additional angular offset for the mesh in radians, by default 0
- Returns:
3x3 orientation matrix for gear 1 to properly mesh with gear 2
- Return type:
np.ndarray
Notes
Use calc_bevel_gear_placement_vector() to get the center position for gear 1.
- py_gearworks.gearmath.calc_bevel_gear_placement_vector(target_dir_norm, cone_data_1, cone_data_2, inside_ring_1=False, inside_ring_2=False, offset=0)[source]
Calculate the center position for gear 1 to mesh with gear 2 when both gears are bevel gears.
- Parameters:
target_dir_norm (np.ndarray) – Normalized target direction vector for mesh alignment.
cone_data_1 (ConicData) – Conic data for gear 1.
cone_data_2 (ConicData) – Conic data for gear 2.
inside_ring_1 (bool, optional) – Whether gear 1 is an internal ring gear, by default False
inside_ring_2 (bool, optional) – Whether gear 2 is an internal ring gear, by default False
offset (float, optional) – Additional angular offset for the mesh in radians, by default 0
- Returns:
Center position for gear 1 to properly mesh with gear 2
- Return type:
np.ndarray
Notes
Use calc_mesh_orientation() to get the orientation matrix for gear 1.