  Write a python code of a function that takes in four points in a counterclockwise order, a, b, c, d and return true if the quadrilateral is convex and false if it is nonconvex. Only the edges ac or bd are flippable.

Question

Write a python code of a function that takes in four points in a counterclockwise order, a, b, c, d and return true if the quadrilateral is convex and false if it is nonconvex. Only the edges ac or bd are flippable.

Step 1

Program Instructions:

• Create a function isConvex() and pass the four points as arguments.
• Save the parameters a, b, and c in a tuple named points.
• Use the function cross_product() to calculate the cross products of adjacent edges of the first three points.
• Return the value true if the cross product is positive, else false.
Step 2

Program:

# to return the cross product of the any three adjacent points

def cross_product(a,b,c):

return (a-b)*(b-c)-(a-b)*(b-c)

# function to check whether the quadilateral is convex or not

def isConvex(a,b,c,d):

points = [a,b,c,d]

# to check whether the cross_product is positive

sign= [cross_product(a,b,c...

Want to see the full answer?

See Solution

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
Tagged in

Python 