Struct Catenary

Source
pub struct Catenary<T: DualNum<f64>> {
    pub a: T,
    pub c: T,
    pub h: T,
    pub s_0: T,
    pub s_1: T,
}
Expand description

Represents a Catenary curve.

The Catenary curve is defined by the equation: y(x) = a * cosh((x - c) / a) - a + h where:

  • a is the parameter that controls the shape of the curve.
  • c is the horizontal shift of the curve.
  • h is the vertical shift of the curve.
  • s_0 and s_1 are linear abscissa of end points (negative on the left of minimum, positive on the right).

Fields§

§a: T

The parameter that controls the shape of the curve.

§c: T

The horizontal shift of the curve.

§h: T

The vertical shift of the curve.

§s_0: T

The linear abscissa of the left endpoint (from min).

§s_1: T

The linear abscissa of the right endpoint (from min).

Implementations§

Source§

impl<T: DualNum<f64>> Catenary<T>

Source

pub fn new(a: T, c: T, h: T, s_0: T, s_1: T) -> Self

Creates a new instance of the Catenary structure.

§Arguments
  • a - The parameter that controls the shape of the curve.
  • c - The horizontal shift of the curve.
  • h - The vertical shift of the curve.
  • s_0 - The linear abscissa of the left endpoint (from min).
  • s_1 - The linear abscissa of the right endpoint (from min).
Source

pub fn x_from_y(&self, y: &T) -> Roots<T>

Computes the x-coordinate(s) from the given y-coordinate on the catenary curve.

§Arguments
  • y - The y-coordinate.
§Returns

The roots of the equation representing the x-coordinate(s).

Source

pub fn y_from_abscissa(&self, s: &T) -> T

Computes the y-coordinate(s) from the given abscissa on the catenary curve.

§Arguments
  • s - The abscissa.
§Returns

The y-coordinate(s) corresponding to the given abscissa.

Source

pub fn s_from_x(&self, x: &T) -> T

Computes the abscissa s from the given x-coordinate on the catenary curve.

§Arguments
  • x - The x-coordinate.
§Returns

The abscissa s corresponding to the given x-coordinate.

Source

pub fn x_from_abscissa(&self, s: &T) -> T

Computes the x-coordinate from the given abscissa on the catenary curve.

§Arguments
  • s - The abscissa.
§Returns

The x-coordinate corresponding to the given abscissa.

Source

pub fn length(&self) -> T

Returns the length of the catenary curve.

Source

pub fn end_points(&self) -> (Point2<T>, Point2<T>)

Returns the end points of the catenary curve.

§Returns

A tuple containing the start and end points of the catenary curve.

Source§

impl Catenary<f64>

Source

pub fn from_points_length_init( p0: &Point2<f64>, p1: &Point2<f64>, length: f64, cat0: &Self, ) -> Option<Self>

Creates a catenary curve from two points and a specified length, and an initial guess

§Arguments
  • p0 - The start point of the catenary curve.
  • p1 - The end point of the catenary curve.
  • length - The desired length of the catenary curve.
  • cat0 - The initial catenary curve to use as a starting point.
§Returns

An Option containing the catenary curve if it could be created, or None otherwise.

Source

pub fn from_points_length( p0: &Point2<f64>, p1: &Point2<f64>, length: f64, ) -> Option<Self>

Creates a catenary curve from two points and a specified length. (same as from_points_length_init but without the initial guess)

§Arguments
  • p0 - The start point of the catenary curve.
  • p1 - The end point of the catenary curve.
  • length - The desired length of the catenary curve.
§Returns

An Option containing the catenary curve if it could be created, or None otherwise.

Source

pub fn from_segment(p0: &Point2<f64>, p1: &Point2<f64>) -> Self

Creates a (almost line) Catenary from a line segment defined by two points (degenerate case with big a, or 0 if vertical)

Source

pub fn from_segment_length( p0: &Point2<f64>, p1: &Point2<f64>, length: f64, ) -> Option<Self>

Creates a Catenary from a line segment defined by two points and a optimize with the length. To use when the catenary is almost a straight line. The optimization starts from a straight line catenary.

Trait Implementations§

Source§

impl<T: DualNum<f64>> Add for Catenary<T>

Source§

type Output = Catenary<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone + DualNum<f64>> Clone for Catenary<T>

Source§

fn clone(&self) -> Catenary<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: DualNum<f64>> Contour<T> for Catenary<T>

Source§

fn position(&self, s: &T) -> Point2<T>

Returns the position on the contour for a given input value. Read more
Source§

fn divide(&self, start: F, end: F, n_points: u32) -> Vec<OPoint<F, Const<2>>>

Divides the contour into a specified number of points between the start and end values. Read more
Source§

impl<T: Debug + DualNum<f64>> Debug for Catenary<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default + DualNum<f64>> Default for Catenary<T>

Source§

fn default() -> Catenary<T>

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for Catenary<T>
where T: Deserialize<'de> + DualNum<f64>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Catenary<f64>> for Catenary<DualSVec64<3>>

Source§

fn from(cat: Catenary<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Catenary<f64>> for Catenary<DualSVec64<5>>

Source§

fn from(cat: Catenary<f64>) -> Self

Converts to this type from the input type.
Source§

impl<T: DualNum<f64>> Mul<&T> for Catenary<T>

Source§

type Output = Catenary<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: PartialEq + DualNum<f64>> PartialEq for Catenary<T>

Source§

fn eq(&self, other: &Catenary<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Catenary<T>
where T: Serialize + DualNum<f64>,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: DualNum<f64>> Sub for &Catenary<T>

Source§

type Output = Catenary<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: DualNum<f64>> Sub for Catenary<T>

Source§

type Output = Catenary<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: Copy + DualNum<f64>> Copy for Catenary<T>

Source§

impl<T: DualNum<f64>> StructuralPartialEq for Catenary<T>

Auto Trait Implementations§

§

impl<T> Freeze for Catenary<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Catenary<T>
where T: RefUnwindSafe,

§

impl<T> Send for Catenary<T>
where T: Send,

§

impl<T> Sync for Catenary<T>
where T: Sync,

§

impl<T> Unpin for Catenary<T>
where T: Unpin,

§

impl<T> UnwindSafe for Catenary<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,