Determine whether a rectangle and a circle are intersecting

Source: Internet
Author: User

Determine whether a rectangle and a circle are intersecting

Ideas:

Method 1: first determine whether the rectangle is in the circle (whether the four vertices of the rectangle are in the circle). If so, otherwise, judge whether the shortest distance from the center of the circle to the four sides of the rectangle (the shortest distance from the point to the line segment) is smaller than the radius. If yes, the rectangle (including the circle) is not intersecting, ).

Method 2: The Circular split plane is divided into four parts. Method 2: The Circular split plane is divided into four parts, which are separated by the following types: the rectangle is above the circular area, the rectangle is under the circular area, and the rectangle is on the left side of the circular area, the rectangle is on the right of the circle, inside the circle, and inside the rectangle.

Method 3: The rectangle is divided into nine parts in the plane. The four sides of the rectangle are used to divide the space into nine areas. The center of the rectangle is located in that area. If it is inside the rectangle, the intersection is inevitable. If it is located in the top, bottom, left, and right sides of the four edge areas, it checks the distance from the center to the edge to determine whether it is intersecting. If it is located in the area corresponding to the four corner points, check whether the four corners of the rectangle are inside the circle.

[Reference]

Http://www.cnblogs.com/hxsyl/p/3250015.html

 

Determine whether a rectangle and a circle are intersecting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.