Skip to content

Commit

Permalink
Added accessors to quaternion elements (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
korken89 committed Jul 11, 2021
1 parent 2458446 commit bbee5cf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/quaternion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,26 @@ impl Quaternion {
pub fn to_array(&self) -> [f32; 4] {
[self.0, self.1, self.2, self.3]
}

/// Access the `w` / `a` real component
pub fn w(&self) -> f32 {
self.0
}

/// Access the `x` / `b` / `i` imaginary component
pub fn x(&self) -> f32 {
self.1
}

/// Access the `y` / `c` / `j` imaginary component
pub fn y(&self) -> f32 {
self.2
}

/// Access the `z` / `d` / `k` imaginary component
pub fn z(&self) -> f32 {
self.3
}
}

impl Add for Quaternion {
Expand Down

0 comments on commit bbee5cf

Please sign in to comment.