What is AABB – Collision detection?

AABB stands for “Axis-Aligned Bounding Box.” It is a fairly computationally- and memory-efficient way of representing a volume, typically used to see if two objects might be touching. Since it is axis-aligned, it does not necessarily “fit” your real 3D object very well. AABB checks are often used as a coarse first-approximation to see if … Read more

iOS: verify if a point is inside a rect

Swift 4 let view = … let point = … view.bounds.contains(point) Objective-C Use CGRectContainsPoint(): bool CGRectContainsPoint(CGRect rect, CGPoint point); Parameters rect The rectangle to examine. point The point to examine. Return Value true if the rectangle is not null or empty and the point is located within the rectangle; otherwise, false. A point is considered … Read more

Circle-Rectangle collision detection (intersection)

Here is how I would do it: bool intersects(CircleType circle, RectType rect) { circleDistance.x = abs(circle.x – rect.x); circleDistance.y = abs(circle.y – rect.y); if (circleDistance.x > (rect.width/2 + circle.r)) { return false; } if (circleDistance.y > (rect.height/2 + circle.r)) { return false; } if (circleDistance.x <= (rect.width/2)) { return true; } if (circleDistance.y <= (rect.height/2)) … Read more

Ball to Ball Collision – Detection and Handling

To detect whether two balls collide, just check whether the distance between their centers is less than two times the radius. To do a perfectly elastic collision between the balls, you only need to worry about the component of the velocity that is in the direction of the collision. The other component (tangent to the … Read more

How can I determine whether a 2D Point is within a Polygon?

For graphics, I’d rather not prefer integers. Many systems use integers for UI painting (pixels are ints after all), but macOS, for example, uses float for everything. macOS only knows points and a point can translate to one pixel, but depending on monitor resolution, it might translate to something else. On retina screens half a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)