Make argument of scale Double
This commit is contained in:
parent
b9c0851beb
commit
872954f492
|
@ -21,8 +21,8 @@ instance Arbitrary Vertex where
|
|||
fromAngle angle = Point (sin angle, cos angle)
|
||||
|
||||
-- | 'scale' @s@ @p@ scales the vector to @p@ by the factor @s@.
|
||||
scale :: Integer -> Vertex -> Vertex
|
||||
scale s (Point (x, y)) = Point (fromInteger s * x, fromInteger s * y)
|
||||
scale :: Double -> Vertex -> Vertex
|
||||
scale s (Point (x, y)) = Point (s * x, s * y)
|
||||
|
||||
-- | 'move' @p1@ @p2@ adds the coordinates of @p1@ and @p2@,
|
||||
-- effectively moving @p1@ by @p2@ (or vice-versa).
|
||||
|
@ -43,14 +43,14 @@ instance Show PolygonPath where
|
|||
-- with the center at @pos@
|
||||
-- that is modified in the sense that it takes @rf@,
|
||||
-- which is used to set the radius for each individual point.
|
||||
regularPolygonMod :: Integer -> (Integer -> Integer) -> Vertex -> PolygonPath
|
||||
regularPolygonMod :: Integer -> (Integer -> Double) -> Vertex -> PolygonPath
|
||||
regularPolygonMod n rf pos = PolygonPath (map (\step -> move pos $ scale (rf step) $ fromAngle (fromInteger step * 2 * pi / fromInteger n)) [0 .. (n - 1)])
|
||||
|
||||
-- | 'regularPolygon' @n@ @r@ @pos@
|
||||
-- creates a regular polygon
|
||||
-- with the radius @r@
|
||||
-- and the center at @pos@.
|
||||
regularPolygon :: Integer -> Integer -> Vertex -> PolygonPath
|
||||
regularPolygon :: Integer -> Double -> Vertex -> PolygonPath
|
||||
regularPolygon n r = regularPolygonMod n (const r)
|
||||
|
||||
-- | 'star' @n@ @r1@ @r2@ @pos@
|
||||
|
@ -59,7 +59,7 @@ regularPolygon n r = regularPolygonMod n (const r)
|
|||
-- the inner radius @r1@,
|
||||
-- the outer radius @r2@
|
||||
-- and the center @pos@.
|
||||
star :: Integer -> Integer -> Integer -> Vertex -> PolygonPath
|
||||
star :: Integer -> Double -> Double -> Vertex -> PolygonPath
|
||||
star n r1 r2 = regularPolygonMod (n * 2) ((take (fromInteger n * 2) (cycle [r1, r2]) !!) . fromInteger)
|
||||
|
||||
main :: IO ()
|
||||
|
|
Reference in a new issue