1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// [[file:../elastic.note::6c5be457][6c5be457]]
// #![deny(warnings)]

use gut::prelude::*;
use vecfx::*;

type Array3 = [f64; 3];
// 6c5be457 ends here

// [[file:../elastic.note::c2302d0e][c2302d0e]]
pub mod direct;
pub mod elastic;

mod constraint;
// c2302d0e ends here

// [[file:../elastic.note::9bc09d49][9bc09d49]]
#[cfg(feature = "adhoc")]
/// Docs for local development
pub mod docs {
    macro_rules! export_doc {
        ($l:ident) => {
            pub mod $l {
                pub use crate::$l::*;
            }
        };
    }

    export_doc!(elastic);
    export_doc!(constraint);
}
// 9bc09d49 ends here

// [[file:../elastic.note::6c4736be][6c4736be]]
/// Represents an elastic spring between a central node i and with its
/// neighboring node j.
#[derive(Debug, Copy, Clone, Default)]
pub struct Spring {
    ///  the ideal distance between node i and node j
    dij: f64,
    /// elastic weight for pair ij. If None, it will be deduced from `dij`
    wij: f64,
}

/// Represents elastic connection of center node `i` with its neighbor `j`
#[derive(Debug, Copy, Clone)]
pub struct Connection {
    /// The elastic spring
    spring: Spring,
    /// The displacement from center to its neighbor
    displace: Array3,
    /// Optional distance between two nodes. If not set, it will be evaluated from `displace`
    distance: Option<f64>,
}
// 6c4736be ends here