Skip to content

Commit

Permalink
Find distance between two points on the tabletop
Browse files Browse the repository at this point in the history
  • Loading branch information
mwunsch committed Oct 6, 2016
1 parent 9ab7bb5 commit 552e819
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Tabletop.elm
Expand Up @@ -36,9 +36,11 @@ positionFromMouseCoords ( x, y ) scale =
transform a =
round <| (toFloat a) / scale

x' = transform x
x' =
transform x

y' = transform y
y' =
transform y
in
( x', y' )

Expand All @@ -47,6 +49,20 @@ type alias Inch =
Int


distance : Position -> Position -> Float
distance ( x1, y1 ) ( x2, y2 ) =
let
y' =
(y1 - y2) ^ 2

x' =
(x1 - x2) ^ 2
in
(x' + y')
|> toFloat
|> sqrt


view : Tabletop -> List (Svg msg) -> Svg msg
view tabletop children =
rect
Expand Down

0 comments on commit 552e819

Please sign in to comment.