4 different points on the plane Read the coordinates of A(xa,ya), B(x, , and read those 4 points Create a program that outputs YES if there is no dent in the quadrangle with the coordinates as the vertices, and NO if there is a dent.
Assistant
import sys
for line in sys.stdin:
data = list(map(float, line.strip().split(',')))
x_a, y_a, x_b, y_b, x_c, y_c, x_d, y_d = data
abx = x_b - x_a
aby = y_b - y_a
bcx = x_c - x_b
bcy = y_c - y_b
cdx = x_d - x_c
cdy = y_d - y_c
dax = x_a - x_d
day = y_a - y_d
cross1 = abx * bcy - aby * bcx
cross2 = bcx * cdy - bcy * cdx
cross3 = cdx * day - cdy * dax
cross4 = dax * aby - day * abx
sign1 = 1 if cross1 > 0 else -1
sign2 = 1 if cross2 > 0 else -1
sign3 = 1 if cross3 > 0 else -1
sign4 = 1 if cross4 > 0 else -1
if sign1 == sign2 == sign3 == sign4:
print("YES")
else:
print("NO")
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
A quadrangle with a dent is a quadrangle as shown in Figure 1.
Given multiple datasets. The format of each dataset is as follows.
xa, ya, xb, yb, xc, yc, xd, yd
xa, ya, xb, yb, xc, yc, xd, yd are -100 or more and 100 or less, respectively, and are given as real numbers.
1 No more than two points can be lined up on a straight line. Also, if you connect the points in the order of input, the coordinates of the points will be input in the order of forming a quadrangle. (That is, the points are not given in the order shown in Figure 2.)