本文整理汇总了C++中Rect::GetYCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::GetYCenter方法的具体用法?C++ Rect::GetYCenter怎么用?C++ Rect::GetYCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::GetYCenter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static inline bool IsColliding( Rect rect,Circle circle, double angle ){
// Rotate circle's center point back
float centerX = rect.GetXCenter();
float centerY = rect.GetYCenter();
double unrotatedCircleX = cos(angle) * (circle.x - centerX) - sin(angle) * (circle.y - centerY) + centerX;
double unrotatedCircleY = sin(angle) * (circle.x - centerX) + cos(angle) * (circle.y - centerY) + centerY;
double closestX, closestY;
if (unrotatedCircleX < rect.x)
closestX = rect.x;
else if (unrotatedCircleX > rect.x + rect.w)
closestX = rect.x + rect.w;
else
closestX = unrotatedCircleX ;
// Find the unrotated closest y point from center of unrotated circle
if (unrotatedCircleY < rect.y)
closestY = rect.y;
else if (unrotatedCircleY > rect.y + rect.h)
closestY = rect.y + rect.h;
else
closestY = unrotatedCircleY;
// Determine collision
double distance = Point(unrotatedCircleX , unrotatedCircleY).GetDistance(Point(closestX, closestY));
if (distance < circle.r)
return true;
else
return false;
};