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
"""
CS1 24fa - Assignment 4
Constants required for a Newton's cradle simulation.
"""
from vpython import color, pi, textures, vector # type: ignore
from support.types import VPythonColor, VPythonTexture
GRAV: float = 9.81 # gravitational acceleration in m/s^2
R: float = 0.2 # cord length in meters, functions as size parameter for whole system
THETA_INIT: float = -30 * pi / 180 # initial angle of 1st pendulum in radians
DT: float = 0.005 # timestep (between 0.000005 [slo-mo] and 0.01 [normal])
# TODO 0.1: Choose the relevant range of cells in the spreadsheet
RANGE: str = ""
# TODO 0.2: Enter the relevant spreadsheet ID
SPREADSHEET_ID: str = ""
# Define color and texture dictionaries that map strings -> VPython attributes
COLOR_MAP: dict[str, VPythonColor] = {
"red": color.red,
"green": color.green,
"blue": color.blue,
"yellow": color.yellow,
"orange": color.orange,
"cyan": color.cyan,
"magenta": color.magenta,
"white": color.white,
"black": color.black,
"gray": color.gray(0.5), # type: ignore
}
TEXTURE_MAP: dict[str, VPythonTexture] = {
"earth": textures.earth,
"flower": textures.flower,
"granite": textures.granite,
"gravel": textures.gravel,
"metal": textures.metal,
"rock": textures.rock,
"rough": textures.rough,
"rug": textures.rug,
"stones": textures.stones,
"stucco": textures.stucco,
"wood": textures.wood,
"wood_old": textures.wood_old,
}