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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Magba is licensed under The 3-Clause BSD, see LICENSE.
* Copyright 2025 Sira Pornsiriprasert <code@psira.me>
*/
//! Magnets and physical objects that generate magnetic fields.
//!
//! # Declaring Magnets
//!
//! Using constructor:
//! ```
//! # use magba::prelude::*;
//! # use nalgebra::UnitQuaternion;
//! let magnet = CuboidMagnet::new(
//! [0.0, 0.0, 0.0], // position (m)
//! UnitQuaternion::identity(), // orientation as unit quaternion
//! [0.0, 0.0, 1.0], // polarization (T)
//! [0.01, 0.01, 0.02], // dimensions (m)
//! );
//! ```
//!
//! Using builder pattern:
//! ```
//! # use magba::magnets::CuboidMagnet;
//! # use nalgebra::UnitQuaternion;
//! let magnet = CuboidMagnet::default()
//! .with_position([0.0, 0.0, 0.0])
//! .with_orientation(UnitQuaternion::identity())
//! .with_polarization([0.0, 0.0, 1.0])
//! .with_dimensions([0.01, 0.01, 0.02]);
//! ```
//!
//! # Computing B-field
//!
//! ```
//! # use magba::prelude::*;
//! # use nalgebra::point;
//! # let magnet = CuboidMagnet::default();
//! // Compute the B-field at a specific point
//! let b_field = magnet.compute_B(point![0.0, 0.0, 0.02]);
//!
//! // Compute the B-field at multiple points
//! let points = vec![point![0.0, 0.0, 0.02], point![0.0, 0.0, 0.03]];
//! let b_fields = magnet.compute_B_batch(&points);
//! ```
//!
//! With the `rayon` feature (default), `compute_B_batch` automatically parallelizes the magnetic
//! field computation using [Rayon](https://github.com/rayon-rs/rayon) if the number of input
//! points is greater than the threshold to overcome the parallelization overhead.
//! If you disable the `rayon` feature, it will fallback to sequential computation.
pub use CuboidMagnet;
pub use CylinderMagnet;
pub use Dipole;
pub use SphereMagnet;
pub use TetrahedronMagnet;
pub use TriangleMagnet;
pub use Magnet;
pub use MeshMagnet;
pub use StableFieldMagnet;