Skip to content

Commit

Permalink
Add circle sweeping for torus
Browse files Browse the repository at this point in the history
  • Loading branch information
samipourquoi committed Feb 7, 2021
1 parent b0e2de5 commit d9b7e1a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions .ghci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:set prompt "ghci> "
1 change: 1 addition & 0 deletions donut-hs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ build-type: Simple

executable donut-hs
main-is: Main.hs
other-modules: Data.Vector
build-depends: base >=4.14 && <4.15
hs-source-dirs: src
default-language: Haskell2010
13 changes: 13 additions & 0 deletions src/Data/Vector.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Data.Vector
( Vector(Vector) ) where

data Vector a = Vector a a a
deriving (Show, Eq)

instance (Num a) => Num (Vector a) where
(Vector x1 y1 z1) + (Vector x2 y2 z2) = Vector (x1+x2) (y1+y2) (z1+z2)
(*) = undefined
abs = undefined
signum = undefined
fromInteger = undefined
negate = undefined
20 changes: 19 additions & 1 deletion src/Main.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
module Main where

import Data.Vector

_r :: Float
_r = 1.0
_R :: Float
_R = 2.0

drawCircle :: Vector Float -> [Vector Float]
drawCircle center = map ((+) center . vradius) [0,0.1..2*pi]
where
vradius :: Float -> Vector Float
vradius theta = Vector (_r * cos theta) (_r * sin theta) 0

render :: [[Char]]
render = ["hello", "world"]

main :: IO ()
main = putStrLn "Hello, Haskell!"
main = do
let screen = unlines render
putStr screen

0 comments on commit d9b7e1a

Please sign in to comment.