Skip to content

Commit 8533cae

Browse files
committed
Fixed comments
1 parent a0272b8 commit 8533cae

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

Physics/src/Vector/Vector.lhs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type VectorTwo = Vector2 Scalar
3838
The magnitude of the vector is it's length. We can calculate this using
3939
Pythagorean theorem:
4040
\begin{equation}
41-
x^2 + y^2 = mag^2
41+
x^2 + y^2 = magnitude^2
4242
\end{equation}
4343

4444
In haskell this would be:
@@ -74,11 +74,15 @@ hundreds of vectors so it would be useful to add, for instance a list of
7474
vectors together and get one final vector as a result. We can use \textit{foldr}
7575
using the zero vector as a starting value.
7676
to acomplish this.
77+
78+
\begin{spec}
79+
zeroVector :: VectorTwo
80+
zeroVector = V2 0 0
81+
\end{spec}
82+
7783
\begin{code}
7884
addListOfVectors :: [VectorTwo] -> VectorTwo
7985
addListOfVectors = foldr add zeroVector
80-
where
81-
zeroVector = V2 0 0
8286
\end{code}
8387
8488
Let's try it out!
@@ -100,15 +104,15 @@ coordinates let's make our own instance for Show.
100104
101105
\begin{code}
102106
instance Show num => Show (Vector2 num) where
103-
show (V2 x y) = "(" ++ show x ++ " x, " ++ show y ++ " y)"
107+
show (V2 x y) = "(" ++ show x ++ ", " ++ show y ++ ")"
104108
\end{code}
105109
106110
And let's try our example again:
107111
```
108112
*Vector> let vec1 = V2 5 3
109113
*Vector> let vec2 = V2 6 5
110-
*Vector> sub2 vec1 vec2
111-
(-1.0 x, -1.0 y)
114+
*Vector> sub vec1 vec2
115+
(-1 x, -2 y)
112116
```
113117
114118
And let's also try adding a list of vectors using our new function:
@@ -117,7 +121,7 @@ And let's also try adding a list of vectors using our new function:
117121
*Vector> let vec3 = V2 8 9
118122
*Vector> let vectors = [vec1, vec2, vec3]
119123
*Vector> addListOfVectors vectors
120-
(19.0 x, 18.0 y)
124+
(19.0 x, 17.0 y)
121125
```
122126
123127
It works!
@@ -208,7 +212,7 @@ direction of $y$ will be boosted. But there are worse ways to hit the dash
208212
panel. We could for instance create a new velocity vector with the exact same
209213
magnitude of speed but which would recieve a worse boost.
210214
211-
% TODO: Picture of mario kart / dash panel
215+
![](boost.png "A mysterious man in a rad hat on a boost pad"){.float-img-right}
212216
213217
\begin{code}
214218
worseCart :: VectorTwo
@@ -228,8 +232,8 @@ True
228232
We talked a lot about angles between vectors but we havn't used it in our code,
229233
so lets make a function which calculates the angle of a vector. The formula is
230234
as follows:
231-
%TODO
232-
\textbf{Insert picture of angle of triangle here}
235+
236+
![](atan.png "Beautiful vector calculus"){.float-img-center}
233237
234238
We'll use Doubles to represent the angle.
235239
\begin{code}
@@ -239,7 +243,7 @@ angle :: VectorTwo -> Scalar
239243
angle (V2 x y) = atan y/x
240244
\end{code}
241245
242-
Using angles and magnitudes we can even make a new function for making vectors:
246+
Using angles and magnitudes we can even write a new function for making vectors:
243247
244248
\begin{code}
245249
mkVector :: Scalar -> Angle -> VectorTwo
@@ -249,10 +253,6 @@ mkVector mag angle = V2 x y
249253
y = mag * sin angle
250254
\end{code}
251255
252-
%-- Angle between two vectors
253-
%angleG :: Vector vec => vec -> vec -> Scalar
254-
%angleG v1 v2 = (dotProd v1 v2) / ((magnitude v1) * (magnitude v2))
255-
256256
Vectors in three dimensions.
257257
--------------------------------------
258258
@@ -344,10 +344,10 @@ between vectors.
344344
\begin{code}
345345
add :: (Num num, Vector vec) => vec num -> vec num -> vec num
346346
add = vzipWith (+)
347-
\end{code}
348347
349348
sub :: (Num num, Vector vec) => vec num -> vec num -> vec num
350349
sub = vzipWith (-)
350+
\end{code}
351351
352352
For multiplying with a scalar:
353353

Physics/src/Vector/atan.png

12.8 KB
Loading

Physics/src/Vector/boost.png

20.3 KB
Loading

0 commit comments

Comments
 (0)