MarketHit-testing
Company Profile

Hit-testing

In computer graphics programming, hit-testing is the process of determining whether a user-controlled cursor intersects a given graphical object drawn on the screen. Hit-testing may be performed on the movement or activation of a mouse or other pointing device.

Algorithm
There are many different algorithms that may be used to perform hit-testing, with different performance or accuracy outcomes. One common hit-test algorithm for axis aligned bounding boxes. A key idea is that the box being tested must be either entirely above, entirely below, entirely to the right or left of the current box. If this is not possible, they are colliding. Example logic is presented in the pseudo-code below: function HitTest(Rectangle r1, Rectangle r2) returns boolean { return not((r1.X + r1.Width r2.X + r2.Width) or (r1.Y + r1.Height r2.Y + r2.Height)); } In Python: def hit_test(r1: Rectangle, r2: Rectangle) -> bool: """Return true if it hits else return false.""" return not ( (r1.x + r1.width r2.x + r2.width) or (r1.y + r1.height r2.y + r2.height) ) ==See also==
tickerdossier.comtickerdossier.substack.com