Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/mat4.zig
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ pub fn Mat4x4(comptime T: type) type {
return Vector3.new(self.data[3][0], self.data[3][1], self.data[3][2]);
}

/// Get the up vector from a given 4x4 matrix
pub fn getUp(self: Self) Vector3 {
return Vector3.new(self.data[0][1], self.data[1][1], self.data[2][1]);
}

/// Get the right vector from a given 4x4 matrix
pub fn getRight(self: Self) Vector3 {
return Vector3.new(self.data[0][0], self.data[1][0], self.data[2][0]);
}

/// Get the right vector from a given 4x4 matrix
pub fn getForward(self: Self) Vector3 {
return Vector3.new(self.data[0][2], self.data[1][2], self.data[2][2]);
}

/// Construct a 4x4 matrix from given axis and angle (in degrees).
pub fn fromRotation(angle_in_degrees: T, axis: Vector3) Self {
var result = Self.identity();
Expand Down
Loading