[][src]Function dihedral::dihedral

pub fn dihedral([a, b, c, d]: [[f64; 3]; 4]) -> f64

Calculates the dihedral angle, in the range -π to π, of the four ordered coordinates.

This is in accordance with the definition of dihedral angle in biochemistry textbooks.

Examples

use dihedral::dihedral;

const P0: [f64; 3] = [24.969, 13.428, 30.692]; // N
const P1: [f64; 3] = [24.044, 12.661, 29.808]; // CA
const P2: [f64; 3] = [22.785, 13.482, 29.543]; // C
const P3: [f64; 3] = [21.951, 13.670, 30.431]; // O
const P4: [f64; 3] = [23.672, 11.328, 30.466]; // CB
const P5: [f64; 3] = [22.881, 10.326, 29.620]; // CG
const P6: [f64; 3] = [23.691, 9.935, 28.389]; // CD1
const P7: [f64; 3] = [22.557, 9.096, 30.459]; // CD2

assert!((dihedral([P0, P1, P2, P3]).to_degrees() - (-71.21515)).abs() < 1E-4);
assert!((dihedral([P0, P1, P4, P5]).to_degrees() - (-171.94319)).abs() < 1E-4);
assert!((dihedral([P1, P4, P5, P6]).to_degrees() - (60.82226)).abs() < 1E-4);
assert!((dihedral([P1, P4, P5, P7]).to_degrees() - (-177.63641)).abs() < 1E-4);