Skip to content

Commit

Permalink
Fix scaling resolution bug for Obj2s.
Browse files Browse the repository at this point in the history
- 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
colah committed Dec 4, 2012
1 parent 4695b9f commit 7161dc6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Graphics/Implicit/Export/SymbolicObj2.hs
Expand Up @@ -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),
Expand Down

0 comments on commit 7161dc6

Please sign in to comment.