Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
If it is possible to represent this figure as a polygon, then it is possible like this
. And if not, then we represent the upper part as a polygon, and the lower part is checked as an occurrence in a circle , but if the Y coordinate of the point is above the center of the circle, then false
PS An example of the second option on js
I think that this figure can be quite simply described by a set of functions: two straight lines and a lower arc of a circle. More in code:
import math
def f1(x):
return x + 1
def f2(x):
return -x + 1
# x^2 + y^2 = r^2 => y = sqrt(r^2 - x^2)
def c(x, r=1):
return -math.sqrt(r**2 - x**2)
x = float(input("Enter x: "))
y = float(input("Enter y: "))
if y <= f1(x) and y <= f2(x) and y >= c(x):
print("hit")
else:
print("missed")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question