Fix incorrect usage of Normalized() vs Normalize()

This commit is contained in:
2025-02-02 22:10:02 -05:00
parent 1a5737a356
commit 174f6068e7
2 changed files with 11 additions and 8 deletions

View File

@@ -372,7 +372,7 @@ namespace J3ML::Geometry
Vector4 b = Vector4(poly.v[face.v[1]], 1.f);
Vector4 c = Vector4(poly.v[face.v[2]], 1.f);
Vector4 normal = (b-a).Cross(c-a);
normal.Normalized();
normal.Normalize();
return normal;
// return ((vec)v[face.v[1]]-(vec)v[face.v[0]]).Cross((vec)v[face.v[2]]-(vec)v[face.v[0]]).Normalized();
}
@@ -390,7 +390,7 @@ namespace J3ML::Geometry
normal.z += (double(poly.v[v0].x) - poly.v[v1].x) * (double(poly.v[v0].y) + poly.v[v1].y); // Project on xy
v0 = v1;
}
normal.Normalized();
normal.Normalize();
return normal;
#if 0
cv bestNormal;

View File

@@ -34,7 +34,8 @@ namespace J3ML::LinearAlgebra {
y = (m02 - m20) / w4;
z = (m10 - m01) / w4;
w = field_w;
Normalize();
bool success = Normalize();
// TODO: Validate normalization success.
}
Quaternion::Quaternion(const Matrix4x4& ro_mat) {
@@ -74,7 +75,7 @@ namespace J3ML::LinearAlgebra {
}
Quaternion Quaternion::operator*(float scalar) const {
return Quaternion(x * scalar, y * scalar, z * scalar, w * scalar);
return {x * scalar, y * scalar, z * scalar, w * scalar};
}
Quaternion Quaternion::operator/(float scalar) const {
@@ -204,12 +205,13 @@ namespace J3ML::LinearAlgebra {
}
Quaternion::Quaternion(const AxisAngle& angle) {
double s = std::sin(angle.angle / 2);
float s = Math::Sin(angle.angle / 2.f);
x = angle.axis.x * s;
y = angle.axis.y * s;
z = angle.axis.z * s;
w = std::cos(angle.angle / 2);
Normalize();
w = Math::Cos(angle.angle / 2);
bool success = Normalize();
// TODO: Validate normalization success.
}
Quaternion Quaternion::RandomRotation(RNG &rng) {
@@ -367,7 +369,8 @@ namespace J3ML::LinearAlgebra {
y = -sin_roll * cos_pitch * sin_yaw + cos_roll * sin_pitch * cos_yaw;
z = cos_roll * cos_pitch * sin_yaw + sin_roll * sin_pitch * cos_yaw;
w = -sin_roll * sin_pitch * sin_yaw + cos_roll * cos_pitch * cos_yaw;
Normalize();
bool success = Normalize();
// TODO: Validate normalization success.
}
Quaternion::Quaternion(const Quaternion& rhs) {