mirror of
https://github.com/orange-cpp/omath.git
synced 2026-06-08 16:24:35 +00:00
added improvement
This commit is contained in:
@@ -34,6 +34,27 @@ namespace omath::cry_engine
|
||||
* mat_rotation_axis_y<float, MatStoreType::ROW_MAJOR>(angles.roll)
|
||||
* mat_rotation_axis_x<float, MatStoreType::ROW_MAJOR>(angles.pitch);
|
||||
}
|
||||
|
||||
Vector3<float> extract_origin(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_origin(mat);
|
||||
}
|
||||
|
||||
Vector3<float> extract_scale(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_scale(mat);
|
||||
}
|
||||
|
||||
ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
|
||||
{
|
||||
const auto angles = mat_extract_rotation_zyx(mat);
|
||||
return {
|
||||
PitchAngle::from_degrees(angles.x),
|
||||
YawAngle::from_degrees(angles.z),
|
||||
RollAngle::from_degrees(angles.y),
|
||||
};
|
||||
}
|
||||
|
||||
Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near,
|
||||
const float far, const NDCDepthRange ndc_depth_range) noexcept
|
||||
{
|
||||
|
||||
@@ -34,6 +34,27 @@ namespace omath::frostbite_engine
|
||||
* mat_rotation_axis_y<float, MatStoreType::ROW_MAJOR>(angles.yaw)
|
||||
* mat_rotation_axis_x<float, MatStoreType::ROW_MAJOR>(angles.pitch);
|
||||
}
|
||||
|
||||
Vector3<float> extract_origin(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_origin(mat);
|
||||
}
|
||||
|
||||
Vector3<float> extract_scale(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_scale(mat);
|
||||
}
|
||||
|
||||
ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
|
||||
{
|
||||
const auto angles = mat_extract_rotation_zyx(mat);
|
||||
return {
|
||||
PitchAngle::from_degrees(angles.x),
|
||||
YawAngle::from_degrees(angles.y),
|
||||
RollAngle::from_degrees(angles.z),
|
||||
};
|
||||
}
|
||||
|
||||
Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near,
|
||||
const float far, const NDCDepthRange ndc_depth_range) noexcept
|
||||
{
|
||||
|
||||
@@ -30,6 +30,26 @@ namespace omath::iw_engine
|
||||
return mat_rotation_axis_z(angles.yaw) * mat_rotation_axis_y(angles.pitch) * mat_rotation_axis_x(angles.roll);
|
||||
}
|
||||
|
||||
Vector3<float> extract_origin(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_origin(mat);
|
||||
}
|
||||
|
||||
Vector3<float> extract_scale(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_scale(mat);
|
||||
}
|
||||
|
||||
ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
|
||||
{
|
||||
const auto angles = mat_extract_rotation_zyx(mat);
|
||||
return {
|
||||
PitchAngle::from_degrees(angles.y),
|
||||
YawAngle::from_degrees(angles.z),
|
||||
RollAngle::from_degrees(angles.x),
|
||||
};
|
||||
}
|
||||
|
||||
Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||
{
|
||||
return mat_camera_view(forward_vector(angles), right_vector(angles), up_vector(angles), cam_origin);
|
||||
|
||||
@@ -36,6 +36,27 @@ namespace omath::opengl_engine
|
||||
* mat_rotation_axis_y<float, MatStoreType::COLUMN_MAJOR>(angles.yaw)
|
||||
* mat_rotation_axis_x<float, MatStoreType::COLUMN_MAJOR>(angles.pitch);
|
||||
}
|
||||
|
||||
Vector3<float> extract_origin(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_origin(mat);
|
||||
}
|
||||
|
||||
Vector3<float> extract_scale(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_scale(mat);
|
||||
}
|
||||
|
||||
ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
|
||||
{
|
||||
const auto angles = mat_extract_rotation_zyx(mat);
|
||||
return {
|
||||
PitchAngle::from_degrees(angles.x),
|
||||
YawAngle::from_degrees(angles.y),
|
||||
RollAngle::from_degrees(angles.z),
|
||||
};
|
||||
}
|
||||
|
||||
Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near,
|
||||
const float far, const NDCDepthRange ndc_depth_range) noexcept
|
||||
{
|
||||
|
||||
@@ -17,6 +17,26 @@ namespace omath::source_engine
|
||||
return mat_rotation_axis_z(angles.yaw) * mat_rotation_axis_y(angles.pitch) * mat_rotation_axis_x(angles.roll);
|
||||
}
|
||||
|
||||
Vector3<float> extract_origin(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_origin(mat);
|
||||
}
|
||||
|
||||
Vector3<float> extract_scale(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_scale(mat);
|
||||
}
|
||||
|
||||
ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
|
||||
{
|
||||
const auto angles = mat_extract_rotation_zyx(mat);
|
||||
return {
|
||||
PitchAngle::from_degrees(angles.y),
|
||||
YawAngle::from_degrees(angles.z),
|
||||
RollAngle::from_degrees(angles.x),
|
||||
};
|
||||
}
|
||||
|
||||
Vector3<float> right_vector(const ViewAngles& angles) noexcept
|
||||
{
|
||||
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right);
|
||||
|
||||
@@ -34,6 +34,27 @@ namespace omath::unity_engine
|
||||
* mat_rotation_axis_y<float, MatStoreType::ROW_MAJOR>(angles.yaw)
|
||||
* mat_rotation_axis_x<float, MatStoreType::ROW_MAJOR>(angles.pitch);
|
||||
}
|
||||
|
||||
Vector3<float> extract_origin(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_origin(mat);
|
||||
}
|
||||
|
||||
Vector3<float> extract_scale(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_scale(mat);
|
||||
}
|
||||
|
||||
ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
|
||||
{
|
||||
const auto angles = mat_extract_rotation_zyx(mat);
|
||||
return {
|
||||
PitchAngle::from_degrees(angles.x),
|
||||
YawAngle::from_degrees(angles.y),
|
||||
RollAngle::from_degrees(angles.z),
|
||||
};
|
||||
}
|
||||
|
||||
Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near,
|
||||
const float far, const NDCDepthRange ndc_depth_range) noexcept
|
||||
{
|
||||
|
||||
@@ -39,6 +39,26 @@ namespace omath::unreal_engine
|
||||
}
|
||||
|
||||
|
||||
Vector3<double> extract_origin(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_origin(mat);
|
||||
}
|
||||
|
||||
Vector3<double> extract_scale(const Mat4X4& mat) noexcept
|
||||
{
|
||||
return mat_extract_scale(mat);
|
||||
}
|
||||
|
||||
ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
|
||||
{
|
||||
const auto angles = mat_extract_rotation_zyx(mat);
|
||||
return {
|
||||
PitchAngle::from_degrees(-angles.y),
|
||||
YawAngle::from_degrees(angles.z),
|
||||
RollAngle::from_degrees(-angles.x),
|
||||
};
|
||||
}
|
||||
|
||||
Mat4X4 calc_perspective_projection_matrix(const double field_of_view, const double aspect_ratio, const double near,
|
||||
const double far, const NDCDepthRange ndc_depth_range) noexcept
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user