717 I. Cowboy Beblop at his computer

717 I. Cowboy Beblop at his computer

The meaning of problems: a simple planar polygons in the two spaces given, asking whether the rims are formed of two polygons may be separated from each other.

Solution:
First, it is determined whether the title has been given of the surface can be separated from each other is a method in which the number of polygons is determined through the two kinds of directions as to whether another multilateral.

Then consider another approach to obtain a polygon the polygonal intersection of the plane of all (but not ignored intersection point just passing through) If there is no intersection, it can be isolated;. Otherwise, there are two or more intersections, the intersections may be determined through linear, find the intersection of this line with another polygon for all the intersection sorting may determine whether each edge of the polygon and passing through the other direction through the polygon.

Finally, consider the calculation:
Points in two polygons are \ (P_ {0,0}, P_ {0,1}, \ cdots, P_ {0, m_0-1} \) and \ (P_ {1,0} , of P_ {1,1}, \ cdots, of P_. 1 {,} n_1-1 \) .
first calculate the normal vector of the plane \ (n_0 = P_ {0,0} P_ {0,1} \ times P_ {0,0 of P_} {0,1}, {1,0} of P_ of n_1 of P_ = {1,1} \ Times of P_ of P_ {1,0} {1,2} \) . determines whether two planes parallel or coincident, equivalent in \ (n_0 \ times n_1 \) whether \ (0 \) . If the output is directly parallel or coincident "NO".
then a calculation for each edge of the polygon and passing through the intersection direction of the plane of the other polygon. Analyzing segment \ (of P_ {0, i} P_ {0 , i + 1} \) whether the plane \ (P_ {1,0} P_ { 1,1} P_ {1,2} \) intersect, is equivalent to determining \ (of n_1 \ cdot P_ {1,0} P_ {0 , i} \) and \ (\ cdot P_ {1,0} P_ {0, i + 1} \) n_1 are the same symbol. If a symbol is 0, then we can be viewed as a line segment passing through the plane half times embodied by two symbols can be represented by subtracting the line segment passing through the plane of the case.
after determining the intersection, the intersection need to sort required. Suppose \ (P_ {0, i} P_ {0, i + 1} \) to the plane\ (P_ {1,0} P_ { 1,1} P_ {1,2} \) intersects the \ (X-\) , and let \ (P_ {0, i} X = kP_ {0, i} P_ { 0, + I. 1} \) . then \ (X-of P_ {1,0} {1,0} of P_ of P_ = {0, I + kP_ {0}, {I} of P_ 0, + I. 1} \) , sides and \ (of n_1 \) dot product obtained \ (0 = P_ {1,0} P_ {0, i} \ cdot n_1 + kP_ {0, i} P_ {0, i + 1} \ cdot n_1 \ ) . was calculated (K \) \ can be obtained after \ (X-\) coordinates.
Finally, the two-plane direction of intersection line of each intersection \ (X-\) dot product, namely \ ((n_1 \ times n_2) \ X-CDOT \) , corresponding to the projected points on the direction, may be used instead of the coordinates of the sort result.

Achieved in some strange questions: the theoretical calculation of the final dot product range is the range of coordinates \ (5 \) th but did not data card. long longYou can use too. doubleIt will Time limit exceeded.

Code

Guess you like

Origin www.cnblogs.com/Heltion/p/11369938.html