mirror of
https://github.com/orange-cpp/omath.git
synced 2026-06-08 16:24:35 +00:00
added safety check
This commit is contained in:
@@ -628,10 +628,16 @@ namespace omath
|
|||||||
return static_cast<Type>(std::sqrt(x * x + y * y + z * z));
|
return static_cast<Type>(std::sqrt(x * x + y * y + z * z));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const auto scale_x = column_length(mat.at(0, 0), mat.at(1, 0), mat.at(2, 0));
|
||||||
|
const auto scale_y = column_length(mat.at(0, 1), mat.at(1, 1), mat.at(2, 1));
|
||||||
|
const auto scale_z = column_length(mat.at(0, 2), mat.at(1, 2), mat.at(2, 2));
|
||||||
|
|
||||||
|
constexpr auto epsilon = std::numeric_limits<Type>::epsilon();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
column_length(mat.at(0, 0), mat.at(1, 0), mat.at(2, 0)),
|
std::abs(scale_x) < epsilon ? Type{1} : scale_x,
|
||||||
column_length(mat.at(0, 1), mat.at(1, 1), mat.at(2, 1)),
|
std::abs(scale_y) < epsilon ? Type{1} : scale_y,
|
||||||
column_length(mat.at(0, 2), mat.at(1, 2), mat.at(2, 2)),
|
std::abs(scale_z) < epsilon ? Type{1} : scale_z,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user