1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

examples: improve the pendulum simulation, with several modes and diagrams (#13446)

This commit is contained in:
Ulises Jeremias Cornejo Fandos
2022-02-12 14:38:07 -03:00
committed by GitHub
parent a74d28ae5f
commit 4391ae563d
26 changed files with 1501 additions and 366 deletions

View File

@ -0,0 +1,64 @@
module sim
fn test_add() {
v := vector(
x: -0.016957230930171364
y: -0.02937078552673521
z: 0.002311063475327252
)
result := v + v
expected := vector(
x: -0.03391446186034273
y: -0.05874157105347042
z: 0.004622126950654504
)
assert result == expected
}
fn test_dot() {
v := vector(
x: -0.016957230930171364
y: -0.02937078552673521
z: 0.002311063475327252
)
result := v * v
expected := 0.0011555317376636305
assert result == expected
}
fn test_scale() {
v := vector(
x: -0.016957230930171364
y: -0.02937078552673521
z: 0.002311063475327252
)
result := v.scale(2.0)
expected := vector(
x: -0.03391446186034273
y: -0.05874157105347042
z: 0.004622126950654504
)
assert result == expected
}
fn test_norm_squared() {
v := vector(
x: -0.016957230930171364
y: -0.02937078552673521
z: 0.002311063475327252
)
result := v.norm_squared()
expected := 0.0011555317376636305
assert result == expected
}
fn test_norm() {
v := vector(
x: -0.016957230930171364
y: -0.02937078552673521
z: 0.002311063475327252
)
result := v.norm()
expected := 0.033993113091678295
assert result == expected
}