Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build on Zig 0.12 #45

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/mat3.zig
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ pub fn Mat3x3(comptime T: type) type {
pub fn extractEulerAngles(self: Self) Vector3 {
const m = self.orthoNormalize();

const theta_x = math.atan2(T, m.data[1][2], m.data[2][2]);
const theta_x = math.atan2(m.data[1][2], m.data[2][2]);
const c2 = @sqrt(math.pow(T, m.data[0][0], 2) + math.pow(T, m.data[0][1], 2));
const theta_y = math.atan2(T, -m.data[0][2], @sqrt(c2));
const theta_y = math.atan2(-m.data[0][2], @sqrt(c2));
const s1 = @sin(theta_x);
const c1 = @cos(theta_x);
const theta_z = math.atan2(T, s1 * m.data[2][0] - c1 * m.data[1][0], c1 * m.data[1][1] - s1 * m.data[2][1]);
const theta_z = math.atan2(s1 * m.data[2][0] - c1 * m.data[1][0], c1 * m.data[1][1] - s1 * m.data[2][1]);

return Vector3.new(root.toDegrees(theta_x), root.toDegrees(theta_y), root.toDegrees(theta_z));
}
Expand Down
6 changes: 3 additions & 3 deletions src/mat4.zig
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ pub fn Mat4x4(comptime T: type) type {
pub fn extractEulerAngles(self: Self) Vector3 {
const m = self.orthoNormalize();

const theta_x = math.atan2(T, m.data[1][2], m.data[2][2]);
const theta_x = math.atan2(m.data[1][2], m.data[2][2]);
const c2 = @sqrt(math.pow(T, m.data[0][0], 2) + math.pow(T, m.data[0][1], 2));
const theta_y = math.atan2(T, -m.data[0][2], @sqrt(c2));
const theta_y = math.atan2(-m.data[0][2], @sqrt(c2));
const s1 = @sin(theta_x);
const c1 = @cos(theta_x);
const theta_z = math.atan2(T, s1 * m.data[2][0] - c1 * m.data[1][0], c1 * m.data[1][1] - s1 * m.data[2][1]);
const theta_z = math.atan2(s1 * m.data[2][0] - c1 * m.data[1][0], c1 * m.data[1][1] - s1 * m.data[2][1]);

return Vector3.new(root.toDegrees(theta_x), root.toDegrees(theta_y), root.toDegrees(theta_z));
}
Expand Down
2 changes: 0 additions & 2 deletions src/quaternion.zig
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,13 @@ pub fn Quaternion(comptime T: type) type {
/// Extract euler angles (degrees) from quaternion.
pub fn extractEulerAngles(self: Self) Vector3 {
const yaw = math.atan2(
T,
2 * (self.y * self.z + self.w * self.x),
self.w * self.w - self.x * self.x - self.y * self.y + self.z * self.z,
);
const pitch = math.asin(
-2 * (self.x * self.z - self.w * self.y),
);
const roll = math.atan2(
T,
2 * (self.x * self.y + self.w * self.z),
self.w * self.w + self.x * self.x - self.y * self.y - self.z * self.z,
);
Expand Down
Loading