From 820775e87ae2761c334b97ae3ff8c6f7917cde16 Mon Sep 17 00:00:00 2001 From: BiscuitCandy <70342294+BiscuitCandy@users.noreply.github.com> Date: Fri, 8 Oct 2021 18:58:10 -0700 Subject: [PATCH] added area of circle given center and a point --- .../area_of_circle_given_center_and_point.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py diff --git a/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py b/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py new file mode 100644 index 0000000..e928fa7 --- /dev/null +++ b/mathgenerator/funcs/geometry/area_of_circle_given_center_and_point.py @@ -0,0 +1,27 @@ +from .__init__ import * +from math import cos, sin, pi + + +def gen_func(maxCoordinate = 10, maxRadius=10, format='string'): + r = random.randint(0, maxRadius) + center_x = random.randint(-maxCoordinate, maxCoordinate) + center_y = random.randint(-maxCoordinate, maxCoordinate) + + angle = random.choice([0, pi//6, pi//2, pi, pi+pi//6, 3*pi//2]) + + point_x = center_x + round(r*cos(angle), 2) + point_y = center_y + round(r*sin(angle), 2) + + area = round(pi * r * r, 2) + + if format == 'string': + problem = f"Area of circle with center ({center_x},{center_y}) and passing through ({point_x}, {point_y}) is" + return problem, str(area) + elif format == 'latex': + return "Latex unavailable" + else: + return center_x, center_y, point_x, point_y, area + + +area_of_circle = Generator("Area of Circle given center and a point on circle", 789, gen_func, + ["maxCoordinate = 10", "maxRadius=10"]) \ No newline at end of file