本文整理汇总了C++中vec::equals方法的典型用法代码示例。如果您正苦于以下问题:C++ vec::equals方法的具体用法?C++ vec::equals怎么用?C++ vec::equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec
的用法示例。
在下文中一共展示了vec::equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: arcball_move
// update current arcball rotation
void arcball_move(int mx, int my)
{
if(ab_planar)
{
ab_curr = planar_coords((GLdouble)mx,(GLdouble)my);
if(ab_curr.equals(ab_start)) return;
// d is motion since the last position
vec d = ab_curr - ab_start;
GLfloat angle = d.length() * 0.5;
GLfloat cosa = cos( angle );
GLfloat sina = sin( angle );
// p is perpendicular to d
vec p = ((ab_out*d.x)-(ab_up*d.y)).unit() * sina;
quaternion(ab_next,p.x,p.y,p.z,cosa);
quatnext(ab_quat,ab_last,ab_next);
// planar style only ever relates to the last point
quatcopy(ab_last,ab_quat);
ab_start = ab_curr;
} else {
ab_curr = sphere_coords((GLdouble)mx,(GLdouble)my);
if(ab_curr.equals(ab_start))
{ // avoid potential rare divide by tiny
quatcopy(ab_quat,ab_last);
return;
}
// use a dot product to get the angle between them
// use a cross product to get the vector to rotate around
GLfloat cos2a = ab_start*ab_curr;
GLfloat sina = sqrt((1.0 - cos2a)*0.5);
GLfloat cosa = sqrt((1.0 + cos2a)*0.5);
vec cross = (ab_start^ab_curr).unit() * sina;
quaternion(ab_next,cross.x,cross.y,cross.z,cosa);
// update the rotation matrix
quatnext(ab_quat,ab_last,ab_next);
}
}