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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Magba is licensed under The 3-Clause BSD, see LICENSE.
* Copyright 2025 Sira Pornsiriprasert <code@psira.me>
*/
//! Analytical computation of magnetic fields for various source geometries.
//!
//! # Argument Conventions
//!
//! The arguments in the field computation functions follow the order of
//! observer position(s), magnet position, magnet orientation, and the other
//! arguments needed for the specific geometry. For the batch functions, the
//! last argument is a slice for receiving the output. This is to avoid
//! allocations and enable use in `no-alloc` contexts.
//!
//! # Batch and Non-Batch Functions
//!
//! The field computation functions are available in three variants:
//!
//! - **Non-batch functions** (e.g., [cuboid_B], [dipole_B]):
//! Compute the magnetic field at a single observation point.
//! - **Batch functions** (e.g., [cuboid_B_batch], [dipole_B_batch]):
//! Compute the magnetic field at multiple observation points simultaneously.
//! - **Sum multiple functions** (e.g., [sum_multiple_cuboid_B], [sum_multiple_dipole_B]):
//! Compute the magnetic field at a single observation point by summing the
//! fields of multiple magnets.
//!
//! ## Parallelization
//!
//! Batch and sum multiple functions are parallelized if the `rayon` feature is
//! enabled (default). If the `rayon` feature is disabled, the batch functions
//! will process the points serially on a single thread.
//!
//! # Examples
//!
//! ```
//! # use magba::fields::*;
//! # use magba::prelude::*;
//! # use nalgebra::{point, vector, UnitQuaternion};
//! let field = cuboid_B(
//! point![0.0, 0.0, 0.0], // Observer position (m)
//! point![0.0, 0.0, 0.0], // Magnet position (m)
//! UnitQuaternion::identity(), // Magnet orientation as unit quaternion
//! vector![0.0, 0.0, 1.0], // Magnet polarization (T)
//! vector![0.01, 0.01, 0.02], // Magnet dimensions (m)
//! );
//! ```
//!
//! # Internal Functions (`unstable`)
//!
//! The following functions with `unstable` badges are internal
//! functions. They are subject to change without prior notice.
//! However, you can access them via the `unstable` feature flag:
//!
//! ```bash
//! cargo add magba --features unstable
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
crateneed_unstable!