[][src]Struct helixiser::helix::Helix

pub struct Helix {
    pub radius: f64,
    pub rise: f64,
    pub frequency: f64,
    pub unit_size: f64,
    pub offset: f64,
    pub rotation: f64,
    pub handedness: Handedness,
}

A Helix struct

Fields

radius: f64

A Helix has a radius value, which should be positive

rise: f64

The helical rise is the distance between subunits along the helix axis (i.e. z axis)

frequency: f64

The amount of subunits in a full turn of a helix. Can be decimal value.

unit_size: f64

The size of each subunit

offset: f64

Translational offset along helix axis (i.e. z)

rotation: f64

Rotational offset of helix around helix axis (i.e. z)

handedness: Handedness

Handedness (left- or righthanded) of the helix.

Implementations

impl Helix[src]

pub fn new(
    radius: f64,
    rise: f64,
    frequency: f64,
    unit_size: f64,
    offset: f64,
    rotation: f64,
    handedness: Handedness
) -> Helix
[src]

Create a new Helix

Directly instantiating is also permitted, as it is more human readable, so may be preferred for example code. When programmatically generating helices, it is best to use the Helix::new() approach as it panics when it encounters invalid values.

Examples

use helixiser::helix::{Helix, Handedness};
let my_helix = Helix::new(0.1, 0.4, 12., 0.1, 5.6, 180., Handedness::Right);
let second = my_helix.clone();

Panics

The new function will panic if any of radius, rise, frequency, unit_size or offset are smaller than or equal to zero.

pub fn pitch(&self) -> f64[src]

Compute the pitch of the helix. This is the distance between the helix backbone along the helix axis (i.e. z axis) after a full rotation. Does not need to be an integer multiple of the rise. Is computed as pitch = rise * frequency.

Examples

use std::f64::consts::PI;

let my_helix = Helix::new( 18.9, 0.55, 11.5, 0.1, 0., 0., Handedness::Right );
let myPitch = my_helix.pitch();

assert_eq!(myPitch, 11.5 * 0.55)

pub fn rotation_to_rad(&self) -> f64[src]

Convert the helix' rotation to radians insted of the default (degrees)

Examples

use std::f64::consts::PI;

let my_helix = Helix::new ( 1.0, 0.34, 10., 0.18, 0., 90., Handedness::Right );
let rotation = my_helix.rotation_to_rad();

assert_eq!(rotation, PI/2f64)

pub fn rad_per_subunit(&self) -> f64[src]

Determine the rotational offset between subunits. This is related only to the frequency by: rotational offset = 2*Pi / frequency

Examples

use std::f64::consts::PI;

let my_helix = Helix::new ( 2.0, 0.34, 8., 0.1, 0., 90., Handedness::Right );
let angle_per_subunit = my_helix.rad_per_subunit();

assert_eq!(angle_per_subunit, PI/4f64)

Trait Implementations

impl Clone for Helix[src]

impl Debug for Helix[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.