Petya has recently started working as a programmer in the IT city company that develops…
- User
Petya has recently started working as a programmer in the IT city company that develops computer games.
Besides game mechanics implementation to create a game it is necessary to create tool programs that can be used by game designers to create game levels. Petya's first assignment is to create a tool that allows to paint different arrows on the screen.
A user of this tool will choose a point on the screen, specify a vector (the arrow direction) and vary several parameters to get the required graphical effect. In the first version of the program Petya decided to limit parameters of the arrow by the following: a point with coordinates (px, py), a nonzero vector with coordinates (vx, vy), positive scalars a, b, c, d, a > c.
The produced arrow should have the following properties. The arrow consists of a triangle and a rectangle. The triangle is isosceles with base of length a and altitude of length b perpendicular to the base. The rectangle sides lengths are c and d. Point (px, py) is situated in the middle of the triangle base and in the middle of side of rectangle that has length c. Area of intersection of the triangle and the rectangle is zero. The direction from (px, py) point to the triangle vertex opposite to base containing the point coincides with direction of (vx, vy) vector.
Enumerate the arrow points coordinates in counter-clockwise order starting from the tip.
The only line of the input contains eight integers px, py, vx, vy ( - 1000 ≤ px, py, vx, vy ≤ 1000, vx2 + vy2 > 0), a, b, c, d (1 ≤ a, b, c, d ≤ 1000, a > c).
Output
Output coordinates of the arrow points in counter-clockwise order. Each line should contain two coordinates, first x, then y. Relative or absolute error should not be greater than 10 - 9.
Examples
Input
8 8 0 2 8 3 4 5
Output
8.000000000000 11.000000000000 4.000000000000 8.000000000000 6.000000000000 8.000000000000 6.000000000000 3.000000000000 10.000000000000 3.000000000000 10.000000000000 8.000000000000 12.000000000000 8.000000000000
Assistant
We need to compute the coordinates of an arrow defined by parameters: point (px, py), vector (vx, vy) (nonzero), scalars a, b, c, d with a > c.
Interpretation: The arrow consists of a triangle and a rectangle. The triangle is isosceles with base length a and altitude length b (perpendicular to base). The rectangle sides lengths are c and d.
Point (px, py) is situated:
- in the middle of the triangle base
- in the middle of side of rectangle that has length c.
Also: "Area of intersection of the triangle and the rectangle is zero." So they do not overlap (except possibly touching along boundary? Probably they share the point? Actually they might be adjacent: the rectangle attaches to the base of the triangle? Usually an arrow: the triangle is the arrowhead, and the rectangle is the shaft. So the rectangle extends from the base of the triangle in the opposite direction of the arrowhead.
The direction from (px, py) to the triangle vertex opposite to base containing the point coincides with direction of (vx, vy) vector. So the triangle's tip is in the direction of (vx, vy) from the base midpoint.
Thus the base of the triangle is perpendicular to the direction of the tip? Actually in an isosceles triangle, the altitude goes from the base to the opposite vertex. The direction from the base midpoint (which is the foot of the altitude) to the vertex is along the altitude. So that direction is perpendicular to the base. So the vector (vx, vy) points from the base midpoint to the tip. So the tip is at (px, py) + t * (vx, vy) for some positive scaling. The altitude length is b. So the distance from (px, py) to the tip should be b. So t = b / sqrt(vx^2+vy^2). So the tip coordinate is (px + vx * b / len, py + vy * b / len). That's straightforward.
Now the base of the triangle has length a, and its midpoint is at (px, py). The base is perpendicular to the direction vector (vx, vy). So we need two points that are the endpoints of the base: each at distance a/2 from (px, py) along a direction perpendicular to (vx, vy). So we can define a unit vector perpendicular to (vx, vy). Since we need counter-clockwise order starting from the tip, we need to determine the ordering of all points.
The arrow consists of the triangle and the rectangle. But "enumerate the arrow points coordinates in counter-clockwise order starting from the tip." This suggests that we output the polygon that is the union of triangle and rectangle? But union of two polygons might be a polygon with 7 vertices? Let's think: Typically an arrow shape: triangle arrowhead attached to a rectangle shaft. The rectangle is placed such that one of its sides of length c coincides with the base of the triangle? But they said: "Area of intersection of the triangle and the rectangle is zero." So they do not overlap; they could share a segment. The rectangle side of length c is placed such that its midpoint is at (px, py). That side of length c is the one attached to the triangle base? Since the triangle base has length a, and a > c, so the rectangle side is shorter than the triangle base. So the rectangle is attached to the triangle base, probably centered. But the triangle and rectangle might share a region? Intersection area zero means they may only touch at the boundary along the shared part. So if the rectangle side of length c is exactly the part of the triangle base? But the triangle base is length a > c, so only part of the triangle base is overlapped by the rectangle side? But that would create overlap if the rectangle extends from that side into the triangle? Actually the rectangle's side of length c is centered at (px, py) and lies along the triangle base? Possibly the rectangle is placed such that its side of length c is collinear with the triangle base, and the rectangle extends away from the triangle (opposite direction of the arrowhead). Then the rectangle and triangle share a line segment of length c along the triangle base (the portion of the base that is covered by the rectangle's side). But then the triangle and rectangle intersect over that line segment? But area of intersection is zero if they only share a boundary. So that's acceptable if they only share a line segment; area of overlap is zero. So the rectangle essentially is attached to the triangle base, but is outside the triangle (the interior of the rectangle does not intersect interior of triangle). So the union shape is a polygon with 7 vertices? Let's draw: Triangle vertices: tip (T), two base endpoints (B_left and B_right). Rectangle: a rectangle with one side of length c (the side that attaches to triangle) centered at (px, py), and the other side extends a distance d away from the triangle (opposite direction). Since the rectangle side is of length c, its endpoints are at a distance c/2 from (px, py) along the base direction (perpendicular to arrow). So those two points are on the triangle base line, but inside the triangle base (since a > c, these points are between the triangle base endpoints). Then the rectangle extends from these points in the direction opposite to the arrow (i.e., opposite to v) for distance d. So rectangle vertices: The two points on the base: let's call them R1 and R2 (order?). Then from each of these, go by vector opposite to v (i.e., -v direction) multiplied by d / len to get the far rectangle vertices (R3 and R4). So rectangle vertices: R1 (left side of rectangle? depends orientation) and R2 (right side) along the base direction, then R2' = R2 - (d * unit v) (since v points towards tip, rectangle extends opposite direction), and R1' = R1 - (d * unit v). Or maybe the rectangle extends from the base side? Since the side of length c is the one that is attached, and the rectangle's other side is parallel and of length c as well? Actually rectangle sides lengths: c and d. Which side is length c? It says: "Point (px, py) is situated ... in the middle of side of rectangle that has length c." So the side of the rectangle that contains (px, py) as its midpoint has length c. So that side is the "attached" side. The other side also has length c? Typically rectangle has two pairs of opposite sides. If one side length is c, then the opposite side is also c. And the other sides (adjacent) are length d. So the rectangle has dimensions: width (the side attached) = c, and height (depth) = d, or vice versa. But we know that the attached side has length c. So the rectangle's two sides of length c are the ones parallel to the base direction. The sides of length d are perpendicular to the base direction, extending from the base endpoints in the opposite direction of v. So the rectangle's four vertices: The attached side endpoints: let's denote them as M1 and M2 (midpoints? Actually the side's endpoints). The side is of length c and centered at (px, py). So M1 = (px, py) + (c/2) * unit_perp (some orientation), M2 = (px, py) - (c/2) * unit_perp. Then from M1 and M2, we go in the direction opposite to v by distance d to get the other two vertices: M1' = M1 - d * unit_v, M2' = M2 - d * unit_v. So rectangle vertices in order: say M1, M1', M2', M2 (going around). Or M1, M2, M2', M1', depending orientation and order (ccw). We need to output the union polygon (arrow shape) in ccw order starting from tip. The union shape consists of triangle (tip, B_left, B_right) and rectangle (M1, M1', M2', M2). However, the triangle base vertices B_left and B_right are at distances a/2 from (px, py) along the same perpendicular direction as M1 and M2? Yes, since base is along the same direction (perpendicular to v). So B_left is further out than M1 (since a/2 > c/2). So the shape's boundary: starting at tip, then go to one of the base endpoints? But note that the rectangle covers the central part of the base. So the shape's outline: from tip, go to the left base endpoint? Actually need to decide orientation: We'll have an outer polygon that goes around the entire shape. The shape is basically a triangle with a rectangular bite taken out from its base? No, the rectangle extends outward from base, so the union is like a triangle with a rectangle attached to its base. But since the rectangle is attached along a segment (the central part of the base), the overall polygon will have vertices: tip, then B_left (one triangle base endpoint), then perhaps M1? But careful: The triangle base from B_left to B_right is a line segment. However, the rectangle's attached side is from M1 to M2, which lies on the same line but inside the base segment. So the union's boundary includes the entire triangle boundary, except that the portion of the base between M1 and M2 is replaced by the rectangle's outer boundary: from M1 go out along rectangle to M1', then to M2', then back to M2, and then continue along the triangle base from M2 to B_right? But that would create a shape that is not a simple polygon? Let's think: The union of triangle and rectangle: The triangle is defined by vertices T (tip), L (left base endpoint), R (right base endpoint). The rectangle is defined by vertices (M1, M1', M2', M2) where M1 and M2 are on the base line between L and R, and the rectangle extends outward from the base (opposite direction of arrow). The union shape includes both interior regions. The outer boundary will be: starting at T, go to L (triangle edge). Then from L, go along the triangle base edge towards the right until hitting M1? Wait L is left base endpoint. M1 is some point to the right of L? Actually which side is left and right? We need to define orientation. The vector v gives direction to tip. Typically, if we look in the direction of v (arrow direction), the base is perpendicular. Let's define coordinate system: Let unit vector u = (vx, vy)/len (direction to tip). Let unit vector w = perpendicular to u, obtained by rotating u 90 degrees counterclockwise? Actually we need to decide orientation of the base endpoints relative to the vector direction. The triangle is isosceles; the base endpoints are symmetric. Which one is considered first in ccw order starting from tip? We need to output polygon vertices in ccw order. Starting from tip, the polygon goes around the shape. For a typical arrow pointing up (v = (0,1)), the tip is at top, base is horizontal below. In ccw order starting from tip: tip, then right base endpoint? Let's test: Suppose arrow points up. Tip at (0,0)? Actually example: Input: 8 8 0 2 8 3 4 5. So px=8, py=8, v=(0,2). That's upward direction? Actually (0,2) points upward (positive y). Tip direction: from (8,8) upwards. a=8, b=3, c=4, d=5.
Compute: len(v)=2. b=3 so tip distance = 3 from base? Actually b is altitude length, so tip is at (8,8) + (0,2)*(3/2)= (8,8)+(0,3)= (8,11). So tip at (8,11). Example output: first line: 8.000000000000 11.000000000000. Good.
Then they output: 4.000000000000 8.000000000000; 6.000000000000 8.000000000000; 6.000000000000 3.000000000000; 10.000000000000 3.000000000000; 10.000000000000 8.000000000000; 12.000000000000 8.000000000000.
So total 7 points (tip + 6 others). So polygon has 7 vertices. The order: tip (8,11). Next: (4,8). Then (6,8). Then (6,3). Then (10,3). Then (10,8). Then (12,8). Then presumably back to tip. So let's reconstruct.
Given arrow pointing up, base is horizontal. Triangle base length a=8, so base endpoints are at (8-4,8)= (4,8) and (8+4,8)= (12,8). Indeed (4,8) and (12,8) are the triangle base endpoints. But output lists (4,8) and then (12,8) appears last. However they also have (6,8) and (10,8) which are points on the base? (6,8) and (10,8) are on the base as well, but they are not the endpoints. They are at distances 2 from center? Because c=4, so rectangle side length 4 centered at (8,8), so its endpoints are (8-2,8)= (6,8) and (8+2,8)= (10,8). So indeed (6,8) and (10,8) are the rectangle's attached side endpoints. Then rectangle extends down (opposite to arrow direction) by d=5. Since arrow points up, opposite is down. So from (6,8) go down 5 => (6,3). And from (10,8) go down 5 => (10,3). So rectangle vertices: (6,8) -> (6,3) -> (10,3) -> (10,8) (if going ccw). However the output order after (4,8) is (6,8) then (6,3) then (10,3) then (10,8) then (12,8). That seems to go: from tip, to left base endpoint (4,8). Then to rectangle left attach point (6,8) (which is to the right of left endpoint). Then down to (6,3). Then across to (10,3). Then up to (10,8). Then to right base endpoint (12,8). Then back to tip? That forms a polygon. Check ccw orientation: For shape pointing up, the outer boundary likely goes: tip (top), then left base endpoint, then down-left? Actually left base endpoint is at (4,8). Then we go along base to the right to (6,8). That's interior? But the base from (4,8) to (6,8) is part of triangle boundary, but then we go to (6,8) which is also on rectangle. But then from (6,8) we go down to (6,3) (rectangle left side), then across to (10,3) (rectangle bottom), then up to (10,8) (rectangle right side), then from (10,8) go along base to (12,8) (triangle right base endpoint), then from (12,8) back to tip (8,11) along triangle right edge. That describes the outer polygon. But note that from (4,8) to (6,8) is along the triangle base; from (10,8) to (12,8) is also along base; and the segment (6,8)-(10,8) is the attached side of the rectangle which is collinear with the base, but is that part of outer boundary? Actually the outer boundary includes the rectangle's outer edges, but the rectangle's top side (the side attached) is exactly the segment (6,8)-(10,8), which lies along the triangle base. However, the triangle base segment (4,8)-(12,8) is fully present, but the part from (6,8) to (10,8) is shared by both triangle and rectangle; including it twice would cause an interior indent? In the described polygon, the base part from (4,8) to (6,8) and from (10,8) to (12,8) are used, but the segment (6,8)-(10,8) is also included as a boundary? Let's see polygon sequence: (4,8) -> (6,8) -> (6,3) -> (10,3) -> (10,8) -> (12,8). So the edge from (4,8) to (6,8) is along base. Then from (6,8) to (6,3) is vertical down (rectangle left side). Then from (6,3) to (10,3) is bottom horizontal (rectangle bottom). Then from (10,3) to (10,8) is vertical up (rectangle right side). Then from (10,8) to (12,8) is along base again. So the base segment from (6,8) to (10,8) is not an edge: actually the edge from (6,8) to (10,8) is skipped because we go from (6,8) to (6,3) (so we leave the base). But then we come back to (10,8) from below, and then go to (12,8). So the segment (6,8)-(10,8) is not part of the polygon boundary; it's inside the shape? Wait, the rectangle's top side is (6,8)-(10,8). But in the polygon, that segment is not traversed; instead we have a "dent"? Let's draw: The shape is like an arrowhead triangle with base from (4,8) to (12,8) and tip at (8,11). Attached to the base is a rectangle of width 4 (from x=6 to 10) extending downward 5. The union shape: The triangle covers region above the base. The rectangle covers region below the base, but only from x=6 to 10, and down to y=3. The overall shape is not convex; there is a notch? Actually, the shape includes the triangle's full area above the base, and the rectangle's area below the base. But the rectangle only occupies the central part of the base; the left and right parts of the base (x=4-6 and x=10-12) have no rectangle below; the shape's boundary there is just the triangle edge down to the base and then? Wait the triangle's interior is only above the base; below the base is empty (outside) except where rectangle exists. So the union shape includes region above the base line (the triangle) and region below the base line for x in [6,10] (the rectangle). So the overall shape's boundary goes: from tip to left base point (4,8). Then from (4,8) we follow the triangle base to the right? But the triangle interior is above the base; the base is a boundary between interior (above) and exterior (below) except where rectangle is attached. For x between 6 and 10, below the base is interior (the rectangle). So the boundary along the base from (4,8) to (6,8) is a boundary: above is interior, below is exterior. Then at (6,8), the rectangle starts; the boundary goes downward along rectangle left side (from (6,8) to (6,3)) because to the left of that line, there is no rectangle; so that is boundary between interior (right side?) Actually to the left of the rectangle left side, it's exterior; to the right, interior. Then along bottom (6,3)-(10,3) (below is exterior, above interior). Then up rectangle right side (10,3)-(10,8). Then from (10,8) to (12,8) along the base again: above interior, below exterior. Then from (12,8) back to tip via triangle right side.
Thus the polygon's vertices, in ccw order starting from tip, would be: tip, left base endpoint, then rectangle left attach point, then rectangle bottom left, rectangle bottom right, rectangle right attach point, then right base endpoint, and back to tip. But in the example, the order is: tip, (4,8), (6,8), (6,3), (10,3), (10,8), (12,8). That matches exactly.
Now we need to determine orientation (which side is left, which is right) to ensure ccw order. The example: v=(0,2) points up. The base is horizontal. The left base endpoint is at x=4, right at x=12. The order: tip (8,11) -> (4,8) (left) -> (6,8) (still left side but moving right along base) -> then down to (6,3) -> across to (10,3) -> up to (10,8) -> then to (12,8) (rightmost) -> back to tip. Let's check if this order is counter-clockwise. Compute polygon vertices: (8,11) (4,8) (6,8) (6,3) (10,3) (10,8) (12,8) Compute signed area (shoelace). Compute sum x_iy_{i+1} - y_ix_{i+1}:
- (88) - (114) = 64 - 44 = 20
- (48) - (86) = 32 - 48 = -16
- (63) - (86) = 18 - 48 = -30
- (63) - (310) wait careful: need to handle each edge:
Let points in order with wrap: 1: (8,11) 2: (4,8) 3: (6,8) 4: (6,3) 5: (10,3) 6: (10,8) 7: (12,8) back to 1.
Compute term for edge 1->2: x1y2 - y1x2 = 88 - 114 = 64 - 44 = 20. 2->3: 48 - 86 = 32 - 48 = -16. 3->4: 63 - 86 = 18 - 48 = -30. 4->5: 63 - 310 = 18 - 30 = -12. 5->6: 108 - 310 = 80 - 30 = 50. 6->7: 108 - 812 = 80 - 96 = -16. 7->1: 1211 - 88 = 132 - 64 = 68.
Sum = 20 -16 -30 -12 +50 -16 +68 = 20+50+68 =138; -16-30-12-16 = -74; total = 64. So area = 32 (since area = sum/2). Positive, which means polygon is oriented counterclockwise. So indeed the order is ccw. So the polygon goes tip, left base endpoint, then interior points along base? Actually the polygon from left base endpoint to rectangle left attach point is moving to the right along the base, which is a "concave" edge? But overall orientation is ccw.
Thus the arrow polygon is formed by 7 vertices in the following order:
- Tip (T)
- Left triangle base endpoint (L)
- Left rectangle attach point (M1) (the one closer to center from L; i.e., the endpoint of the rectangle's side that lies on the base, on the side of L)
- Rectangle vertex at M1 - d * unit_v (call it P1)
- Rectangle vertex at M2 - d * unit_v (call it P2) (i.e., the other side's far vertex)
- Right rectangle attach point (M2)
- Right triangle base endpoint (R)
Where M1 and M2 are the endpoints of the rectangle's side of length c, with M1 being the one in the direction from center towards L? Actually we need to decide which is M1 and M2 relative to orientation. The rectangle side of length c is centered at (px, py) and oriented perpendicular to v (i.e., along base direction). The two endpoints are at distances c/2 along both directions of some perpendicular unit vector w. The direction of w determines which side corresponds to left/right. We must ensure the polygon order is ccw starting from tip. From the example, with v pointing up, w pointing left? Actually they used left base endpoint first: (4,8) is to the left (negative x) relative to tip (8,11). So from tip to left base endpoint is a line sloping down-left. Then they went to (6,8) which is to the right of (4,8). That suggests that L is the extreme left point (at distance a/2 from center), and M1 is at distance c/2 from center in the same direction? Actually center (8,8). L = (4,8) is left, R = (12,8) right. The rectangle endpoints: M_left = (6,8) and M_right = (10,8). So L < M_left < center < M_right < R. So L is leftmost, then rectangle left endpoint, then center, etc. In polygon order: after L, they go to M_left (which is to the right). That seems like moving inward along base. That is part of the boundary because the shape's interior is above that base, and below is exterior; so traversing from L to M_left is along the base in the direction that keeps interior on left? For ccw polygon, interior is to left of edges. Let's examine: Edge from tip to L: vector from (8,11) to (4,8) = (-4,-3). For ccw orientation, interior should be left of this edge. Compute left: if edge direction is (dx, dy), left is (-dy, dx). For (-4,-3), left = (3, -4). That vector points somewhere. Not easy. But we can rely on the ordering they used. So the correct order for a general vector v is: tip, then the triangle base endpoint that is obtained by rotating the direction vector -v (or something) appropriately.
Better: Define unit vector u = (vx, vy)/|v| (direction to tip). The triangle base is perpendicular to u. Choose a unit vector w perpendicular to u such that (u, w) is a right-handed coordinate system? For ccw order starting from tip, we need to go from tip to the base endpoint that is obtained by rotating u by +90 degrees? Let's test with example: u = (0,1) (since v=(0,2) normalized (0,1)). If we rotate u by +90 degrees (counterclockwise), we get (-1,0). That's left direction. Starting from tip (8,11), going to left base endpoint (4,8) means direction vector = L - T = (4-8, 8-11)=(-4,-3). That is not exactly along -u? Actually the left base endpoint is directly below and left of tip? The tip is above center, left base endpoint is left and down from tip. More systematically: the triangle is isosceles, with altitude along u from base midpoint to tip. So base is perpendicular to u. The left base endpoint relative to center: L_c = center - (a/2) * w, where w is a unit perpendicular vector. If we choose w such that w is the direction from center to the "right" base endpoint? Let's define w: unit vector perpendicular to u. The two perpendicular directions are w and -w. Which one is considered "right"? In the example, u=(0,1). If we take w = (1,0) (right), then center + (a/2)w = (8+4,8) = (12,8) = R. center - (a/2)w = (8-4,8)= (4,8)= L. So w = (1,0) yields R to the right, L to left. Then the tip is at center + bu = (8,11). So triangle vertices: T, L, R. If we order T->L->R (and back to T), what orientation? T(8,11), L(4,8), R(12,8). Compute orientation: (L-T) = (-4,-3), (R-L) = (8,0). Cross product (L-T) x (R-L) = (-4,-3) x (8,0) = (-4)0 - (-3)8 = 24 positive. So T->L->R is ccw? Actually the cross product of vectors from T to L and L to R gives a positive z if the points are ccw? Standard: For points p1,p2,p3, compute (p2-p1)x(p3-p1). If positive, then p1,p2,p3 are ccw. Here p1=T, p2=L, p3=R: (L-T)=(-4,-3), (R-T)=(4,-3). Cross = (-4)(-3) - (-3)4 = 12 - (-12) = 24? Wait compute: (dx1,dy1) x (dx2,dy2) = dx1dy2 - dy1dx2. So (-4)(-3) - (-3)*4 = 12 - (-12)=24. Positive => ccw. So ordering T, L, R is ccw for triangle alone. But our arrow polygon has more vertices inserted between L and R. So if we start at T, go to L, then later after traversing rectangle we end at R, and finally back to T, that would be consistent with ccw if we insert rectangle vertices in appropriate order.
Now after L, we need to go to M_left. M_left = center - (c/2)*w. Since w = (1,0), M_left = (8-2,8) = (6,8). That is to the right of L (since L is at 4, M_left at 6). So from L to M_left, we are moving along the base line in the direction of +w (right). The interior of the arrow is above the base (since triangle interior above base, rectangle interior below? Actually the interior near that base: For x between 4 and 6, the shape includes only the triangle above the base; below base is exterior. So the boundary along the base from x=4 to 6 is part of the outer boundary, with interior above. So if we traverse from L (x=4) to M_left (x=6) along the base (direction right), the interior is to the left of the edge? Let's determine: Edge direction from L to M_left is (2,0) (east). For ccw polygon, interior should be to the left of each directed edge. For a horizontal edge eastwards, left is north (since from direction (1,0), left = (0,1) which is up). Indeed interior is above (north) which matches. So edge L->M_left is correct.
Then from M_left, we go down to rectangle bottom left: M_left - du? Actually rectangle extends opposite to u (since u points to tip). Since u=(0,1) up, opposite direction is -u = (0,-1). So M_left - du? Wait u points up, so moving opposite to u is -u. But we need to move a distance d. So from M_left (6,8) we go to P1 = M_left - d * u = (6,8) - (0,5) = (6,3). Edge direction from M_left to P1 is (0,-5) (south). For a southward edge, left is east? Let's see: direction (0,-1), left = (1,0) (since rotate (0,-1) 90 degrees ccw: (1,0)). That would point east (right). But interior of rectangle is to the east of that edge? Actually rectangle interior is to the right of the left side? Let's examine: The rectangle: vertices in order M_left, then P1 (down), then P2 (right-down?), then M_right, then back to M_left. For the rectangle alone, a typical ccw order would be M_left, M_left' (down), M_right' (down and right), M_right (up). But is that ccw? Let's check: points: (6,8) -> (6,3) -> (10,3) -> (10,8). Compute orientation: (6,8)->(6,3): dx=0, dy=-5. (6,3)->(10,3): dx=4, dy=0. (10,3)->(10,8): dx=0, dy=5. (10,8)->(6,8): dx=-4, dy=0. Compute signed area: sum x_iy_{i+1} - y_ix_{i+1}: 63 - 86 = 18-48=-30 63 - 310 = 18-30=-12 108 - 310 = 80-30=50 108 - 86 = 80-48=32 Sum = -30-12+50+32 = 40, area=20 positive -> ccw. So order (6,8)->(6,3)->(10,3)->(10,8) is ccw. For edge (6,8)->(6,3) (south), left is east, interior of rectangle is to the east? The rectangle interior is to the right of the left side? Actually the left side is x=6 from y=3 to 8. The interior of rectangle is for x>6 (east) and y between 3 and 8. So indeed for the directed edge from (6,8) down to (6,3), interior is to the left (east). So that matches.
Thus rectangle order as we inserted: M_left -> P1 -> P2 -> M_right is ccw. So when we go from M_left to P1, that's consistent.
Then from P1 to P2: edge (6,3)->(10,3) eastwards. For eastward edge, left is north, interior is north (since rectangle interior is above this edge? Actually rectangle interior is above the bottom edge? The bottom edge is y=3, rectangle interior is y>3 (north). So interior is to left, good.
From P2 to M_right: (10,3)->(10,8) northwards. For northward edge, left is west? Actually direction (0,1) north; left = (-1,0) west. But interior of rectangle is to the left? For northward edge along x=10, interior of rectangle is west (x<10). So interior to left, good.
From M_right to R: M_right (10,8) to R (12,8) eastwards. For eastward edge, left is north, interior of overall shape is north (above base), indeed interior is to left. So good.
From R to T: edge from (12,8) to (8,11). direction = (-4,3). Compute left: direction = (-4,3); left = rotate ccw: (-3,-4)? Actually rotating (-4,3) 90 degrees ccw gives (-3,-4) because (dx,dy)->(-dy,dx) = (-3, -4). That vector points down-left. Is interior to left? Hard to visualize, but as part of triangle, interior is to left if triangle is ccw. Since triangle vertices T, L, R in ccw order, the edge R->T is part of that triangle boundary. In triangle T-L-R ccw, the edges are T->L, L->R, R->T. For edge R->T, interior is to left. So it should be consistent.
Thus the polygon order is T, L, M_left, P_left (P1), P_right (P2), M_right, R. That's 7 points.
Now we need to define w direction such that M_left is the point in the direction of -w from center? Wait: In example, w = (1,0) gives R = center + (a/2)*w, L = center - (a/2)*w. And M_left = center - (c/2)*w = L + ( (a/2 - c/2) )*w? Actually L = center - (a/2)*w; M_left = center - (c/2)*w. Since a/2 > c/2, M_left is between center and L (closer to center). So M_left is to the right of L. So in the order after L, we go to M_left (moving rightwards along base). That works.
But what if we had chosen w = (-1,0) instead? Then L = center + (a/2)? Actually we need consistency: We need to define w as a unit vector perpendicular to u. There are two choices: w and -w. Which one gives the correct ordering? We need the polygon to be ccw. If we pick w arbitrarily, the order might be reversed. So we must choose w such that the triangle vertices in order T, (center - (a/2) w), (center + (a/2) w) are ccw. Let's test: T = center + bu. Then points: A = center - (a/2) w, B = center + (a/2) w. Compute orientation of T, A, B. Use cross product (A - T) x (B - T). Compute: A - T = (center - (a/2) w) - (center + bu) = -bu - (a/2) w. B - T = (center + (a/2) w) - (center + bu) = -bu + (a/2) w. Cross product = (-bu - (a/2) w) x (-bu + (a/2) w) = compute cross product in 2D: (p x q) = p.xq.y - p.yq.x. Since u and w are perpendicular unit vectors with u x w = ? The orientation of (u, w) matters. Suppose we set w such that rotating u by +90 degrees gives w (i.e., w = rotate_ccw(u)). Then u x w = u.xw.y - u.yw.x. For a right-handed rotation: if u = (ux, uy), then rotate ccw: w = (-uy, ux). Then u x w = uxux - uy(-uy)? Let's compute: u x w = uxw.y - uyw.x = uxux - uy(-uy) = ux^2 + uy^2 = 1. So u x w = 1. And w x u = -1.
Now compute cross: (-bu - (a/2) w) x (-bu + (a/2) w) = Expand: = (-bu) x (-bu) + (-bu) x ((a/2) w) + (- (a/2) w) x (-bu) + (-(a/2) w) x ((a/2) w). The first and last terms are zero (vector cross itself). So we have: (-bu) x ((a/2) w) + (- (a/2) w) x (-bu) = -(ba/2) (u x w) + (a/2 * b) (w x u) because (- (a/2) w) x (-bu) = (a/2 * b) (w x u). Actually careful: (-(a/2) w) x (-bu) = (a/2 * b) (w x u) because both negative signs multiply to positive? (-A) x (-B) = A x B. So yes it's (a/2 * b) (w x u). So total = - (ba/2) (u x w) + (ab/2) (w x u). Since w x u = - (u x w), this becomes - (ab/2) (u x w) - (ab/2) (u x w) ? Wait: (ab/2) (w x u) = (ab/2) * ( - (u x w) ) = - (ab/2) (u x w). So total = - (ab/2) (u x w) - (ab/2) (u x w) = - ab (u x w). Since u x w = 1, we get -ab, which is negative. That would indicate that orientation of T, A, B is clockwise (since cross negative). But earlier with u=(0,1) and w=(1,0) (rotate ccw from u? Actually rotating u=(0,1) ccw gives (-1,0), not (1,0). In our example we used w=(1,0). That w is rotate cw from u. Because rotating (0,1) cw gives (1,0). So w = rotate cw(u) yields u x w = ? For u=(0,1), w=(1,0), u x w = 00 - 11 = -1. Then cross = -ab(u x w) = -ab(-1) = ab positive. So orientation positive (ccw). So to have triangle T, A=center - (a/2) w, B=center + (a/2) w be ccw, we need w such that u x w = -1? Actually from above derivation, orientation of T, A, B gave cross = -ab (u x w). So to have positive cross (ccw), we need -a*b (u x w) > 0 => u x w < 0. So we need w such that u x w is negative, i.e., w is a clockwise rotation of u (i.e., rotate u by -90 degrees). Because for u, a clockwise rotated vector w_cw: u x w_cw = -1 (if u and w are orthonormal). So w = rotate_cw(u) yields u x w = -1. So choose w = (uy, -ux)? Actually rotate cw: (ux, uy) rotated cw (90° clockwise) becomes (uy, -ux). Let's check: u=(ux, uy). Rotating cw: (uy, -ux). Rotating ccw: (-uy, ux). So indeed cw gives (uy, -ux). For u=(0,1), cw gives (1,0) correct. For u=(1,0), cw gives (0,-1). That would yield base direction downwards? We'll test.
Thus to have triangle orientation ccw, we set w = (uy, -ux) (unit vector because u is unit). This ensures that the order T, (center - (a/2) w), (center + (a/2) w) is ccw. Let's verify with arbitrary u. For u=(ux, uy) with ux^2+uy^2=1. w = (uy, -ux). Then u x w = ux*(-ux) - uyuy = -ux^2 - uy^2 = -1. Good. Then cross = -ab*(u x w) = -ab(-1)= a*b >0. So indeed orientation positive.
So we have defined:
- center C = (px, py)
- unit vector u = (vx, vy) / L, where L = sqrt(vx^2+vy^2)
- unit vector w = (uy, -ux) (clockwise rotation of u) Then: Tip T = C + b * u Left base endpoint? Actually which one is "left"? From orientation, with w defined as cw rotation, we have: A = C - (a/2) w, B = C + (a/2) w. The order T, A, B is ccw. So the polygon starting at T, then go to A, then ... then to B, then back to T. In example, w = (1,0) (since u=(0,1), w=(1,0)). Then A = C - (a/2) w = (8-4,8)=(4,8) (left), B = C + (a/2) w = (12,8) (right). So indeed A is leftmost, B rightmost. And the order T->A->...->B is consistent with output: tip, then (4,8) (A), then ... then (12,8) (B). So good.
Now rectangle side of length c: its endpoints are M1 = C - (c/2) w, M2 = C + (c/2) w. Note that since c < a, M1 is between A and C? Actually A = C - (a/2) w, so moving from A towards C is +w direction. So M1 = C - (c/2) w is closer to C than A (since c/2 < a/2). So M1 is to the right of A (if w points right). Similarly, M2 is to the left of B? Actually B = C + (a/2) w, M2 = C + (c/2) w is left of B.
Now rectangle extends opposite to u: So the far vertices: P1 = M1 - d * u? Wait careful: The rectangle side of length c is attached, and the rectangle extends in the direction opposite to u (since u points to tip). So the rectangle's other side (parallel) is at a distance d from the attached side, in the direction -u. So the four rectangle vertices in ccw order (when considering rectangle alone) would be: M1, then M1 - d * u, then M2 - d * u, then M2. Let's verify orientation: Using w = cw(u), rectangle vertices: start at M1 (C - (c/2) w). Then move along -u to Q1 = M1 - du. Then move along +w to Q2 = M2 - du? Actually after Q1, we need to go to the opposite corner. In ccw order, if we go M1 -> Q1 (downwards if u up), then to Q2 (rightwards if w right), then to M2 (upwards). But is that ccw? In example: M1 = (6,8), Q1 = (6,3), Q2 = (10,3), M2 = (10,8). That's exactly M1 -> Q1 -> Q2 -> M2, which we found is ccw. So that order works. So the rectangle order is M1 -> (M1 - du) -> (M2 - du) -> M2.
Now integrating with the triangle: The polygon order we need is T, A, M1, (M1 - du), (M2 - du), M2, B, then back to T.
But is that always ccw? Let's test with arbitrary orientation. Suppose u points to the right (east), w = cw(u) = (uy, -ux). For u=(1,0), w = (0,-1) (down). Then C = (px,py). T = C + bu = (px+b, py). A = C - (a/2) w = C - (a/2)(0,-1) = C - (0, -a/2) = (px, py + a/2). Actually w = (0,-1), so - (a/2) w = - (a/2)(0,-1) = (0, a/2). So A = (px, py + a/2). B = C + (a/2) w = (px, py - a/2). So A is above, B is below. Order T, A, B: T is to the right of C; A is above C; B is below C. Let's compute orientation: T=(px+b, py), A=(px, py+a/2), B=(px, py-a/2). Compute cross (A-T) x (B-T). A-T = (-b, a/2). B-T = (-b, -a/2). Cross = (-b)(-a/2) - (a/2)(-b) = (b a/2) + (a b/2) = a b. Positive => ccw. So indeed T->A->B is ccw. Now polygon: T, A, M1, (M1 - du), (M2 - du), M2, B. Let's compute positions: M1 = C - (c/2) w = C - (c/2)(0,-1) = (px, py + c/2). M2 = C + (c/2) w = (px, py - c/2). So M1 is above C but less than A (since c/2 < a/2). So A is above M1. So from A (top) we go downwards to M1? Actually A = (px, py + a/2) and M1 = (px, py + c/2). So moving from A to M1 is downwards (south). Edge direction (0, - (a/2 - c/2) ) i.e., south. For southward edge, left is east. Is interior to left? The interior near this edge: The triangle interior is to the right of the base? Wait base is horizontal? Actually base is along w direction? In this orientation, w = (0,-1) (down), so base is vertical. The triangle's base is vertical line through x=px, from y= py - a/2 to y= py + a/2. The triangle interior is to the right of the base? Because the tip is to the right (east). The triangle interior is to the east of the base line? Let's think: The triangle has base as a segment on a line (vertical line x=px). The tip is at (px+b, py). So interior of triangle is to the right of the base (east). So the interior is to the east of the vertical base. The edge from A (top) to M1 (just below) is along the base line (vertical). The interior of the overall shape (triangle) is to the east (right). For an edge going downward (south), left is east. So interior is left, correct. So A->M1 is fine.
Then M1-> (M1 - du). u is east, so -u is west. Actually rectangle extends opposite to u, so direction is -u = west. But careful: In the example, rectangle extended opposite to u, i.e., -u. Since u points to tip (east), rectangle should extend opposite, i.e., west. But from M1, we go to M1 - du = (px, py + c/2) - d*(1,0) = (px - d, py + c/2). That is west from M1. So edge from M1 to Q1 is westwards. For a westwards edge, left is south? Direction (-1,0) west; left = (0,-1) (south). Is interior to left? The rectangle interior: For the left side? Actually rectangle's vertices: M1 (on base), Q1 (westwards), Q2 (westwards and down? Wait we need to compute Q2 = M2 - du = (px, py - c/2) - d(1,0) = (px - d, py - c/2). So rectangle extends west from the base. So rectangle interior lies west of the base? Actually the rectangle: the attached side is vertical at x=px, from y=py-c/2 to y=py+c/2. The rectangle extends westwards to x=px-d. So interior is between x=px-d and x=px, and y between py-c/2 and py+c/2. So for edge M1->Q1 (west), the interior of rectangle is south of that edge? Actually M1->Q1 is a horizontal edge from (px, py+c/2) left to (px-d, py+c/2). This is the top edge of the rectangle? Wait rectangle orientation: vertices order M1 -> Q1 -> Q2 -> M2. M1 is at (px, py+c/2). Q1 = (px-d, py+c/2) (west). Q2 = (px-d, py-c/2) (south). M2 = (px, py-c/2) (east). So rectangle is oriented with top edge from M1 to Q1 (westwards). For that directed edge (west), left is south. The interior of rectangle is south of this top edge? Actually rectangle interior is below the top edge. So interior is south, which is left. Good.
Then Q1 -> Q2: from (px-d, py+c/2) to (px-d, py-c/2) (south). For southward edge, left is east. The interior of rectangle is east of the left side? Actually the left side of rectangle is at x=px-d, interior is to the east. So interior is left, good.
Then Q2 -> M2: from (px-d, py-c/2) to (px, py-c/2) (east). For eastward edge, left is north. Interior is north (above bottom edge), good.
Then M2 -> B: from (px, py-c/2) to B = (px, py - a/2) (south). Since B is further down than M2? Actually B = (px, py - a/2). Since a/2 > c/2, B is lower (more south). So edge from M2 to B is southwards. For southward edge, left is east. Interior is east (right) of base line, yes.
Then B -> T: from (px, py-a/2) to T (px+b, py). Direction: (b, a/2). Compute left: rotate (b, a/2) ccw: (-a/2, b). Not obvious but should be interior to left.
Thus the order T, A, M1, Q1, Q2, M2, B works.
But wait: In this orientation, after M2 we go to B, which is further south along the base. But note: The order we used in example was: T, A, M1, Q1, Q2, M2, B. But in example, after M2 they went to B? Actually example: T (8,11), A (4,8), M1 (6,8), Q1 (6,3), Q2 (10,3), M2 (10,8), B (12,8). That's T, A, M1, Q1, Q2, M2, B. So yes.
But note: In example, M2 is (10,8) and B is (12,8). That's moving eastwards along base from M2 to B, not southwards. In the east-pointing example, we would have M2 -> B as southwards? Let's check: In east-pointing, w is down, so base is vertical. M2 = C + (c/2) w = (px, py - c/2) and B = C + (a/2) w = (px, py - a/2). So from M2 to B is further down (south). So that is a vertical edge downwards. That's consistent with the pattern: after rectangle's right attach point, we go further along base towards the base endpoint. So in general, the direction from M2 to B is along w direction (since B = C + (a/2) w, M2 = C + (c/2) w). So M2 to B is +w (since w points from C to B). So edge direction is w (positive w). For the example, w = (1,0) (east), so M2 to B is eastwards. For east-pointing, w = (0,-1) (south), so M2 to B is southwards. So it's consistent.
Similarly, A to M1: A = C - (a/2) w, M1 = C - (c/2) w, so direction from A to M1 is +w (since moving from -a/2 w to -c/2 w means adding (a/2 - c/2) w? Actually vector from A to M1 = (C - (c/2) w) - (C - (a/2) w) = (a/2 - c/2) w. So direction +w. So A->M1 is +w direction.
Thus overall polygon order: T, then A, then M1, then Q1, then Q2, then M2, then B, then back to T. This yields 7 vertices.
Now we need to output coordinates of these points in order. That seems straightforward.
But is there any case where the rectangle might be on the other side? Could the rectangle extend in the same direction as the tip? That would cause intersection? The problem says area of intersection of triangle and rectangle is zero. If rectangle extended in the same direction as tip, they'd overlap (since triangle is in that direction). So rectangle must extend opposite to tip. So that is correct.
Now we need to ensure that the polygon vertices are listed in counter-clockwise order starting from the tip. We derived order T, A, M1, Q1, Q2, M2, B. Is this always ccw? Let's test with a generic u, w. We'll do a sanity check with another orientation, say u = (1,1)/√2 (45° up-right). Compute numerically and check orientation using cross sum.
Let's do a quick mental test: Suppose px=0, py=0, v=(1,1) => u=(√2/2, √2/2). L = sqrt(2). Let a=8, b=3, c=4, d=5. Compute:
C=(0,0). b=3 => T = C + bu = (3√2/2, 3*√2/2) ≈ (2.121, 2.121). w = cw(u) = (uy, -ux) = (√2/2, -√2/2) ≈ (0.7071, -0.7071). A = C - (a/2) w = -4 * (0.7071, -0.7071) = (-2.828, 2.828)? Actually a/2=4, so A = -4 * w = (-40.7071, -4(-0.7071))? Wait careful: C - (a/2) w = -(a/2) w = (-2.828, 2.828) because w = (0.7071, -0.7071), -(4)w = (-2.828, 2.828). So A ≈ (-2.828, 2.828). B = C + (a/2) w = 4 * w = (2.828, -2.828). M1 = C - (c/2) w = -2 * w = (-1.414, 1.414). M2 = C + (c/2) w = (1.414, -1.414). Q1 = M1 - du = (-1.414, 1.414) - 5(0.7071,0.7071) = (-1.414-3.5355, 1.414-3.5355) = (-4.9495, -2.1215). Q2 = M2 - d*u = (1.414, -1.414) - (3.5355, 3.5355) = (-2.1215, -4.9495). Now polygon order: T(2.121,2.121), A(-2.828,2.828), M1(-1.414,1.414), Q1(-4.9495,-2.1215), Q2(-2.1215,-4.9495), M2(1.414,-1.414), B(2.828,-2.828). Let's compute signed area to check orientation. Use shoelace. Compute edges:
1: T->A: (2.121,2.121) to (-2.828,2.828): vector = (-4.949,0.707). Not needed directly.
Shoelace sum: x1y2 = 2.1212.828 = 6.0? Let's compute precisely later.
Better to compute using program mentally? Might be messy but we can trust derivation.
We already proved triangle T, A, B is ccw. Inserting the rectangle points between A and B should preserve ccw if we insert them in the order along the boundary. The boundary from A to B along the shape goes: A -> (along base towards center) M1 -> around rectangle Q1 -> Q2 -> M2 -> (continue along base to B). All these edges are part of the outer boundary. Since the shape is simple, and we are traversing its boundary in a consistent direction (ccw), we need to confirm that the direction along the rectangle is consistent with ccw. The rectangle order M1 -> Q1 -> Q2 -> M2 is ccw when rectangle is considered as a standalone polygon. However, is that ccw with respect to the overall shape? The overall shape's interior is to the left of each edge. For rectangle, interior is inside rectangle. The rectangle is attached to the base; its interior lies on the side opposite the tip (i.e., in direction -u). In the overall shape, the rectangle interior is part of the shape, so the boundary of the rectangle that is not shared with the triangle is traversed in such a way that interior is to the left. For the rectangle's outer edges (the ones not on the base), the interior is indeed to the left when we go M1->Q1->Q2->M2. But is that consistent with the direction of traversal from A to M1? A->M1 goes from the far base endpoint towards the center along the base. That edge is part of the base. For that edge, interior is to the left. Then we continue to Q1: M1->Q1 leaves the base going into the rectangle. The interior should stay to the left. As we determined for the example, it's consistent.
Now we need to verify that for any orientation, the polygon T, A, M1, Q1, Q2, M2, B is indeed ccw. Perhaps we can derive orientation analytically: The polygon is essentially the union of two convex polygons (triangle and rectangle) that share a common segment (from M1 to M2). The union's boundary is obtained by traversing the triangle from A to M1 along base, then rectangle from M1 to Q1 to Q2 to M2, then triangle from M2 to B, then triangle edges B->T and T->A. Since the triangle's edges are convex, and rectangle orientation matches, the overall orientation remains the same as triangle's (ccw). So it's fine.
Thus the solution: compute points as described.
One nuance: The output in the example shows 7 points, but maybe there are 10? Wait the arrow consists of triangle and rectangle. The union may have 7 vertices if rectangle attaches along base interior. But what about the case where c = a? But condition a > c, so c strictly less, so rectangle side is strictly shorter, so we have exactly 7 distinct vertices. If c were equal, then M1 = A and M2 = B, then shape would have 5 vertices? But not in this problem.
Thus output 7 points.
Now need to determine order precisely: Starting from tip, then going to A = C - (a/2) w, then M1 = C - (c/2) w, then Q1 = M1 - d * u, then Q2 = M2 - d * u, then M2 = C + (c/2) w, then B = C + (a/2) w.
Check: In example, M2 is at (10,8) and B at (12,8). That's correct.
But is there any possibility that the ordering of Q1 and Q2 might be reversed depending on w? Because rectangle order M1 -> Q1 -> Q2 -> M2 is ccw for the rectangle. But if w direction is defined as cw(u), then the rectangle's ccw order is indeed M1, M1 - du, M2 - du, M2. Let's verify generically.
We have rectangle vertices: attached side endpoints: M1 (C - (c/2) w) and M2 (C + (c/2) w). The rectangle extends in direction -u. So the other side is at offset -du from these. So vertices: R1 = M1 R2 = M1 - du R3 = M2 - d*u R4 = M2
Now consider the quadrilateral R1-R2-R3-R4. Is it always ccw? Compute cross product sum to verify orientation. But we can test with our earlier example with u=(1,0), w=(0,-1). Then M1=(px, py + c/2), R2 = (px - d, py + c/2), R3 = (px - d, py - c/2), R4 = (px, py - c/2). The order R1->R2->R3->R4 yields ccw as we computed. So fine.
But what if we reverse w? That would yield triangle orientation cw, so we must choose w accordingly.
Thus algorithm:
- Read px, py, vx, vy, a, b, c, d.
- Compute len_v = sqrt(vxvx + vyvy).
- u = (vx/len_v, vy/len_v).
- Compute w = (u.y, -u.x). This is unit perpendicular vector (cw rotation). Because we need u x w negative to get triangle ccw. (Alternatively, we could compute w = ( -u.y, u.x )? That is ccw rotation, then triangle orientation would be cw. So we use cw.)
- Compute: T = (px + b * u.x, py + b * u.y) A = (px - (a/2) * w.x, py - (a/2) * w.y) M1 = (px - (c/2) * w.x, py - (c/2) * w.y) Q1 = (M1.x - d * u.x, M1.y - d * u.y) Q2 = (M2.x - d * u.x, M2.y - d * u.y) but we need M2 first: M2 = (px + (c/2) * w.x, py + (c/2) * w.y) Q2 = (M2.x - d * u.x, M2.y - d * u.y) B = (px + (a/2) * w.x, py + (a/2) * w.y)
- Output each coordinate with sufficient precision (e.g., 12 decimal places). The order: T, A, M1, Q1, Q2, M2, B.
Check with example: px=8,py=8, vx=0,vy=2 => len=2, u=(0,1). w=(u.y,-u.x)=(1,0). Then: T = (8+30, 8+31) = (8,11) A = (8 -41, 8 -40) = (4,8) M1 = (8 -21, 8 -20) = (6,8) M2 = (8 +21, 8+20) = (10,8) Q1 = (6 -50, 8 -51) = (6,3) Q2 = (10 -50, 8 -51) = (10,3) B = (8+41, 8+40) = (12,8) Matches example.
Thus solution seems correct.
Now we should consider whether the output order might be T, A, M1, Q1, Q2, M2, B in all cases, or sometimes T, B, M2, Q2, Q1, M1, A? That would be reversed. But our derivation says ccw orientation requires starting at tip and then going to A (the point such that T->A->B is ccw). So we need to confirm that in all cases the starting point is tip and next is A (the one obtained by subtracting (a/2) w). In example, they indeed start with tip then (4,8). So yes.
Now potential pitfalls: Might need to output more than 7 points? The arrow consists of a triangle and a rectangle; but the union polygon may have a "notch" if rectangle width c is less than a, which gives 7 vertices. However, could there be additional vertices if the rectangle is placed differently? For instance, if the rectangle's side of length c is not the side attached to triangle? But the description: "Point (px, py) is situated in the middle of the triangle base and in the middle of side of rectangle that has length c." So (px,py) is the midpoint of that rectangle side. "Area of intersection of the triangle and the rectangle is zero." So they don't overlap. That implies the rectangle is placed such that its side of length c is adjacent to the triangle base, and rectangle extends away. So the union is exactly as we described.
Now we need to ensure that the direction of the rectangle extension is indeed opposite to the vector (vx, vy). The phrase: "The direction from (px, py) point to the triangle vertex opposite to base containing the point coincides with direction of (vx, vy) vector." That defines that the tip is in direction of v. It doesn't explicitly say that rectangle extends opposite, but given intersection area zero, it must be opposite; otherwise they'd overlap. Also typical arrow.
Thus we are done.
Now implement: Use double precision. Compute len, u_x, u_y. Then w_x = u_y, w_y = -u_x. But ensure that w is unit? Since u is unit, w is automatically unit (since perpendicular). So fine.
Then compute all coordinates.
Potential edge case: vx,vy can be any non-zero, but values up to 1000, so len may be large but within double.
Now output formatting: We can use cout with fixed and setprecision(12) or printf("%.12f").
Check the error tolerance: 1e-9, so 12 decimal digits should be fine.
Now test with another custom case: Suppose px=0, py=0, vx=1, vy=0, a=6, b=4, c=2, d=3. So arrow points right. Then u=(1,0), w = (0,-1). Compute: T = (4,0) A = (0 - 30? Actually a/2=3, A = (0 - 30, 0 - 3*(-1))? Wait w=(0,-1). So A = (0 - 30, 0 - 3(-1)) = (0, 3). Since - (a/2) w = -3*(0,-1) = (0,3). B = (0 + 30, 0 + 3(-1)) = (0, -3). M1 = (0 -10, 0 -1(-1)) = (0,1). M2 = (0 +10, 0 +1(-1)) = (0,-1). Q1 = M1 - du = (0,1) - 3(1,0) = (-3,1). Q2 = M2 - du = (0,-1) - 3(1,0) = (-3,-1). B = (0,-3). Polygon order: T(4,0), A(0,3), M1(0,1), Q1(-3,1), Q2(-3,-1), M2(0,-1), B(0,-3). Let's check orientation: Compute area roughly. Points: (4,0)->(0,3): edge (0,3)->(0,1): down (south). left of south is east, interior should be east (right) of base? For arrow pointing right, triangle interior is to the right of base? Actually base is vertical line at x=0 from y=-3 to y=3; tip is at (4,0). So interior is to the right of base (positive x). For edge from (0,3) to (0,1) (south), left is east, interior is east, good. (0,1)->(-3,1) west, left is south, interior? Rectangle interior is between x=-3 to 0, y from -1 to 1. At top edge (0,1) to (-3,1) west, interior is south (below), left is south, good. (-3,1)->(-3,-1) south, left is east, interior is east (since rectangle interior is to the right of left side? Actually left side x=-3, interior is east, so left is east, good. (-3,-1)->(0,-1) east, left is north, interior is north (above bottom), good. (0,-1)->(0,-3) south, left is east, interior east, good. (0,-3)->(4,0) back to tip. That seems consistent. So polygon is ccw? Compute signed area: Use shoelace. Might be positive. So fine.
Thus algorithm works.
Now double-check orientation: In above, we start with tip (4,0), then go to A (0,3). That is moving left and up. Then A->M1 down. The interior is to the left of each edge. Let's compute cross product sum to confirm. We'll do rough mental:
Points: 1: (4,0) 2: (0,3) 3: (0,1) 4: (-3,1) 5: (-3,-1) 6: (0,-1) 7: (0,-3)
Compute edges:
1-2: 43 - 00 =12? Actually x1y2 =43=12, y1x2=00=0 =>12 2-3: 01 - 30 = 0-0=0 3-4: 01 - 1(-3)=0 - (-3)=3 4-5: (-3)(-1) - 1(-3)=3 - (-3)=6 5-6: (-3)(-1) - (-1)0 =3 -0=3? Wait compute: x5y6 - y5x6 = (-3)*(-1) - (-1)0 = 3 - 0 =3 6-7: 0(-3) - (-1)0 =0 -0 =0 7-1: 00 - (-3)*4 = 0 - (-12)=12
Sum =12+0+3+6+3+0+12=36. Area=18 positive. So indeed ccw.
Thus solution is consistent.
Now one more nuance: The problem says "Enumerate the arrow points coordinates in counter-clockwise order starting from the tip." The "arrow points" means the vertices of the polygon that is the union of triangle and rectangle. So we have to output exactly the 7 vertices as described.
But is there any scenario where the rectangle might be placed such that its side of length c is not the side attached to the triangle? The description says: "Point (px, py) is situated ... in the middle of side of rectangle that has length c." And "Area of intersection of the triangle and the rectangle is zero." It does not explicitly say the rectangle shares the side with the triangle base. But the most natural way to satisfy both conditions is that the rectangle's side of length c is collinear with the triangle base, and the rectangle extends away from the triangle, so intersection area is zero. Could there be an alternative where the rectangle is placed on the other side of the base (i.e., extending in the same direction as the triangle) but not overlapping because they are separated? But then the point (px,py) being the midpoint of triangle base and also midpoint of that rectangle side would mean the rectangle side lies on the same line as the base but possibly on the same side as the triangle? If rectangle extends into triangle area, they'd overlap. If rectangle extends away but still on the same side as triangle? Actually the triangle occupies the region on one side of the base (the side where the tip is). The rectangle would occupy the other side of the base if it is attached, because if it occupied the same side, they'd overlap (since triangle covers the region adjacent to base on tip side). To have zero intersection, rectangle must be on the opposite side. So indeed it extends opposite to tip.
Thus all good.
Now corner case: If the vector (vx, vy) is not of unit length, we compute u. But we need to ensure we use b as distance along u, so multiply u by b.
Now about precision: Use double. Output with at least 10 decimal places; 12 or 15 is fine.
Thus solution is straightforward.
Now let's confirm we didn't misinterpret which side of rectangle has length c. It says "in the middle of side of rectangle that has length c." So the side containing (px,py) as midpoint has length c. So the rectangle's side of length c is the one that is attached. So we set that side as the one between M1 and M2. Good.
Now confirm that we used correct orientation for w: w = (uy, -ux) (cw rotation). Let's verify with a case where v points down-left maybe. For any u, this choice yields triangle ccw. Let's test with u = (-1,0) (left). Then w = (0, -(-1))? Actually u = (-1,0). Then w = (uy, -ux) = (0, -(-1)) = (0,1). So w = (0,1) (up). Then A = C - (a/2) w = (px, py - a/2) (since w up, subtract up gives down). B = C + (a/2) w = (px, py + a/2). Tip T = C + bu = (px - b, py). So triangle: tip left, base vertical. Now order T, A, B: T is left, A is down, B is up. Compute orientation: A - T = (px - (px-b), py - a/2 - py) = (b, -a/2). B - T = (b, a/2). Cross = b(a/2) - (-a/2)*b = (b a/2) + (a b/2) = a b >0. So ccw. Good.
Now if we had chosen w = (-uy, ux) (ccw rotation), then for u=(0,1), w=(-1,0) (left). Then A = C - (a/2) w = C - (a/2)(-1,0) = (px + a/2, py) => right point? Actually that would put A to the right, B to left. Then T->A->B would be cw? Let's check: u=(0,1), w=(-1,0): A = (px + a/2, py) (right), B = (px - a/2, py) (left). Then T=(px, py+b). Compute orientation: A-T = (a/2, -b), B-T = (-a/2, -b). Cross = (a/2)(-b) - (-b)*(-a/2) = -ab/2 - (ab/2) = -ab <0. So cw. So our choice of w must be cw rotation to get ccw triangle.
Thus we have consistent method.
Now implement.
But wait: The problem states: "The direction from (px, py) point to the triangle vertex opposite to base containing the point coincides with direction of (vx, vy) vector." So the vector points from base midpoint to tip. That's exactly u direction. So we set T = C + b*u.
All good.
Now we should also consider if there is any need to output the points as floating point numbers even if they are integer? The example outputs with .000000000000. So printing as double with fixed precision is fine.
Now implement solution in C++:
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { int px, py, vx, vy, a, b, c, d; cin >> px >> py >> vx >> vy >> a >> b >> c >> d; double len = sqrt(vx*vx + vy*vy); double ux = vx / len; double uy = vy / len; // w = clockwise perpendicular: (uy, -ux) double wx = uy; double wy = -ux; // compute points double T_x = px + b * ux; double T_y = py + b * uy; double A_x = px - (a/2.0) * wx; double A_y = py - (a/2.0) * wy; double M1_x = px - (c/2.0) * wx; double M1_y = py - (c/2.0) * wy; double M2_x = px + (c/2.0) * wx; double M2_y = py + (c/2.0) * wy; double Q1_x = M1_x - d * ux; double Q1_y = M1_y - d * uy; double Q2_x = M2_x - d * ux; double Q2_y = M2_y - d * uy; double B_x = px + (a/2.0) * wx; double B_y = py + (a/2.0) * wy; // Output with high precision cout << fixed << setprecision(12); cout << T_x << " " << T_y << "\n"; cout << A_x << " " << A_y << "\n"; cout << M1_x << " " << M1_y << "\n"; cout << Q1_x << " " << Q1_y << "\n"; cout << Q2_x << " " << Q2_y << "\n"; cout << M2_x << " " << M2_y << "\n"; cout << B_x << " " << B_y << "\n"; return 0; }But careful: Are we sure about the order: T, A, M1, Q1, Q2, M2, B? In example it matches. Let's double-check the order around the polygon. After Q2, we go to M2. But is there an edge directly from Q2 to M2? In rectangle, yes: Q2 to M2 is an edge. Then from M2 to B is an edge along base. So that's correct.
Could the order be T, A, M1, Q1, Q2, M2, B? Yes.
One more nuance: The rectangle side of length c is between M1 and M2. In our rectangle order, we go M1 -> Q1 -> Q2 -> M2. That includes the edge M1->Q1, Q1->Q2, Q2->M2. However, the side M1-M2 is not traversed because we go around the rectangle's outer boundary that is away from triangle. In the union polygon, the side M1-M2 is internal (shared with triangle base) and thus not part of the outer boundary; it is replaced by the rectangle's other three sides plus the two base segments A-M1 and M2-B. So polygon edges are: T-A, A-M1, M1-Q1, Q1-Q2, Q2-M2, M2-B, B-T. That's 7 edges? Actually 7 vertices yield 7 edges (closed). Yes.
Now check that A-M1 and M2-B are indeed edges: They are along the base line, and they are part of the triangle's base but only the outer parts. Good.
Now any other possible shape: Could the rectangle be attached such that the side of length c is not the one that lies on the base but the other side? For example, rectangle could be oriented such that its side of length d is attached? But the point is in the middle of side of length c, so that side must be the one that includes (px,py). And the intersection area zero suggests that side lies on the base line. If the rectangle were rotated 90 degrees, its side of length c would be perpendicular to base, then (px,py) would be on that side but not on base; then triangle and rectangle might still intersect? Possibly not, but then (px,py) would be on triangle base midpoint? Actually the condition says point (px,py) is situated in the middle of the triangle base and in the middle of side of rectangle that has length c. So (px,py) is both the midpoint of triangle base and the midpoint of that rectangle side. So that rectangle side must be collinear with the triangle base? Not necessarily; they could be two different lines intersecting at (px,py) but then (px,py) is the midpoint of both segments. However, if the rectangle side is not collinear with the base, the rectangle would stick out in some direction; but then the area of intersection might be zero if they are placed apart. However, typical arrow has the rectangle as the shaft aligned with the arrow direction, not perpendicular. But let's examine: If rectangle side of length c is centered at (px,py) and is not collinear with base, then the rectangle would be oriented such that one side (length c) has midpoint at (px,py). The rectangle extends in some direction (perpendicular to that side). To have zero intersection with triangle, the rectangle must be entirely outside the triangle. Since triangle's base is a line, and the triangle interior is on one side of that line. If the rectangle side is not collinear, part of the rectangle might cross the base line and enter triangle. It's possible to position rectangle so that it avoids triangle entirely, but then the rectangle would be offset from the base. However, the condition that (px,py) is the midpoint of both the base and the rectangle side forces the rectangle side to lie on the same line as the base? Actually not necessarily; the base is a line segment; its midpoint is (px,py). The rectangle side is also a segment; its midpoint is (px,py). For the rectangle side to be collinear with the base, its direction must be the same as base direction. If it's not collinear, then the rectangle side would cross the base line at its midpoint but at an angle; then the rectangle would extend partly on both sides of the base. The triangle interior is on one side of the base (the side where the tip is). If the rectangle extends on the opposite side, it might avoid overlap; but if the rectangle side is not collinear, the rectangle would also have some portion on the tip side near the midpoint, which could cause intersection with triangle unless the rectangle is entirely on the opposite side. But if the rectangle side is not collinear, the rectangle will have some points on both sides of the line of the base, because the side itself is a segment that is not collinear? Actually consider a line L (the base line). A segment S with midpoint on L but not collinear will cross L at that point, so half of S lies on one side of L, half on the other. Thus part of S lies on the same side as the triangle interior. Since S is part of the rectangle, the rectangle would include points on that side, potentially intersecting triangle. However, could the rectangle be placed such that the rectangle side S is entirely on the opposite side? No, because if S's midpoint is on L and S is not collinear, then S will have points on both sides of L. The only way for S to have all points on one side of L is if it's parallel to L and offset, but then its midpoint would not be on L. So the only way for S to have its midpoint on L and be entirely on one side of L is if S is of zero length, not possible. So S must cross L. Therefore, to have intersection area zero, S must lie exactly on L (collinear) and the rectangle must be entirely on the opposite side of L (the non-triangle side). If S is collinear and lies on L, then it's exactly on the base line. Then the rectangle extends from that line in the opposite direction (away from triangle). That is exactly our interpretation. So it's forced.
Thus our interpretation is correct.
Now check edge cases: vx and vy may be negative. That's fine. The direction of u might be negative. But we defined w = (uy, -ux) regardless of sign. That yields a perpendicular direction. For example, v = (0,-2) (downwards). Then u = (0,-1). w = (uy, -ux) = (-1, 0). So w = (-1,0) (left). Then T = (px, py - b). A = px - (a/2)(-1) = px + a/2, py? Actually w = (-1,0), so A = (px - (a/2)(-1), py - (a/2)0) = (px + a/2, py). B = (px - (a/2)w? Actually B = px + (a/2)w = (px + (a/2)(-1), py + 0) = (px - a/2, py). So A is right, B is left. T is down. The order T, A, B? Let's compute: T = (px, py - b), A = (px + a/2, py), B = (px - a/2, py). Visualizing: tip is below, base is horizontal? Since w = (-1,0) is leftwards, but base direction is w, so base is horizontal (since w is horizontal). Actually w = (-1,0) means base direction is horizontal, pointing left. So base endpoints: A = C - (a/2) w = C - (a/2)(-1,0) = C + (a/2,0) = (px + a/2, py) which is to the right. B = C + (a/2) w = C + (a/2)(-1,0) = (px - a/2, py) which is to the left. So base runs from right (A) to left (B). Tip is below. Now orientation T, A, B: T (down), A (right), B (left). Let's compute cross: A-T = (a/2, b), B-T = (-a/2, b). Cross = (a/2)b - b(-a/2) = (ab/2 + ab/2)=ab>0. So ccw. So polygon order: T, A (rightmost), then M1 = C - (c/2) w = C - (c/2)(-1,0) = (px + c/2, py) (still right but less than A if c<a), then Q1 = M1 - du = (px + c/2, py) - d*(0,-1) = (px + c/2, py + d) because u=(0,-1) so -du = (0,d). So Q1 = (px + c/2, py + d). Since u points down, -u points up, so rectangle extends up. Q2 = M2 - du = (px - c/2, py + d). M2 = (px - c/2, py). B = (px - a/2, py). So order: T (down), A (right), M1 (right inner), Q1 (right inner up), Q2 (left inner up), M2 (left inner), B (left). That yields shape: tip down, rectangle up from base. So the arrow points downward, shaft goes upward? That seems opposite: If arrow points down, the rectangle (shaft) should be attached at the base and extend opposite to the tip direction, i.e., upward. So that matches: rectangle goes up. Good.
Thus orientation works.
Now confirm that we always take w = (uy, -ux). That gives the correct orientation for triangle (ccw) and then the polygon order yields ccw overall.
Now implement as described.
But we must be careful about the order of points: Starting from tip, then A (C - (a/2) w). In the example, that was the leftmost. But in the case v = (0,-2), A was rightmost. So the first point after tip might be either left or right depending on orientation. That's fine as long as order is ccw.
Now verify that the polygon indeed goes ccw. Let's test with v = (0,-2) using our computed order. Points: T (down), A (right), M1 (right inner), Q1 (right inner up), Q2 (left inner up), M2 (left inner), B (left). Let's quickly compute orientation with sample numbers: px=0,py=0, a=6,b=4,c=2,d=3. Then u=(0,-1), w=(-1,0). Then:
T = (0, -4) A = (0 -3*(-1)? Actually a/2=3, A = (0 -3*(-1), 0 -30) = (3,0) M1 = (0 -1(-1), 0) = (1,0) M2 = (0 +1*(-1), 0) = (-1,0) Q1 = (1,0) - 3*(0,-1) = (1,3) Q2 = (-1,0) - 3*(0,-1) = (-1,3) B = (0 +3*(-1), 0) = (-3,0)
Order: T(0,-4), A(3,0), M1(1,0), Q1(1,3), Q2(-1,3), M2(-1,0), B(-3,0)
Compute area: 1-2: 00 - (-4)3 = 0 - (-12)=12 2-3: 30 - 01 = 0 - 0 =0 3-4: 13 - 01 = 3 - 0 =3 4-5: 13 - 3(-1) = 3 - (-3) =6 5-6: (-1)0 - 3(-1) = 0 - (-3)=3 6-7: (-1)0 - 0(-3) = 0 - 0 =0 7-1: (-3)(-4) - 00 =12 - 0 =12
Sum = 12+0+3+6+3+0+12 = 36, area=18 positive. So ccw.
Thus correct.
Now consider another test: v = (1,1) earlier gave positive area.
Thus the solution is robust.
Now implement with double. Ensure to use proper division: a/2.0 etc.
Now final step: Output each point on separate line. No extra spaces.
Potential pitfalls: If vx and vy are such that len is very small? But vx,vy are integers up to 1000 in absolute value, but can be zero? vx^2+vy^2 >0 so not both zero, so len >=1? Actually could be sqrt(1^2+0^2)=1, so okay. No issue.
Now we can produce final answer.
But wait: The output in the example has exactly 7 lines. Our code will output 7 lines. Good.
Now consider if we need to output any particular ordering like tip first then the rest. Yes.
Thus final answer is as above.
I will now write the solution explanation and code.
But before finalizing, we should double-check the statement: "The arrow consists of a triangle and a rectangle." It says "Enumerate the arrow points coordinates in counter-clockwise order starting from the tip." That implies the union is a single polygon. The polygon we enumerated is the union.
But is there any possibility that the union polygon might have 8 vertices? Because the rectangle may have its far side also of length c, so the rectangle has 4 vertices. The triangle has 3 vertices. The union might have up to 7 if they share two vertices? Actually they share the entire segment from M1 to M2? But they only share the segment M1-M2 as a common boundary? The triangle base is from A to B. The rectangle side is from M1 to M2, which is a subsegment of the base. So the union's boundary includes the entire triangle edges except the interior part of base from M1 to M2 is replaced by the rectangle's other three edges. So number of vertices = triangle vertices (3) + rectangle vertices (4) - 2* (shared vertices? Actually M1 and M2 are common to both triangle base and rectangle, but they are included in both boundaries. However, when forming union, those points become vertices of the union. So total distinct vertices: triangle vertices: T, A, B (3). Rectangle vertices: M1, Q1, Q2, M2 (4). But A and B are distinct from M1, M2 because a>c so M1 ≠ A, M2 ≠ B. So total 7 distinct points. So 7 is correct.
Now check if any vertices could be collinear in degenerate sense? a > c, so A and M1 are distinct, and M2 and B distinct. So all 7 vertices are distinct. However, if a is just slightly greater than c, points are close but distinct.
Now we should also consider the orientation of the rectangle: Could the rectangle be attached such that its side of length c is the one of length c, but the rectangle extends in direction opposite to u. That is what we used. However, what if the rectangle extends in direction u? Then intersection would be nonzero (triangle and rectangle would overlap). So that's invalid.
Thus the solution is done.
Now I'll produce final answer with explanation and code.
But before final, ensure we handle potential floating-point issues: Use double and output with 12 decimal places.
Now write final solution.
One more test: Input: "0 0 1 0 6 4 2 3" (the right-pointing arrow we computed). Our output would be:
4.000000000000 0.000000000000 0.000000000000 3.000000000000 0.000000000000 1.000000000000 -3.000000000000 1.000000000000 -3.000000000000 -1.000000000000 0.000000000000 -1.000000000000 0.000000000000 -3.000000000000
But wait check: According to our computed earlier, A = (0,3)? Actually with a=6, a/2=3, w=(0,-1)? We computed earlier: u=(1,0), w = (0,-1). Then A = C - (a/2) w = (0 - 30, 0 - 3(-1)) = (0,3). Yes. M1 = (0,1). Q1 = ( -3,1). Q2 = ( -3, -1). M2 = (0,-1). B = (0,-3). So output as above. This seems plausible arrow pointing right: tip at (4,0), base vertical line at x=0 from y=3 to y=-3, rectangle extends left from the central part y in [ -1,1 ] to x=-3. That is correct.
Now check orientation: Starting tip (4,0), then (0,3) (top of base), then (0,1) (inner top), then (-3,1) (left top), then (-3,-1) (left bottom), then (0,-1) (inner bottom), then (0,-3) (bottom of base). That is ccw? Let's compute area earlier got positive. So good.
Thus solution stands.
Now I'll prepare final answer with explanation and code. We need to output the vertices of the arrow polygon in counter‑clockwise order, starting from the tip.
The arrow is defined by a base point(px, py), a direction vector(vx, vy), and lengthsa,b,c,dwitha > c.
The triangle is isosceles: base lengtha, altitude lengthb. Its base midpoint is(px, py)and the tip lies in the direction of(vx, vy)at distanceb.
The rectangle has one side of lengthcwhose midpoint is also(px, py); it is attached to the triangle base (so that the interior of the rectangle lies opposite to the tip) and extends a distancedin that opposite direction.Let
len = sqrt(vx*vx + vy*vy)u = (vx/len, vy/len)(unit vector toward the tip)w = (u.y, -u.x)(unit vector perpendicular touobtained by a clockwise rotation; this choice makes the triangle verticesT, A, Bappear in counter‑clockwise order)
Then compute the points:
T = (px, py) + b * u // tip A = (px, py) - (a/2) * w // left (or “first”) base endpoint of the triangle M1 = (px, py) - (c/2) * w // left attachment point of the rectangle M2 = (px, py) + (c/2) * w // right attachment point Q1 = M1 - d * u // far left vertex of the rectangle Q2 = M2 - d * u // far right vertex B = (px, py) + (a/2) * w // right base endpoint of the triangleThe polygon is traversed in the order:
T→A→M1→Q1→Q2→M2→B(and then back toT).
This yields a simple 7‑vertex polygon whose interior lies always to the left of each directed edge.All calculations are done in double precision. Output each coordinate with at least 12 decimal places.
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { int px, py, vx, vy, a, b, c, d; cin >> px >> py >> vx >> vy >> a >> b >> c >> d; double len = sqrt(vx * vx + vy * vy); double ux = vx / len, uy = vy / len; // clockwise perpendicular double wx = uy, wy = -ux; // compute points double T_x = px + b * ux, T_y = py + b * uy; double A_x = px - (a / 2.0) * wx, A_y = py - (a / 2.0) * wy; double M1_x = px - (c / 2.0) * wx, M1_y = py - (c / 2.0) * wy; double M2_x = px + (c / 2.0) * wx, M2_y = py + (c / 2.0) * wy; double Q1_x = M1_x - d * ux, Q1_y = M1_y - d * uy; double Q2_x = M2_x - d * ux, Q2_y = M2_y - d * uy; double B_x = px + (a / 2.0) * wx, B_y = py + (a / 2.0) * wy; // output cout << fixed << setprecision(12); cout << T_x << " " << T_y << "\n"; cout << A_x << " " << A_y << "\n"; cout << M1_x << " " << M1_y << "\n"; cout << Q1_x << " " << Q1_y << "\n"; cout << Q2_x << " " << Q2_y << "\n"; cout << M2_x << " " << M2_y << "\n"; cout << B_x << " " << B_y << "\n"; return 0; }