summaryrefslogtreecommitdiff
path: root/MeshSketch.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-05-25 20:01:35 -0400
committerJoe Crayne <joe@jerkface.net>2019-05-25 20:01:35 -0400
commit27aa69522ca3da4fe04f996eb87a13e295db0f9f (patch)
tree12d08ea5b702b94753c1cfbd5fb18099a00368e5 /MeshSketch.hs
parent786e58ccbb05ced78c5421b53fbc469971d7db82 (diff)
Attempt to detect sharp-turns.
Diffstat (limited to 'MeshSketch.hs')
-rw-r--r--MeshSketch.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/MeshSketch.hs b/MeshSketch.hs
index ea8fbe6..7cda3fc 100644
--- a/MeshSketch.hs
+++ b/MeshSketch.hs
@@ -622,10 +622,15 @@ pushRing w st h k c = do
622 g <- pushFront (fromList [h,k]) <$> readIORef (stRecentPts st) 622 g <- pushFront (fromList [h,k]) <$> readIORef (stRecentPts st)
623 writeIORef (stRecentPts st) g 623 writeIORef (stRecentPts st) g
624 with3 g $ \a b c -> do 624 with3 g $ \a b c -> do
625 let d = det $ fromRows [(b-c),(a-b)] 625 let û = unit $ a-b
626 putStrLn $ "d = " ++ show d 626 v̂ = unit $ b-c
627 δ = norm_1 $ (a-b)^2
628 d = det $ fromRows [û,v̂]
629 x = dot û v̂
630 putStrLn $ "(d,x) = " ++ show (d,x)
627 updateBack (stRingBuffer st) $ \RingPoint{..} -> do 631 updateBack (stRingBuffer st) $ \RingPoint{..} -> do
628 rpColor @<- if d<0 then blue else red 632 rpColor @<- if x < 0.3 || δ<0.5 then yellow
633 else if d<0 then blue else red
629 pushBack (stRingBuffer st) $ \RingPoint{..} -> do 634 pushBack (stRingBuffer st) $ \RingPoint{..} -> do
630 rpPosition @<- d 635 rpPosition @<- d
631 rpColor @<- c 636 rpColor @<- c