-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
65 lines (45 loc) · 1.41 KB
/
main.py
File metadata and controls
65 lines (45 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# VAMMS - A Project Lead The Way project
# Jack Sloan, Shawn Johnson, and Matthew Wincek
# 2023-2024
# Dependencies
import math
import numpy as np
from connection import Connection
from graph import Graph
from renderer import Renderer
import dance
from colors import Colors
raw_function = input("Enter your function: f(x,y)=")
if(raw_function) == "SJM":
dance.dance()
raw_function = input("Enter your function: f(x,y)=")
try:
x_min = int(input("Minimum x value (inclusive): "))
except ValueError:
x_min = 0
try:
x_max = int(input("Maximum x value (exclusive): "))
except ValueError:
x_max = 10
try:
y_min = int(input("Minimum y value (inclusive): "))
except ValueError:
y_min = 0
try:
y_max = int(input("Maximum y value (exclusive): "))
except ValueError:
y_max = 10
def clean_function(function):
function = function.replace(" ", "")
function = function.replace("xy", "x * y")
function = function.replace("yx", "x * y")
print(Colors.CYAN + f"Graphing: {function}" + Colors.RESET)
return function
def generate_graph(function, x_min, x_max, y_min, y_max):
graph = Graph(function)
graph.fill(x_min, x_max, y_min, y_max) # x max, x min, y max, y min
graph.scale()
renderer = Renderer(graph.scaled_array)
renderer.render()
cleaned_function = clean_function(raw_function)
generate_graph(cleaned_function, x_min, x_max, y_min, y_max)