Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scad rotate fixes #35

Merged
merged 1 commit into from Mar 5, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions Graphics/Implicit/ExtOpenScad/Statements.hs
Expand Up @@ -518,16 +518,18 @@ translateStatement = moduleWithSuite "translate" $ \suite -> do
getAndTransformSuiteObjs suite (Op.translate (x,0.0) ) (Op.translate (x,0.0,0.0))
) <||> (\ _ -> noChange)

deg2rad x = x / 180.0 * pi

-- This is mostly insane
rotateStatement = moduleWithSuite "rotate" $ \suite -> do
a <- argument "a"
caseOType a $
( \xy ->
getAndTransformSuiteObjs suite (Op.rotateXY xy ) (Op.rotate3 (xy, 0, 0) )
) <||> ( \(yz,xz,xy) ->
getAndTransformSuiteObjs suite (Op.rotateXY xy ) (Op.rotate3 (yz, xz, xy) )
) <||> ( \(yz,xz) ->
getAndTransformSuiteObjs suite (id ) (Op.rotate3 (yz, xz, 0))
( \xy ->
getAndTransformSuiteObjs suite (Op.rotateXY $ deg2rad xy ) (Op.rotate3 (deg2rad xy, 0, 0) )
) <||> ( \(yz,xy,xz) ->
getAndTransformSuiteObjs suite (Op.rotateXY $ deg2rad xy ) (Op.rotate3 (deg2rad yz, deg2rad xz, deg2rad xy) )
) <||> ( \(yz,xz) ->
getAndTransformSuiteObjs suite (id ) (Op.rotate3 (deg2rad yz, deg2rad xz, 0))
) <||> ( \_ -> noChange )


Expand Down