ode_rs/
lib.rs

1#![doc(html_root_url = "https://docs.rs/ode-rs/1.2.1")]
2//! ODE Open Dynamics Engine for Rust
3//!
4//! # Requirements
5//!
6//! - [ode and drawstuff](https://ode.org/)
7//! - [ode-base for Rust crates.io](https://crates.io/crates/ode-base)
8//! - [ode-base for Rust rep.](https://github.com/nomissbowling/ode-base)
9//! - [drawstuff for Rust crates.io](https://crates.io/crates/drawstuff)
10//! - [drawstuff for Rust rep.](https://github.com/nomissbowling/drawstuff)
11//! - [https://crates.io/crates/asciiz](https://crates.io/crates/asciiz)
12//! - [https://github.com/nomissbowling/asciiz](https://github.com/nomissbowling/asciiz)
13//!
14//! to build dll
15//!
16//! - premake4 --with-demos --only-double --with-libccd --cc=gcc --platform--x64 --os=windows codeblocks
17//! - premake4 --with-demos --only-double --with-libccd --platform--x64 --os=windows vs2010
18//!
19//! in the running directory
20//!
21//! - drawstuff.dll
22//! - ode.dll
23//! - libstdc++-6.dll
24//! - libgcc_s_seh-1.dll
25//! - libwinpthread-1.dll
26//!
27//! # Examples
28//!
29//! see also
30//!
31//! - [https://crates.io/crates/ode-rs-0000](https://crates.io/crates/ode-rs-0000)
32//! - [https://github.com/nomissbowling/ode-rs-0000](https://github.com/nomissbowling/ode-rs-0000)
33//!
34
35pub mod ds;
36pub use drawstuff::drawstuff::*;
37pub use oyk::*;
38
39#[cfg(test)]
40mod tests {
41  use super::colors::*;
42/*
43  use super::ode::*;
44
45  #[test]
46  fn check_quaternion_matrix() {
47    let q = dQuaternion::from_axis_and_angle([1.0, 0.0, 0.0], PIh);
48    let p = dQuaternion::from_axis_and_angle([0.0, 1.0, 0.0], PIh);
49    let o = dQuaternion::from_axis_and_angle([0.0, 0.0, 1.0], PIh);
50    println!("q, p, o");
51    println!("{}", q.as_vec());
52    println!("{}", p.as_vec());
53    println!("{}", o.as_vec());
54    assert!(q.prec_eq(1e-15, [PIq.cos(), PIq.sin(), 0.0, 0.0]));
55    assert!(p.prec_eq(1e-15, [PIq.cos(), 0.0, PIq.sin(), 0.0]));
56    assert!(o.prec_eq(1e-15, [PIq.cos(), 0.0, 0.0, PIq.sin()]));
57
58    let oq = dQuaternion::multiply0(o, q);
59    let po = dQuaternion::multiply0(p, o);
60    let pq = dQuaternion::multiply0(p, q);
61    println!("oq, po, pq");
62    println!("{}", oq.as_vec());
63    println!("{}", po.as_vec());
64    println!("{}", pq.as_vec());
65    assert!(oq.prec_eq(1e-15, [0.5, 0.5, 0.5, 0.5])); // j
66    assert!(po.prec_eq(1e-15, [0.5, 0.5, 0.5, 0.5])); // i
67    assert!(pq.prec_eq(1e-15, [0.5, 0.5, 0.5, -0.5])); // k
68    assert!(oq.prec_eq(1e-15, po));
69
70    let nq = dMatrix4::from_P(q);
71    let np = dMatrix4::from_P(p);
72    let no = dMatrix4::from_P(o);
73    println!("nq, np, no");
74    println!("{}", nq.as_mat());
75    println!("{}", np.as_mat());
76    println!("{}", no.as_mat());
77    assert!(dQuaternion::multiply0_441(nq, o).prec_eq(1e-15, oq));
78    assert!(dQuaternion::multiply0_441(no, p).prec_eq(1e-15, po));
79    assert!(dQuaternion::multiply0_441(nq, p).prec_eq(1e-15, pq));
80
81    let nqno = dMatrix4::multiply0_444(nq, no);
82    let nonp = dMatrix4::multiply0_444(no, np);
83    let nqnp = dMatrix4::multiply0_444(nq, np);
84    println!("nqno, nonp, nqnp");
85    println!("{}", nqno.as_mat());
86    println!("{}", nonp.as_mat());
87    println!("{}", nqnp.as_mat());
88    assert!(nqno.is_quaternion());
89    assert!(nqno.to_Q().prec_eq(1e-15, oq));
90    assert!(nonp.is_quaternion());
91    assert!(nonp.to_Q().prec_eq(1e-15, po));
92    assert!(nqnp.is_quaternion());
93    assert!(nqnp.to_Q().prec_eq(1e-15, pq));
94    assert!(nqno.prec_eq(1e-15, nonp));
95
96    let mq = dMatrix4::from_Q(q);
97    let mp = dMatrix4::from_Q(p);
98    let mo = dMatrix4::from_Q(o);
99    println!("mq, mp, mo");
100    println!("{}", mq.as_mat());
101    println!("{}", mp.as_mat());
102    println!("{}", mo.as_mat());
103    assert!(dQuaternion::multiply0_441(mo, q).prec_eq(1e-15, oq));
104    assert!(dQuaternion::multiply0_441(mp, o).prec_eq(1e-15, po));
105    assert!(dQuaternion::multiply0_441(mp, q).prec_eq(1e-15, pq));
106
107    let momq = dMatrix4::multiply0_444(mo, mq);
108    let mpmo = dMatrix4::multiply0_444(mp, mo);
109    let mpmq = dMatrix4::multiply0_444(mp, mq);
110    println!("momq, mpmo, mpmq");
111    println!("{}", momq.as_mat());
112    println!("{}", mpmo.as_mat());
113    println!("{}", mpmq.as_mat());
114    assert!(momq.is_quaternion());
115    assert!(momq.to_Q().prec_eq(1e-15, oq));
116    assert!(mpmo.is_quaternion());
117    assert!(mpmo.to_Q().prec_eq(1e-15, po));
118    assert!(mpmq.is_quaternion());
119    assert!(mpmq.to_Q().prec_eq(1e-15, pq));
120    assert!(momq.prec_eq(1e-15, mpmo));
121  }
122*/
123
124  /// with [-- --nocapture] or with [-- --show-output]
125  #[test]
126  fn test_ode() {
127    assert_eq!(COLORS[0], 0xcccccccc);
128    assert_eq!(vec4_from_u32(COLORS[COLORS.len() - 1]), [0.2, 0.2, 0.2, 0.8]);
129  }
130}