ribbon.spiralpolar module#
Classes for spirals described by a polar equation r = f(theta).
- class ribbon.spiralpolar.SpiralPolarBase(tincr, r0)[source]#
Bases:
ABCAbstract base class for spirals with polar equation r = f(theta).
The starting point is at r =
r0and theta =t0. This need not be the origin of the spiral. The arclength s is measured from (r0,t0) in the direction of increasing radius.- Attributes:
- tincrbool
Whether radius increases with increasing theta.
- r0, t0float
The spiral curve segment begins at (r = r0, theta = t0).
Methods
Returns the radial coordinates corresponding to the arclengths.
arclength_to_theta(s[, s0, t0])Returns the angular coordinates corresponding to the arclengths.
get_arclength(v[, var, v0])Returns the arclength at the given values of polar coordinates.
get_cart_coords(v[, var])Returns the cartesian coordinates at the given values of polar coordinates or arclengths.
get_curvature(v[, var])Returns the curvature at the given values of polar coordinates or arclengths.
get_polar_coords(v[, var])Returns the polar coordinates at the given values of theta, r, or arclengths.
get_tangent(v[, var])Returns the unit tangent vector at the given values of polar or arclength coordinates.
r_to_theta(r)Returns the angular coordinates corresponding to the given radial coordinates.
theta_to_r(theta)Returns the radial coordinates corresponding to the given angular coordinates.
- abstractmethod theta_to_r(theta)[source]#
Returns the radial coordinates corresponding to the given angular coordinates.
- Parameters:
- thetaarray_like
Angular coordinates in radians.
- Returns:
- float or ndarray
Radial coordinates (float if input is scalar, else ndarray)
- abstractmethod r_to_theta(r)[source]#
Returns the angular coordinates corresponding to the given radial coordinates.
- Parameters:
- rarray_like
Radial coordinates.
- Returns:
- float or ndarray
Angular coordinates in radians (float if input is scalar, else ndarray).
- abstractmethod get_tangent(v, var='s')[source]#
Returns the unit tangent vector at the given values of polar or arclength coordinates.
- Parameters:
- varray_like
Value of the polar coordinates or arclengths.
- var{‘r’, ‘theta’, ‘s’}
Descriptor for v. Radial coordinates —
'r', angular coordinates —'theta', and arclengths —'s'.
- Returns:
- ndarray
Unit tangent vectors. Shape is (2,) if v is scalar, else (n,2) where n is the length of v.
- arclength_to_r(s)[source]#
Returns the radial coordinates corresponding to the arclengths.
- Parameters:
- sarray_like
Arclengths measured from the starting point (as set by the instance attribute
r0) along the direction of increasing radius.
- Returns:
- float or ndarray
Radial coordinates (float if input is scalar, else ndarray).
- arclength_to_theta(s, s0=0.0, t0=None)[source]#
Returns the angular coordinates corresponding to the arclengths.
- Parameters:
- sarray_like
Arclengths measured from the starting point (as set by the instance attribute
r0) along the direction of increasing radius.- s0float
Value of the arclength at angle t0.
- t0float | None
Measure arclength from this value of the angular coordinate. If
None, set tot0, which corresponds to the radial coordinater0.
- Returns:
- float or ndarray
Radial coordinates (float if input is scalar, else ndarray).
- get_arclength(v, var='theta', v0=None)[source]#
Returns the arclength at the given values of polar coordinates.
- Parameters:
- varray_like
Value of the polar coordinates.
- var{‘r’, ‘theta’}
Descriptor for v. Radial coordinates —
'r', angular coordinates —'theta'.- v0float or None
Origin of the arclength. If
None, will be set toself.t0ifvar = 'theta'or toself.r0ifvar = 'r'.
- Returns:
- float or ndarray
Arclength (float if input is scalar, else ndarray).
- get_curvature(v, var='s')[source]#
Returns the curvature at the given values of polar coordinates or arclengths.
- Parameters:
- varray_like
Value of the polar coordinates or arclengths.
- var{‘r’, ‘theta’, ‘s’}
Descriptor for v. Radial coordinates —
'r', angular coordinates —'theta', and arclengths —'s'.
- Returns:
- float or ndarray
Curvatures (float if input is scalar, else ndarray).
- get_cart_coords(v, var='s')[source]#
Returns the cartesian coordinates at the given values of polar coordinates or arclengths.
- Parameters:
- varray_like
Value of the polar coordinates or arclengths.
- var{‘r’, theta’, ‘s’}
Descriptor for v. Radial coordinates —
'r', angular coordinates —'theta', and arclengths —'s'.
- Returns:
- x, ytuple
Cartesian coordinates. If v is a scalar, x and y are floats, else they are 1D *ndarray*s.
- get_polar_coords(v, var='s')[source]#
Returns the polar coordinates at the given values of theta, r, or arclengths.
- Parameters:
- varray_like
Value of the polar coordinates or arclengths.
- var{‘r’, ‘theta’, ‘s’}
Descriptor for v. Radial coordinates —
'r', angular coordinates —'theta', and arclengths —'s'.
- Returns:
- r, thetatuple
Polar coordinates. If v is a scalar, r and theta are floats, else they are 1D *ndarray*s.
- class ribbon.spiralpolar.SpiralCircleInvolute(b, r0)[source]#
Bases:
SpiralPolarBaseSpirals with polar equation: r = b * (1+theta^2)^(1/2), where b >= 0 is the radius of the circle.
The starting point is at r =
r0and theta =t0, where r0 must be >b.The arclength s is measured from (
r0,t0) in the direction of increasing radius.For all points on this spiral r must be >=
r0, theta must be >=t0, and s must be >= 0.- Parameters:
- bfloat
The radius of circle, must be >= 0.
- r0
Radial coordinate of the starting point of the spiral (must be > b).
Methods
Returns the radial coordinates corresponding to the arclengths.
arclength_to_theta(s[, s0, t0])Returns the angular coordinates corresponding to the arclengths.
get_arclength(v[, var, v0])Returns the arclength at the given values of polar coordinates.
get_cart_coords(v[, var])Returns the cartesian coordinates at the given values of polar coordinates or arclengths.
get_curvature(v[, var])Returns the curvature at the given values of polar coordinates or arclengths.
get_polar_coords(v[, var])Returns the polar coordinates at the given values of theta, r, or arclengths.
get_tangent(v[, var])Returns the unit tangent vector at the given values of polar or arclength coordinates.
r_to_theta(r)Returns the angular coordinates corresponding to the given radial coordinates.
theta_to_r(theta)Returns the radial coordinates corresponding to the given angular coordinates.
- theta_to_r(theta)[source]#
Returns the radial coordinates corresponding to the given angular coordinates.
- Parameters:
- thetaarray_like
Angular coordinates in radians.
- Returns:
- float or ndarray
Radial coordinates (float if input is scalar, else ndarray)
- r_to_theta(r)[source]#
Returns the angular coordinates corresponding to the given radial coordinates.
- Parameters:
- rarray_like
Radial coordinates.
- Returns:
- float or ndarray
Angular coordinates in radians (float if input is scalar, else ndarray).
- get_tangent(v, var='s')[source]#
Returns the unit tangent vector at the given values of polar or arclength coordinates.
- Parameters:
- varray_like
Value of the polar coordinates or arclengths.
- var{‘r’, ‘theta’, ‘s’}
Descriptor for v. Radial coordinates —
'r', angular coordinates —'theta', and arclengths —'s'.
- Returns:
- ndarray
Unit tangent vectors. Shape is (2,) if v is scalar, else (n,2) where n is the length of v.
- arclength_to_r(s)#
Returns the radial coordinates corresponding to the arclengths.
- Parameters:
- sarray_like
Arclengths measured from the starting point (as set by the instance attribute
r0) along the direction of increasing radius.
- Returns:
- float or ndarray
Radial coordinates (float if input is scalar, else ndarray).
- arclength_to_theta(s, s0=0.0, t0=None)#
Returns the angular coordinates corresponding to the arclengths.
- Parameters:
- sarray_like
Arclengths measured from the starting point (as set by the instance attribute
r0) along the direction of increasing radius.- s0float
Value of the arclength at angle t0.
- t0float | None
Measure arclength from this value of the angular coordinate. If
None, set tot0, which corresponds to the radial coordinater0.
- Returns:
- float or ndarray
Radial coordinates (float if input is scalar, else ndarray).
- get_arclength(v, var='theta', v0=None)#
Returns the arclength at the given values of polar coordinates.
- Parameters:
- varray_like
Value of the polar coordinates.
- var{‘r’, ‘theta’}
Descriptor for v. Radial coordinates —
'r', angular coordinates —'theta'.- v0float or None
Origin of the arclength. If
None, will be set toself.t0ifvar = 'theta'or toself.r0ifvar = 'r'.
- Returns:
- float or ndarray
Arclength (float if input is scalar, else ndarray).
- get_cart_coords(v, var='s')#
Returns the cartesian coordinates at the given values of polar coordinates or arclengths.
- Parameters:
- varray_like
Value of the polar coordinates or arclengths.
- var{‘r’, theta’, ‘s’}
Descriptor for v. Radial coordinates —
'r', angular coordinates —'theta', and arclengths —'s'.
- Returns:
- x, ytuple
Cartesian coordinates. If v is a scalar, x and y are floats, else they are 1D *ndarray*s.
- get_curvature(v, var='s')#
Returns the curvature at the given values of polar coordinates or arclengths.
- Parameters:
- varray_like
Value of the polar coordinates or arclengths.
- var{‘r’, ‘theta’, ‘s’}
Descriptor for v. Radial coordinates —
'r', angular coordinates —'theta', and arclengths —'s'.
- Returns:
- float or ndarray
Curvatures (float if input is scalar, else ndarray).
- get_polar_coords(v, var='s')#
Returns the polar coordinates at the given values of theta, r, or arclengths.
- Parameters:
- varray_like
Value of the polar coordinates or arclengths.
- var{‘r’, ‘theta’, ‘s’}
Descriptor for v. Radial coordinates —
'r', angular coordinates —'theta', and arclengths —'s'.
- Returns:
- r, thetatuple
Polar coordinates. If v is a scalar, r and theta are floats, else they are 1D *ndarray*s.