Data structure and algorithm surface test questions 80 (23)

Source: Internet
Author: User

Question 23rd (algorithm):
The simplest and quickest way to calculate whether the following circle intersects a square. "
3D coordinate system origin (0.0,0.0,0.0)
Circular:
Radius r = 3.0
Center o = (*. *, 0.0, *. *)
Square:
4 angular coordinates;
1: (* *, 0.0, * *)
2: (* *, 0.0, * *)
3: (* *, 0.0, * *)
4: (* *, 0.0, * *)

I don't know what the coordinates are. * * Indicates the value of coordinates?

It is not clear whether circles and squares are solid. If it is solid, then the inclusion is also intersected. If it is hollow, the inclusion is disjoint.

Just tell me if the circle and the square intersect.

Idea: Judging the angle by length is not within the circle. Directly calculates the distance from the angle to the center of the circle, if it is greater then no longer in the garden, less than or equal to the circle, intersect.

If it is solid. This makes it possible to determine if there is a crossover. If it is hollow, it must intersect if there is an angle to the center of the distance equal to the radius. Otherwise, to determine the four corners, if the four corners are in the garden (distance is less than the radius), then does not intersect (circle contains square).

Data structure and algorithm surface test questions 80 (23)

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.