本文整理汇总了C++中vec3::abs方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3::abs方法的具体用法?C++ vec3::abs怎么用?C++ vec3::abs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec3
的用法示例。
在下文中一共展示了vec3::abs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make_pair
const std::pair<vec3, vec3> rotate(const vec3 &r, const vec3 &vt, const real dt)
{
const real th = vt.abs()*dt/r.abs();
const real sinth = sin(th);
const real costh = cos(th);
const vec3 rv = r.cross(vt);
const vec3 n = rv/rv.abs();
const vec3 n2(sqr(n.x), sqr(n.y), sqr(n.z));
const real Axx = n2.x + (n2.y + n2.z)*costh;
const real Ayy = n2.y + (n2.x + n2.z)*costh;
const real Azz = n2.z + (n2.x + n2.y)*costh;
const real Axy = n.x*n.y*(1-costh) - n.z*sinth;
const real Axz = n.x*n.z*(1-costh) + n.y*sinth;
const real Ayx = n.x*n.y*(1-costh) + n.z*sinth;
const real Ayz = n.y*n.z*(1-costh) - n.x*sinth;
const real Azx = n.x*n.z*(1-costh) - n.y*sinth;
const real Azy = n.y*n.z*(1-costh) + n.x*sinth;
return std::make_pair(
vec3(
vec3(Axx, Axy, Axz)*r,
vec3(Ayx, Ayy, Ayz)*r,
vec3(Azx, Azy, Azz)*r),
vec3(
vec3(Axx, Axy, Axz)*vt,
vec3(Ayx, Ayy, Ayz)*vt,
vec3(Azx, Azy, Azz)*vt)
);
}
示例2: setView
// Set viewing direction:
void Camera::setView(const vec3& view) {
pitch = degrees(asin(view.y / view.abs()));
yaw = degrees(atan2(view.z, view.x));
}
示例3: Problem_computePvel
bool System::Problem_computePvel()
{
for (int i = 0; i < nactive_loc; i++)
{
MeshPoint &p = *mesh_act[i];
p.vel = 0.0;
const Fluid W = U_act[i]->to_primitive(p.Volume);
p.vel = W.get_vel();
#if 0
const real D = std::log(W[Fluid::DENS]);
const real DV = std::log(DVAC);
const real dD = DV * 0.01/2;
const real r = (D-DV)/std::abs(dD);
const real vfac = (-r > 20) ? 0.0 : 1.0/(1.0 + std::exp(-r));
assert(vfac >= 0.0);
assert(vfac <= 1.0);
p.vel *= vfac;
#endif
#if 1
const real B2 = W.get_B().norm2();
const real pres = Problem_compute_pressure(W);
const real cs2 = (gamma_gas * pres + B2)/W[Fluid::DENS];
const real vel2 = W.get_vel().norm2();
const real vabs = std::sqrt(cs2 + vel2);
const vec3 centroid = cell_list[i].centroid - p.pos;
const real d = centroid.abs();
if (d == 0.0) continue;
const real eta = 0.25f;
const real ki = 1.0f;
const real f1 = 0.9f;
const real f2 = 1.1f;
const real R = std::pow(cell_list[i].Volume * (3.0/(4.0*M_PI)), 1.0/3.0);
const real fac = d/(eta*R);
real f;
if (fac < f1) f = 0.0;
else if (fac < f2) f = (d - f1*eta*R)/((f2 - f1)*eta*R);
else f = 1.0;
real tau = d / vabs;
f *= ki/tau;
p.vel += centroid*f;
if (p.is_boundary()) p.vel = 0.0;
if (p.pos.abs() > RoutBND) p.vel = 0.0;
#endif
p.vel = p.vel - (p.vel*p.pos)*p.pos/p.pos.norm2(); // subtract radial component
#if 0
p.vel = 0.0;
#endif
}
return true;
}