oscpacking-0.1.0.0: Geometry.hs
{--
This file is part of the OscPacking library.
Copyright 2016 Christopher Howard.
OscPacking is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OscPacking is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OscPacking. If not, see <http://www.gnu.org/licenses/>.
--}
module Geometry where
data Circle = Circle {
position :: Point,
radius :: Float
}
type Point = (Float, Float)
type Metric = Point -> Point -> Float
euclidean :: Metric
euclidean (x1, y1) (x2, y2) = sqrt ((x2 - x1)**2 + (y2 - y1)**2)
distToCircle :: Point -> Circle -> Float
distToCircle point circle = euclidean point (position circle) - radius circle