本文整理汇总了C++中vector3f::normalized方法的典型用法代码示例。如果您正苦于以下问题:C++ vector3f::normalized方法的具体用法?C++ vector3f::normalized怎么用?C++ vector3f::normalized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector3f
的用法示例。
在下文中一共展示了vector3f::normalized方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lookAt
void Camera::lookAt(const vector3f &refPos, const vector3f &upVector)
{
front = refPos.normalized();
up = upVector.normalized();
vector3f s = cross(front, up);
vector3f u = cross(s, front);
view = matrix4f(
s.x, u.x, -front.x, 0,
s.y, u.y, -front.y, 0,
s.z, u.z, -front.z, 0,
0, 0, 0, 1
);
}
示例2:
matrix4x4 matrix4x4::rotation_around_axis(vector3f const& axis, float const radians)
{
vector3f axis_normalized{axis.normalized()};
float const cos_value{std::cos(radians)};
float const sin_value{std::sin(radians)};
return matrix4x4{
axis_normalized.x * axis_normalized.x * (1.0f - cos_value) + cos_value,
axis_normalized.x * axis_normalized.y * (1.0f - cos_value) + axis_normalized.z * sin_value,
axis_normalized.x * axis_normalized.z * (1.0f - cos_value) - axis_normalized.y * sin_value,
0.0f,
axis_normalized.x * axis_normalized.y * (1.0f - cos_value) - axis_normalized.z * sin_value,
axis_normalized.y * axis_normalized.y * (1.0f - cos_value) + cos_value,
axis_normalized.y * axis_normalized.z * (1.0f - cos_value) + axis_normalized.x * sin_value,
0.0f,
axis_normalized.x * axis_normalized.z * (1.0f - cos_value) + axis_normalized.y * sin_value,
axis_normalized.y * axis_normalized.z * (1.0f - cos_value) - axis_normalized.x * sin_value,
axis_normalized.z * axis_normalized.z * (1.0f - cos_value) + cos_value,
0.0f,
0.0f,
0.0f,
0.0f,
1.0f};
}
示例3:
camera::camera(
vector3f const& position,
vector3f const& forward,
vector3f const& fake_up,
float const horizontal_fov,
float const aspect_ratio,
float const near_plane_z,
float const far_plane_z)
: m_position{position},
m_forward{forward.normalized()},
m_horizontal_fov{horizontal_fov},
m_vertical_fov{horizontal_fov * aspect_ratio},
m_aspect_ratio{aspect_ratio},
m_near_plane_z{near_plane_z},
m_far_plane_z{far_plane_z}
{
establish_coordinate_system(fake_up.normalized());
}