Permalink
Browse files

extopenscad: Avoid breaking up vector

  • Loading branch information...
1 parent 2f6e1ca commit bad8efed2008583a0844bf31646dbfd24eaeeb93 @bgamari bgamari committed Nov 25, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 extopenscad.hs
View
@@ -17,6 +17,7 @@ import Data.Maybe as Maybe
import Text.ParserCombinators.Parsec (errorPos, sourceLine)
import Text.ParserCombinators.Parsec.Error
import Data.IORef (writeIORef)
+import Data.VectorSpace
-- | strip a .scad or .escad file to its basename.
strip :: String -> String
@@ -45,8 +46,8 @@ getRes (varlookup, _, obj:_) =
getRes (varlookup, obj:_, _) =
let
- ((x1,y1),(x2,y2)) = getBox2 obj
- (x,y) = (x2-x1, y2-y1)
+ (p1,p2) = getBox2 obj
+ (x,y) = p2 ^-^ p1
in case Maybe.fromMaybe (ONum 1) $ Map.lookup "$quality" varlookup of
ONum qual | qual > 0 -> min (min x y/2) ((x*y/qual)**0.5 / 30)
_ -> min (min x y/2) ((x*y )**0.5 / 30)

0 comments on commit bad8efe

Please sign in to comment.