Skip to content

Commit dbf6a9b

Browse files
committed
2 parents 9167269 + 0074dd4 commit dbf6a9b

39 files changed

+1312
-450
lines changed

Book/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore the built files
2+
build/

Book/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
run :
3+
python3 build.py

Book/build.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def build_index(sources):
109109
("Differential calculus", "Physics/src/Calculus/DifferentialCalc.lhs"),
110110
("Integral calculus", "Physics/src/Calculus/IntegralCalc.lhs"),
111111
("Plotting graphs", "Physics/src/Calculus/VisVerApp.lhs"),
112+
("Syntax trees", "Physics/src/Calculus/SyntaxTree.lhs"),
112113
]),
113114
("Linear algebra", [
114115
("Vectors", "Physics/src/Vector/Vector.lhs")
@@ -123,6 +124,19 @@ def build_index(sources):
123124
("Testing of Quantities",
124125
"Physics/src/Dimensions/Quantity/Test.lhs"),
125126
("Usage", "Physics/src/Dimensions/Usage.lhs"),
127+
]),
128+
("Vectors", [
129+
("Vector", "Physics/src/Vector/Vector.lhs")
130+
]),
131+
("Calculus", [
132+
("Introduction", "Physics/src/Calculus/Intro.lhs"),
133+
("Function expressions", "Physics/src/Calculus/FunExpr.lhs"),
134+
("Differential calculus", "Physics/src/Calculus/DifferentialCalc.lhs"),
135+
("Integral calculus", "Physics/src/Calculus/IntegralCalc.lhs"),
136+
("Visualization, Verification, and Application", "Physics/src/Calculus/VisVerApp.lhs"),
137+
]),
138+
("Newtonian Mechanics", [
139+
("Single particle mechanics", "Physics/src/NewtonianMechanics/SingleParticle.lhs")
126140
])
127141
# ("Examples", [
128142
# ("Gungbräda", "Physics/src/Examples/Gungbraeda.lhs"),

Book/chapter.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<a href="../index.html">Table of contents</a>
3232
<span>Next: <a href="{next-href}">{next-name}</a></span>
3333
</nav>
34-
© Kandidatboisen (2018), GPL
34+
© Björn Werner, Erik Sjöström, Johan Johansson, Oskar Lundström (2018), GPL
3535
</footer>
3636
</body>
3737
</html>

Book/includes/type.html

Lines changed: 0 additions & 63 deletions
This file was deleted.

Book/index.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</main>
2121

2222
<footer>
23-
© Kandidatboisen (2018), GPL
23+
© Björn Werner, Erik Sjöström, Johan Johansson, Oskar Lundström (2018), GPL
2424
</footer>
2525
</body>
2626
</html>

Book/test.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

Physics/Hatlab/package.cache

40 Bytes
Binary file not shown.

Physics/Hatlab/package.cache.lock

Whitespace-only changes.

Physics/_w

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
> {-# LANGUAGE GADTs #-}
2+
> module Body.TypedVectors where
3+
4+
In order to do some physics we have to imbue our vectors with a dimension.
5+
6+
> import Vector.Vector as V
7+
> import Dimensions.ValueLevel as Val
8+
9+
> data TypedVector = TV Vector2 Dim
10+
11+
> velocity :: TypedVector
12+
> velocity = TV (V2 0 0) (Val.length `Val.div` time)
13+
14+
> instance Show TypedVector where
15+
> show (TV vec dim) = show (V.magnitude vec) ++ " " ++ show dim
16+
17+
We can add vectors together
18+
19+
> data TVOps where
20+
> Add :: TypedVector -> TypedVector -> TVOps
21+
> Scale :: Scalar -> TypedVector -> TVOps
22+
23+
24+
> add :: TypedVector -> TypedVector -> TVOps
25+
> add = Add
26+
27+
> eval :: TVOps -> IO TypedVector
28+
> eval (Add (TV vec1 dim1) (TV vec2 dim2)) = case dim1 == dim2 of
29+
> True -> return $ TV (V.add vec1 vec2) dim1
30+
> False -> error "Dimensions are different"
31+
> eval (Scale s (TV vec dim)) = return $ TV (V.scale s vec) dim
32+
33+
34+

0 commit comments

Comments
 (0)