Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs1-25sp
lecture-code
Commits
f609a883
Commit
f609a883
authored
1 month ago
by
Adam Blank
Browse files
Options
Download
Email Patches
Plain Diff
Add new file
parent
2727c49c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
12/physics.py
+39
-0
12/physics.py
with
39 additions
and
0 deletions
+39
-0
12/physics.py
0 → 100644
View file @
f609a883
from
vpython
import
sphere
,
vec
,
vector
,
color
,
cylinder
,
rate
,
cos
,
cross
,
mag
,
sin
,
pi
# type: ignore
sphere
,
vec
,
vector
,
color
,
cylinder
,
rate
,
cos
,
cross
,
mag
,
sin
,
pi
# type: ignore
POSITION
:
vector
=
vec
(
0
,
0
,
0
)
SIZE
:
vector
=
vec
(
5
,
0.5
,
0.5
)
DIRS
:
list
[
int
]
=
[
0
,
1
,
-
1
]
RADIUS
:
int
=
1
def
setup
()
->
dict
[
tuple
[
int
,
int
,
int
],
cylinder
]:
ball
:
sphere
=
sphere
(
pos
=
POSITION
,
radius
=
RADIUS
,
color
=
color
.
yellow
)
res
=
{}
return
res
def
rotate
(
v
:
vector
,
e
:
vector
,
angle
:
float
)
->
vector
:
"""
See https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula#Statement
v + sin(theta) * (e x v) + (1 - cos(theta)) * (e x (e x v))
"""
return
v
def
scale
(
v
:
vector
,
by
:
float
)
->
vector
:
return
v
ANGLE
:
float
=
pi
/
64
CYLINDERS
:
dict
[
tuple
[
int
,
int
,
int
],
cylinder
]
=
setup
()
while
True
:
rate
(
10
)
for
i
in
DIRS
:
for
j
in
DIRS
:
for
k
in
DIRS
:
pass
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment