本文整理汇总了C++中Vector2::AngleBetween方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2::AngleBetween方法的具体用法?C++ Vector2::AngleBetween怎么用?C++ Vector2::AngleBetween使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2
的用法示例。
在下文中一共展示了Vector2::AngleBetween方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unitVec
void Vector2::RotateAround(Vector2 origin, double rotation) {
Vector2 fromMid = *this - origin;
Vector2 unitVec(1, 0);
double angleFrom0 = fromMid.AngleBetween(unitVec);
if (fromMid.y < 0) {
angleFrom0 *= -1;
}
angleFrom0 += rotation;
Vector2 endMove(cos(angleFrom0), sin(angleFrom0));
endMove *= fromMid.Magnitude();
endMove = origin + endMove;
*this = endMove;
}
示例2: unitVec
Vector2 Vector2::RotateAround(Vector2 origin, float rotation) const {
if (rotation == 0) {
return *this;
}
Vector2 fromMid = *this - origin;
Vector2 unitVec(1, 0);
float angleFrom0 = fromMid.AngleBetween(unitVec);
angleFrom0 -= rotation;
Vector2 endMove(cos(angleFrom0), sin(angleFrom0));
endMove *= fromMid.Magnitude();
endMove = origin + endMove;
return endMove;
}