Skip to content

Commit

Permalink
add some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cvhammond committed Jan 6, 2024
1 parent 5489f0b commit 8b9cb25
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/analog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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<i16>),
Expand Down Expand Up @@ -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<f64>,
pub labels: Vec<String>,
pub descriptions: Vec<String>,
Expand Down
7 changes: 7 additions & 0 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 3 additions & 0 deletions src/file_formats/sto.rs
Original file line number Diff line number Diff line change
@@ -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<String>,
Expand Down
3 changes: 3 additions & 0 deletions src/file_formats/trc.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down
Binary file modified tests/data/short-copy.c3d
Binary file not shown.

0 comments on commit 8b9cb25

Please sign in to comment.