diff --git a/src/analog.rs b/src/analog.rs index 7c73435..ef16c8c 100644 --- a/src/analog.rs +++ b/src/analog.rs @@ -8,6 +8,7 @@ use crate::processor::Processor; use crate::{C3dParseError, C3dWriteError}; use grid::Grid; +/// Analog format describes whether the analog data is signed or unsigned. #[derive(Debug, Clone, PartialEq, Default)] pub enum AnalogFormat { #[default] @@ -35,6 +36,7 @@ impl AnalogFormat { } } +/// An offset that is subtracted from the analog data before scaling. #[derive(Debug, Clone, PartialEq)] pub enum AnalogOffset { Signed(Vec), @@ -68,9 +70,11 @@ impl AnalogOffset { } } +/// Analog data and parameters are stored as a struct. +/// Definitions for data and parameters are from the C3D file format documentation. #[derive(Debug, Clone)] pub struct Analog { - pub parsed_header: bool, + parsed_header: bool, pub analog: Grid, pub labels: Vec, pub descriptions: Vec, diff --git a/src/data.rs b/src/data.rs index 65c6398..850073f 100644 --- a/src/data.rs +++ b/src/data.rs @@ -2,6 +2,9 @@ use crate::C3dParseError; use std::ops::{Deref, DerefMut}; +/// DataFormat is the format of the data in the file. +/// Floating point data is larger than integer data, but the loss of precision +/// in integer data may be acceptable for some applications. #[derive(Debug, Clone, PartialEq, Default)] pub enum DataFormat { #[default] @@ -30,6 +33,9 @@ pub(crate) fn get_analog_bytes_per_frame( Ok(bytes_per_analog_point * analog_samples_per_frame as usize) } +/// MarkerPoint contains both the points and residuals for a marker. +/// The residuals are the average distance between the marker and the reconstructed point. +/// Cameras is a bitfield of which cameras saw the marker. #[derive(Debug, Clone, Copy, PartialEq, Default)] pub struct MarkerPoint { pub point: [f32; 3], @@ -72,6 +78,7 @@ impl MarkerPoint { *self } + /// used for writing to file pub(crate) fn cameras_as_byte(&self) -> u8 { let mut cameras_byte = 0; for (i, camera) in self.cameras.iter().enumerate() { diff --git a/src/file_formats/sto.rs b/src/file_formats/sto.rs index 1282630..e267c25 100644 --- a/src/file_formats/sto.rs +++ b/src/file_formats/sto.rs @@ -1,8 +1,11 @@ +//! STO file formats are used by OpenSim to store table-based data such as joint angles, muscle activations, and muscle forces. +//! They can be used to store ground reaction forces/moments and emg data as well. use crate::{C3d, C3dWriteError}; use std::io::Write; use std::path::PathBuf; use grid::Grid; +/// The STO struct contains the data for writing an STO file. #[derive(Debug, Clone)] pub struct Sto { pub file_description: Option, diff --git a/src/file_formats/trc.rs b/src/file_formats/trc.rs index 541e147..77cd9e8 100644 --- a/src/file_formats/trc.rs +++ b/src/file_formats/trc.rs @@ -1,3 +1,5 @@ +//! TRC file format is a Motion Analysis Corporation file format for storing 3D marker data. +//! It is also used by OpenSim to store marker data. use crate::C3d; use crate::C3dWriteError; use std::io::Write; @@ -6,6 +8,7 @@ use std::path::PathBuf; use crate::data::MarkerPoint; use grid::Grid; +/// The TRC struct contains the data for writing a TRC file. #[derive(Debug, Clone)] pub struct Trc { pub path_file_type: u8, diff --git a/tests/data/short-copy.c3d b/tests/data/short-copy.c3d index 5270e8a..a625244 100644 Binary files a/tests/data/short-copy.c3d and b/tests/data/short-copy.c3d differ