Skip to content

Commit

Permalink
Transform2 -> Transform
Browse files Browse the repository at this point in the history
so it is aligned with Rotate, Rotate3 naming
  • Loading branch information
sorki committed Nov 1, 2023
1 parent e05ce20 commit 3327cf4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Graphics/Implicit/Definitions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module Graphics.Implicit.Definitions (
Circle,
Polygon,
Rotate2,
Transform2,
Transform,
Shared2),
SymbolicObj3(
Cube,
Expand Down Expand Up @@ -294,7 +294,7 @@ data SymbolicObj2 =
| Polygon [ℝ2] -- points.
-- Simple transforms
| Rotate2 SymbolicObj2
| Transform2 (M33 ) SymbolicObj2
| Transform (M33 ) SymbolicObj2
-- Lifting common objects
| Shared2 (SharedObj SymbolicObj2 V2 )
deriving (Generic)
Expand All @@ -308,7 +308,7 @@ instance Show SymbolicObj2 where
Circle r -> showCon "circle" @| r
Polygon ps -> showCon "polygon" @| ps
Rotate2 v obj -> showCon "rotate" @| v @| obj
Transform2 m obj -> showCon "transform" @| m @| obj
Transform m obj -> showCon "transform" @| m @| obj
Shared2 obj -> flip showsPrec obj

-- | Semigroup under 'Graphic.Implicit.Primitives.union'.
Expand Down
4 changes: 2 additions & 2 deletions Graphics/Implicit/Export/SymbolicFormats.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Graphics.Implicit.Export.SymbolicFormats (scad2, scad3) where

import Prelude((.), fmap, Either(Left, Right), ($), (*), ($!), (-), (/), pi, error, (+), (==), take, floor, (&&), const, pure, (<>), sequenceA, (<$>))

import Graphics.Implicit.Definitions(, SymbolicObj2(Shared2, Square, Circle, Polygon, Rotate2, Transform2), SymbolicObj3(Shared3, Cube, Sphere, Cylinder, Rotate3, Transform3, Extrude, ExtrudeM, RotateExtrude, ExtrudeOnEdgeOf), isScaleID, SharedObj(Empty, Full, Complement, UnionR, IntersectR, DifferenceR, Translate, Scale, Mirror, Outset, Shell, EmbedBoxedObj, WithRounding), quaternionToEuler)
import Graphics.Implicit.Definitions(, SymbolicObj2(Shared2, Square, Circle, Polygon, Rotate2, Transform), SymbolicObj3(Shared3, Cube, Sphere, Cylinder, Rotate3, Transform3, Extrude, ExtrudeM, RotateExtrude, ExtrudeOnEdgeOf), isScaleID, SharedObj(Empty, Full, Complement, UnionR, IntersectR, DifferenceR, Translate, Scale, Mirror, Outset, Shell, EmbedBoxedObj, WithRounding), quaternionToEuler)
import Graphics.Implicit.Export.TextBuilderUtils(Text, Builder, toLazyText, fromLazyText, bf)

import Control.Monad.Reader (Reader, runReader, ask)
Expand Down Expand Up @@ -176,7 +176,7 @@ buildS2 (Polygon points) = call "polygon" (fmap bvect points) []

buildS2 (Rotate2 r obj) = call "rotate" [bf (rad2deg r)] [buildS2 obj]

buildS2 (Transform2 m obj) =
buildS2 (Transform m obj) =
let toM44 (V3 (V3 a b c) (V3 d e f) (V3 g h i)) =
V4 (V4 a b c 0)
(V4 d e f 0)
Expand Down
4 changes: 2 additions & 2 deletions Graphics/Implicit/ObjectUtil/GetBox2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Graphics.Implicit.ObjectUtil.GetBox2 (getBox2, getBox2R) where
import Prelude(pure, fmap, Eq, (==), (.), (<$>), (||), unzip, minimum, maximum, ($), (/), (-), (+), (*), cos, sin, sqrt, min, max, (<), (<>), pi, atan2, (==), (>), show, (&&), otherwise, error)

import Graphics.Implicit.Definitions
( SymbolicObj2(Square, Circle, Polygon, Rotate2, Transform2, Shared2),
( SymbolicObj2(Square, Circle, Polygon, Rotate2, Transform, Shared2),
SharedObj(IntersectR, Complement, UnionR, DifferenceR),
Box2,
ℝ2,
Expand All @@ -34,7 +34,7 @@ getBox2 (Polygon points) = pointsBox points
getBox2 (Rotate2 θ symbObj) =
let rotate (V2 x y) = V2 (x*cos θ - y*sin θ) (x*sin θ + y*cos θ)
in pointsBox $ fmap rotate $ corners $ getBox2 symbObj
getBox2 (Transform2 m symbObj) =
getBox2 (Transform m symbObj) =
let box = getBox2 symbObj
augment (V2 x y) = V3 x y 1
normalize (V3 x y w) = V2 (x/w) (y/w)
Expand Down
6 changes: 3 additions & 3 deletions Graphics/Implicit/ObjectUtil/GetImplicit2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Graphics.Implicit.ObjectUtil.GetImplicit2 (getImplicit2) where
import Prelude(cycle, (/=), uncurry, fst, Eq, zip, drop, abs, (-), (/), sqrt, (*), (+), length, fmap, (<=), (&&), (>=), (||), odd, ($), (>), filter, (<), minimum, (.), sin, cos)

import Graphics.Implicit.Definitions
( objectRounding, ObjectContext, SymbolicObj2(Square, Circle, Polygon, Rotate2, Transform2, Shared2), SharedObj (Empty), Obj2, ℝ2, , hasZeroComponent )
( objectRounding, ObjectContext, SymbolicObj2(Square, Circle, Polygon, Rotate2, Transform, Shared2), SharedObj (Empty), Obj2, ℝ2, , hasZeroComponent )

import Graphics.Implicit.MathUtil
( distFromLineSeg, rmaximum )
Expand Down Expand Up @@ -72,13 +72,13 @@ getImplicit2 ctx (Rotate2 θ symbObj) =
obj $ V2 (x*cos θ + y*sin θ) (y*cos θ - x*sin θ)
-- ignore if zeroes, TODO(srk): produce warning
-- TODO(srk): produce warning and ignore if we get a non-invertible matrix
getImplicit2 ctx (Transform2
getImplicit2 ctx (Transform
(V3 (V3 x _ _)
(V3 _ y _)
(V3 _ _ _)
)
symbObj) | hasZeroComponent (V2 x y) = getImplicit2 ctx symbObj
getImplicit2 ctx (Transform2 m symbObj) =
getImplicit2 ctx (Transform m symbObj) =
\vin ->
let
obj = getImplicit2 ctx symbObj
Expand Down
4 changes: 2 additions & 2 deletions Graphics/Implicit/Primitives.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import Graphics.Implicit.Definitions (ObjectContext, ℝ, ℝ2, ℝ3, Box2,
Circle,
Polygon,
Rotate2,
Transform2,
Transform,
Shared2
),
SymbolicObj3(
Expand Down Expand Up @@ -484,7 +484,7 @@ transform
:: M33
-> SymbolicObj2
-> SymbolicObj2
transform = Transform2
transform = Transform

-- | Attempt to pack multiple 2D objects into a fixed area.
pack2
Expand Down

0 comments on commit 3327cf4

Please sign in to comment.