From 3327cf44b9b0329ca04f8b91a4c56a8818ce2d5c Mon Sep 17 00:00:00 2001 From: Richard Marko Date: Wed, 1 Nov 2023 17:02:49 +0100 Subject: [PATCH] Transform2 -> Transform so it is aligned with Rotate, Rotate3 naming --- Graphics/Implicit/Definitions.hs | 6 +++--- Graphics/Implicit/Export/SymbolicFormats.hs | 4 ++-- Graphics/Implicit/ObjectUtil/GetBox2.hs | 4 ++-- Graphics/Implicit/ObjectUtil/GetImplicit2.hs | 6 +++--- Graphics/Implicit/Primitives.hs | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Graphics/Implicit/Definitions.hs b/Graphics/Implicit/Definitions.hs index 3398f4e1..5762b1da 100644 --- a/Graphics/Implicit/Definitions.hs +++ b/Graphics/Implicit/Definitions.hs @@ -50,7 +50,7 @@ module Graphics.Implicit.Definitions ( Circle, Polygon, Rotate2, - Transform2, + Transform, Shared2), SymbolicObj3( Cube, @@ -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) @@ -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'. diff --git a/Graphics/Implicit/Export/SymbolicFormats.hs b/Graphics/Implicit/Export/SymbolicFormats.hs index 811988fd..334aabc3 100644 --- a/Graphics/Implicit/Export/SymbolicFormats.hs +++ b/Graphics/Implicit/Export/SymbolicFormats.hs @@ -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) @@ -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) diff --git a/Graphics/Implicit/ObjectUtil/GetBox2.hs b/Graphics/Implicit/ObjectUtil/GetBox2.hs index a86c5459..c7c07068 100644 --- a/Graphics/Implicit/ObjectUtil/GetBox2.hs +++ b/Graphics/Implicit/ObjectUtil/GetBox2.hs @@ -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, @@ -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) diff --git a/Graphics/Implicit/ObjectUtil/GetImplicit2.hs b/Graphics/Implicit/ObjectUtil/GetImplicit2.hs index ecbb6e70..fa51543d 100644 --- a/Graphics/Implicit/ObjectUtil/GetImplicit2.hs +++ b/Graphics/Implicit/ObjectUtil/GetImplicit2.hs @@ -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 ) @@ -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 diff --git a/Graphics/Implicit/Primitives.hs b/Graphics/Implicit/Primitives.hs index f5ab3f1a..1b2825fa 100644 --- a/Graphics/Implicit/Primitives.hs +++ b/Graphics/Implicit/Primitives.hs @@ -77,7 +77,7 @@ import Graphics.Implicit.Definitions (ObjectContext, ℝ, ℝ2, ℝ3, Box2, Circle, Polygon, Rotate2, - Transform2, + Transform, Shared2 ), SymbolicObj3( @@ -484,7 +484,7 @@ transform :: M33 ℝ -> SymbolicObj2 -> SymbolicObj2 -transform = Transform2 +transform = Transform -- | Attempt to pack multiple 2D objects into a fixed area. pack2