import HTurtle
import Data.Complex
import System.Environment
data Circle = Circle {center :: Point, r :: Double}
getP :: Circle -> Double -> Point
getP c radian = let (a :+ b) = c0 in (a,b)
where c0 = mkPolar (r c) radian
drawCircle :: Circle -> IO()
drawCircle c = circle (center c) (r c)
getAs :: IO [Double]
getAs = do
as <- getArgs
return $ map read as
main = do
[a,b,c,d] <- getAs
start
screensize (3000,2500)
pensize 5
speed 10
let c0 = Circle (0,0) a
print $ getP c0 pi
drawCircle c0
let c1 = Circle (0,0) b
-- drawCircle c1
dot (0,0)
mapM_ dot $ dots0 c0 c
mapM_ dot $ dots1 c1 c
color "red"
line [p0 b c d, p1 a c] "red"
let (aa,bb) = p0 b c d
line [p2 (aa :+ bb), dots0 c0 c !! 1] "red"
color "blue"
line [(0,0), (getP c0 ((yen / (c*2) * (-1)) * 3))] "blue"
end
dots0 c h = map (\x -> getP c x) $ take (round h) [0 , (yen / h) ..]
dots1 c h = map (\x -> getP c x) $ take (round (h/2)) [x + yen/h|x <- [0, (yen / (h/2)) ..]]
yen = pi * 2
p0 r h k = let (a :+ b) = x in (a,b)
where x = mkPolar r (yen / (h / 2) * (k - 1) / 2)
p1 r h = let (a :+ b) = x in (a,b)
where x = mkPolar r (yen / h * (-1))
p2 c = let (a :+ b) = conjugate c in (a,b)
2023年6月3日土曜日
ハブ、リム、マーク合わせ
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿