com_croftsoft_core/math/matrix/structures/
mod.rs

1// =============================================================================
2//! - The Matrix and supporting structures
3//!
4//! # Metadata
5//! - Copyright: © 1998 - 2022 [`CroftSoft Inc`]
6//! - Author: [`David Wallace Croft`]
7//! - Rust version: 2022-10-20
8//! - Rust since: 2022-09-04
9//! - Java version: 1998-12-27
10//!
11//! # History
12//! - Adapted from the Java class com.croftsoft.core.math.Matrix
13//!   - In the Java-based [`CroftSoft Core Library`]
14//!
15//! [`CroftSoft Core Library`]: https://www.croftsoft.com/library/code/
16//! [`CroftSoft Inc`]: https://www.croftsoft.com/
17//! [`David Wallace Croft`]: https://www.croftsoft.com/people/david/
18// =============================================================================
19
20// -----------------------------------------------------------------------------
21/// A newtype for functions that take an f64 argument in units of degrees
22// -----------------------------------------------------------------------------
23#[derive(Clone, Copy, Debug, PartialEq)]
24pub struct Degrees(pub f64);
25
26// -----------------------------------------------------------------------------
27/// The row and column indices of a Matrix, indexed from zero
28// -----------------------------------------------------------------------------
29#[derive(Clone, Copy, Debug, Eq, PartialEq)]
30pub struct Indices {
31  pub row: usize,
32  pub column: usize,
33}
34
35// -----------------------------------------------------------------------------
36/// A mathematical matrix structure
37// -----------------------------------------------------------------------------
38#[derive(Clone, Debug, PartialEq)]
39pub struct Matrix<const R: usize, const C: usize> {
40  pub rows: [[f64; C]; R],
41}
42
43// -----------------------------------------------------------------------------
44/// A newtype for functions that take an f64 argument in units of radians
45// -----------------------------------------------------------------------------
46#[derive(Clone, Copy, Debug, PartialEq)]
47pub struct Radians(pub f64);
48
49#[derive(Clone, Copy, Debug, Default, PartialEq)]
50pub struct RotationDegrees {
51  pub x: f64,
52  pub y: f64,
53  pub z: f64,
54}
55
56#[derive(Clone, Copy, Debug, Default, PartialEq)]
57pub struct RotationRadians {
58  pub x: f64,
59  pub y: f64,
60  pub z: f64,
61}