Permalink
Browse files

Fix scaling resolution bug for Obj2s.

- symbolic rendering of 2D objects was removing a Scale2 but not
  chainging the resolution, leading to weird bugs. This is now fixed.
  • Loading branch information...
1 parent 4695b9f commit 7161dc696704a888786cb750bf21cc70f50a9da6 @colah committed Dec 4, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 Graphics/Implicit/Export/SymbolicObj2.hs
View
7 Graphics/Implicit/Export/SymbolicObj2.hs
@@ -45,16 +45,17 @@ symbolicGetContour _ (RectR 0 (x1,y1) (x2,y2)) = [[ (x1,y1), (x2,y1), (x2,y2), (
symbolicGetContour res (Circle r) = [[ ( r*cos(2*pi*m/n), r*sin(2*pi*m/n) ) | m <- [0.. n] ]] where
n = max 5 (fromIntegral $ ceiling $ 2*pi*r/res)
symbolicGetContour res (Translate2 v obj) = map (map (+ v) ) $ symbolicGetContour res obj
-symbolicGetContour res (Scale2 s obj) = map (map (⋯* s)) $ symbolicGetContour res obj
+symbolicGetContour res (Scale2 s@(a,b) obj) = map (map (⋯* s)) $ symbolicGetContour (res/sc) obj
+ where sc = max a b
symbolicGetContour res obj = case rebound2 (getImplicit2 obj, getBox2 obj) of
(obj, (a,b)) -> Render.getContour a b res obj
symbolicGetContourMesh :: -> SymbolicObj2 -> [(ℝ2,ℝ2,ℝ2)]
symbolicGetContourMesh res (Translate2 v obj) = map (\(a,b,c) -> (a + v, b + v, c + v) ) $
symbolicGetContourMesh res obj
-symbolicGetContourMesh res (Scale2 s obj) = map (\(a,b,c) -> (a ⋯* s, b ⋯* s, c ⋯* s) ) $
- symbolicGetContourMesh res obj
+symbolicGetContourMesh res (Scale2 s@(a,b) obj) = map (\(a,b,c) -> (a ⋯* s, b ⋯* s, c ⋯* s) ) $
+ symbolicGetContourMesh (res/sc) obj where sc = max a b
symbolicGetContourMesh _ (RectR 0 (x1,y1) (x2,y2)) = [((x1,y1), (x2,y1), (x2,y2)), ((x2,y2), (x1,y2), (x1,y1)) ]
symbolicGetContourMesh res (Circle r) =
[ ((0,0),

0 comments on commit 7161dc6

Please sign in to comment.