本文整理汇总了C++中vec3::Normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3::Normalize方法的具体用法?C++ vec3::Normalize怎么用?C++ vec3::Normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec3
的用法示例。
在下文中一共展示了vec3::Normalize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: YawPitchRollToUpDirection
bool YawPitchRollToUpDirection(float yaw, float pitch, float roll, vec3& up, vec3& dir)
{
float cos_yaw = cos(yaw);
float cos_pitch = cos(pitch);
float cos_roll = cos(roll);
float sin_yaw = sin(yaw);
float sin_pitch = sin(pitch);
float sin_roll = sin(roll);
dir.Set(sin_yaw * cos_pitch, sin_pitch, cos_pitch * -cos_yaw);
up.Set(-cos_yaw * sin_roll - sin_yaw * sin_pitch * cos_roll, cos_pitch * cos_roll, -sin_yaw * sin_roll - sin_pitch * cos_roll * -cos_yaw);
up.Normalize();
dir.Normalize();
return true;
}
示例2: Lookat
// Generates a look-at matrix
mat4 Lookat(vec3 target, vec3 camera, vec3 up)
{
vec3 forward = (target - camera).Normalize();
vec3 upNorm = up.Normalize();
vec3 side = forward.Cross(upNorm);
vec3 upNew = side.Cross(forward);
mat4 result;
result[0] = vec4(side[0], side[1], side[2], 0.0f);
result[1] = vec4(upNew[0], upNew[1], upNew[2], 0.0f);
result[2] = vec4(forward[0], forward[1], forward[2], 0.0f);
result[3] = vec4(-camera[0], -camera[1], -camera[2], 1.0f);
return result;
}
示例3: getCuTransformParams
void getCuTransformParams(cu_param ¶_trans, paramfile ¶ms, vec3 &campos,
vec3 &lookat, vec3 &sky)
{
int xres = params.find<int>("xres", 800), yres = params.find<int>("yres", xres);
double fov = params.find<double>("fov", 45); //in degrees
double fovfct = tan(fov * 0.5 * degr2rad);
float64 xfac = 0.0, dist = 0.0;
sky.Normalize();
vec3 zaxis = (lookat - campos).Norm();
vec3 xaxis = crossprod(sky, zaxis).Norm();
vec3 yaxis = crossprod(zaxis, xaxis);
TRANSFORM trans;
trans.Make_General_Transform(TRANSMAT(xaxis.x, xaxis.y, xaxis.z, yaxis.x, yaxis.y, yaxis.z,
zaxis.x, zaxis.y, zaxis.z, 0, 0, 0));
trans.Invert();
TRANSFORM trans2;
trans2.Make_Translation_Transform(-campos);
trans2.Add_Transform(trans);
trans = trans2;
bool projection = params.find<bool>("projection", true);
if (!projection)
{
float64 dist = (campos - lookat).Length();
float64 xfac = 1. / (fovfct * dist);
cout << " Field of fiew: " << 1. / xfac * 2. << endl;
}
float minrad_pix = params.find<float>("minrad_pix", 1.);
//retrieve the parameters for transformation
for (int i = 0; i < 12; i++)
para_trans.p[i] = trans.Matrix().p[i];
para_trans.projection = projection;
para_trans.xres = xres;
para_trans.yres = yres;
para_trans.fovfct = fovfct;
para_trans.dist = dist;
para_trans.xfac = xfac;
para_trans.minrad_pix = minrad_pix;
}
示例4: Normalize
vec3 Normalize(vec3 v)
{
v.Normalize();
return v;
}