Home > Net >  A simple algorithm, discuss.
A simple algorithm, discuss.

Time:11-01

Known radius of a circle, the center coordinates of the center of a rectangular coordinates, and width, to write a c # program to judge circular and rectangular position: intersection, containing, depart, tangent, etc.,

CodePudding user response:

Think along while, drew the along while, said a word or two to return true.
General idea:
Rectangular outside to create a distance of r buffer, get the casing outside the buffer curve (consisting of four straight lines, four quadrant), write a algorithm to judge circle on the buffer curve, the curve, the curve. The curve, and tangent, foreign curve. The curve points: in the intersection or contain, continue again after this time is:
If the rectangle are small, can be included in the circle (r> H& & R> W),
If the rectangle is bigger, can contain circle, need to create a distance of r in the rectangular buffers (this should be a rectangular) : similar to the above logic, judge the position and the center of the circle buffer curve relationship: or, rectangular contain circular, curve, intersection.
General logic, may not be too strict, his painting figure, and then write code debugging, consuming brain

CodePudding user response:

Rectangular rotation Angle?

CodePudding user response:

refer to the second floor icoolno1 response:
rectangular rotation Angle?

Temporary not consider Angle first, I think it will

CodePudding user response:

If is the general judgment, the relationship between two shape, in fact, if "deliberately simplify" for rectangle and circle the judgment of the relationship, this may well be partial, because of the shape of the general judgment method and not from the latter to inherit and upgrade,

Understand the relationship between two shapes, the first thing to understand the relationship between two external rectangular graphics, through the two rectangular "left, right, up and down the value of simple than size" algorithm "to judge whether the intersection, for graphics not and mutually leave, only need to traverse each point in one of the external rectangular, see if there was a certain point is" hit "into two graphics (along the edge of the graphics on the left walk counterclockwise, always on the left; Or this point x, y direction of the straight line, line with graphic node is an odd number or an even number, etc), if there are any such, it is the intersection of,

CodePudding user response:

Through the two rectangular "left, right, up and down the value of simple than size" algorithm "to determine whether phase

CodePudding user response:

Grab a "computer graphics" textbook, to copy the algorithm, the program design is a kind of practice, to learn the basic knowledge of many, learn some basic to use in the future,

CodePudding user response:

this is a math problem

CodePudding user response:

By controlling the rectangle
  •  Tags:  
  • C#