aerocaps.geom.curves.Line2D#

class Line2D(p0: ~aerocaps.geom.point.Point2D, p1: ~aerocaps.geom.point.Point2D = None, theta: ~aerocaps.units.angle.Angle = None, d: ~aerocaps.units.length.Length = <aerocaps.units.length.Length object>, name: str = 'Line2D', construction: bool = False)[source]#

Bases: PCurve2D

Two-dimensional line class

__init__(p0: ~aerocaps.geom.point.Point2D, p1: ~aerocaps.geom.point.Point2D = None, theta: ~aerocaps.units.angle.Angle = None, d: ~aerocaps.units.length.Length = <aerocaps.units.length.Length object>, name: str = 'Line2D', construction: bool = False)[source]#

Two-dimensional line defined by either two points or a point and an angle. If a second point (p1) is defined, the curve will be evaluated as

\[\begin{split}\begin{align} x(t) &= x_0 + t (x_1 - x_0) \\ y(t) &= y_0 + t (y_1 - y_0) \end{align}\end{split}\]

If an angle (theta) is specified instead, the curve will be evaluated as

\[\begin{split}\begin{align} x(t) &= x_0 + d \cdot t \cdot \cos{\theta} \\ y(t) &= y_0 + d \cdot t \cdot \sin{\theta} \end{align}\end{split}\]
Parameters:
  • p0 (Point2D) – Origin of the line

  • p1 (Point2D or None) – Endpoint of the line. If None, theta must be specified. Default: None

  • theta (Angle or None) – Angle of the line (counter-clockwise positive, \(0^{\circ}\) defined along the \(x\)-axis). If None, p1 must be specified. Default: None

  • d (Length) – Used in conjunction with theta to determine the point corresponding to \(t=1\). If p1 is specified, this value is not used. Default: Length(m=1.0)

  • name (str) – Name of the geometric object. May be re-assigned a unique name when added to a GeometryContainer. Default: ‘Line2D’

  • construction (bool) – Whether this is a geometry used only for construction of other geometries. If True, this geometry will not be exported or plotted. Default: False

Methods

d2cdt2(t)

Evaluates the second derivative of the curve with respect to \(t\)

dcdt(t)

Evaluates the first derivative of the curve with respect to \(t\)

evaluate(t)

Evaluates the line at one or more \(t\)-values

evaluate_pcurvedata(t)

Evaluates a verbose set of parametric curve data as a class based on an input parameter value or vector

evaluate_point2d(t)

Evaluates the line at one or more \(t\)-values and returns a single point object or list of point objects

get_vector()

Gets a vector object determined by the starting and ending points of the line

plot(ax[, nt])

Plots the line on a matplotlib.pyplot.Axes

Attributes

d2cdt2(t: float) ndarray[source]#

Evaluates the second derivative of the curve with respect to \(t\)

Parameters:

t (float or int or numpy.ndarray) – Either a single \(t\)-value, a number of evenly spaced \(t\)-values between 0 and 1, or a 1-D array of \(t\)-values

Returns:

If \(t\) is a float, the output is a 1-D array containing two elements: the \(x\)- and \(y\)-components of the second derivative. Otherwise, the output is a 2-D array of size \(\text{len}(t) \times 2\)

Return type:

numpy.ndarray

dcdt(t: float) ndarray[source]#

Evaluates the first derivative of the curve with respect to \(t\)

Parameters:

t (float or int or numpy.ndarray) – Either a single \(t\)-value, a number of evenly spaced \(t\)-values between 0 and 1, or a 1-D array of \(t\)-values

Returns:

If \(t\) is a float, the output is a 1-D array containing two elements: the \(x\)- and \(y\)-components of the first derivative. Otherwise, the output is a 2-D array of size \(\text{len}(t) \times 2\)

Return type:

numpy.ndarray

evaluate(t: float) ndarray[source]#

Evaluates the line at one or more \(t\)-values

Parameters:

t (float or int or numpy.ndarray) – Either a single \(t\)-value, a number of evenly spaced \(t\)-values between 0 and 1, or a 1-D array of \(t\)-values

Returns:

If t is a float, the output is a 1-D array with two elements: the values of \(x\) and \(y\). Otherwise, the output is an array of size \(\text{len}(t) \times 2\)

Return type:

numpy.ndarray

evaluate_pcurvedata(t: float) PCurveData2D[source]#

Evaluates a verbose set of parametric curve data as a class based on an input parameter value or vector

Parameters:

t (float or int or numpy.ndarray) – Either a single \(t\)-value, a number of evenly spaced \(t\)-values between 0 and 1, or a 1-D array of \(t\)-values

Returns:

Parametric curve information, including derivative and curvature data

Return type:

PCurveData2D

evaluate_point2d(t: float) Point2D[source]#

Evaluates the line at one or more \(t\)-values and returns a single point object or list of point objects

Parameters:

t (float or int or numpy.ndarray) – Either a single \(t\)-value, a number of evenly spaced \(t\)-values between 0 and 1, or a 1-D array of \(t\)-values

Returns:

If t is a float, the output is a single point object. Otherwise, the output is a list of point objects

Return type:

Point2D or List[Point2D]

get_vector() Vector2D[source]#

Gets a vector object determined by the starting and ending points of the line

Returns:

Vector object

Return type:

Vector2D

plot(ax: Axes, nt: int = 10, **kwargs)[source]#

Plots the line on a matplotlib.pyplot.Axes

Parameters:
  • ax (plt.Axes) – Axis on which to plot the line

  • nt (int) – Number of points along the line to output to the plot. Default: 10

  • kwargs – Additional keyword arguments to pass to matplotlib.pyplot.Axes.plot