Copperbox revision 874.
I've made ellipse a drawing primitive alongside path and label. This is for efficiency reasons. Circles can be simulated with Bezier curves but it takes 8 sections to get a reasonable approximation.
Adding arc to the primitive path type (with curve and line segment) would follow how PostScript works but it would make affine transformations on paths very difficult. Similarly finding the bounding box of a path would also be difficult.
Saturday, October 31, 2009
Friday, October 30, 2009
More golf...
Update - I submitted it after all, and as a message to self, I really should write emails for public distribution in a separate editor and proof read them properly before pressing send.
Old post begins...
Currently on haskell-beginners there's a thread 'list monad question' with more golf practice. I'd go further than the current pointfree version, but decided not to submit after typing it up. I'm not sure of the merits of posting incomprehensible code on a beginners list.
Old post begins...
Currently on haskell-beginners there's a thread 'list monad question' with more golf practice. I'd go further than the current pointfree version, but decided not to submit after typing it up. I'm not sure of the merits of posting incomprehensible code on a beginners list.
-- combinations :: Int -> [a] -> [[a]]
-- combinations = (foldr ((. (. (:)) . flip map) . (>>=)) [[]] .) . replicate
-- The pointfree version can be golfed even further if you consider
-- some useful combinators not found in the standard libraries
combinations :: Int -> [a] -> [[a]]
combinations = foldr (<:>) [[]] `oo` replicate
-- | Applicative 'cons'.
(<:>) :: Applicative f => f a -> f [a] -> f [a]
(<:>) a b = (:) <$> a <*> b
-- | Compose an arity 1 function with an arity 2 function.
--
-- I call this combinator 'specs' (aka glasses) due to its infix
-- appearance `oo`
oo :: (c -> d) -> (a -> b -> c) -> a -> b -> d
oo f g = (f .) . g
Thursday, October 29, 2009
Wumpus
Copperbox revision 870.
Changing the frame is working again. I've decided it make a lot more sense to communicate a change of frame immediately to PostScript (as a concat operation) as it is encountered during the top-down traversal. Trying to do the translations on the Haskell side was too flaky. It also generated more obscure PostScript, being much harder to map a sub-picture in the Haskell code to a sub-picture in the PostScript code.
Changing the frame is working again. I've decided it make a lot more sense to communicate a change of frame immediately to PostScript (as a concat operation) as it is encountered during the top-down traversal. Trying to do the translations on the Haskell side was too flaky. It also generated more obscure PostScript, being much harder to map a sub-picture in the Haskell code to a sub-picture in the PostScript code.
Wumpus
Copperbox revision 869.
I've added substantial haddock docs describing the matrix representations used in Wumpus - Matrix3'3 in the core geometry module and CTM in the PostScript module.
For the record - Wumpus represents an affine frame as columns in a matrix whereas PostScript represents the frame as rows.
I've added substantial haddock docs describing the matrix representations used in Wumpus - Matrix3'3 in the core geometry module and CTM in the PostScript module.
For the record - Wumpus represents an affine frame as columns in a matrix whereas PostScript represents the frame as rows.
Wumpus
Copperbox revision 868.
I've change the order of parameters inside the Frame2 data type so they match the order of concatenation when constructing a matrix from a frame - i.e. the parameters are now (e0, e1, origin), rather than (origin, e0, e1).
I've also changed the matrix code to be more illustrative of the fact that I'm storing matrices in row-major form.
... I still have problems with calculating the correct CTM to send to PostScript though.
I've change the order of parameters inside the Frame2 data type so they match the order of concatenation when constructing a matrix from a frame - i.e. the parameters are now (e0, e1, origin), rather than (origin, e0, e1).
I've also changed the matrix code to be more illustrative of the fact that I'm storing matrices in row-major form.
... I still have problems with calculating the correct CTM to send to PostScript though.
Wumpus
Copperbox revision 867.
I've made CTM a concrete datatype - this is so I can define the conversion from frames and 3x3 matrices to the CTM in one place, getting the presentation in the right order (column-major or row-major). That said I've a bit of research to do to verify which order the PostScript CTM actually is.
I've made CTM a concrete datatype - this is so I can define the conversion from frames and 3x3 matrices to the CTM in one place, getting the presentation in the right order (column-major or row-major). That said I've a bit of research to do to verify which order the PostScript CTM actually is.
Wednesday, October 28, 2009
Wumpus
Copperbox revision 865.
Affine transformations are currently working for paths as they are temporarily using pointInFrame and transforming each point before sending it to PostScript (as opposed to sending the calculated current translation matrix to PostScript with a concat command).
This does mean that labels are not transformed properly - I have no access to their paths/control points so cannot pre-translate them. They need to be evaluated in PostScript within the context of a concat command that has set the current translation matrix.
Affine transformations are currently working for paths as they are temporarily using pointInFrame and transforming each point before sending it to PostScript (as opposed to sending the calculated current translation matrix to PostScript with a concat command).
This does mean that labels are not transformed properly - I have no access to their paths/control points so cannot pre-translate them. They need to be evaluated in PostScript within the context of a concat command that has set the current translation matrix.
Wumpus
Copperbox revision 864.
I'm having trouble with affine frames again. I revised the rendering of the picture type so that instead of composing a function that represents a point in the current frame (and with function composition I had nested frames) I've gone to a first order representation and consider the affine frame as a transformation matrix. Unfortunately it isn't working correctly - rotations for instance go in the wrong direction. Time to check my geometry again...
I'm having trouble with affine frames again. I revised the rendering of the picture type so that instead of composing a function that represents a point in the current frame (and with function composition I had nested frames) I've gone to a first order representation and consider the affine frame as a transformation matrix. Unfortunately it isn't working correctly - rotations for instance go in the wrong direction. Time to check my geometry again...
Tuesday, October 27, 2009
Monday, October 26, 2009
Wumpus
Copperbox revision 862.
Initial work on adding grids of nodes/labels. The matrix command is one of TikZ's most useful operations and it is something I'd want to provide an analogue of for Wumpus. It builds a grid of nodes that are addressable. Nodes can obviously have labels, and by being addressable they can be easily connected together with lines or arrows.
Initial work on adding grids of nodes/labels. The matrix command is one of TikZ's most useful operations and it is something I'd want to provide an analogue of for Wumpus. It builds a grid of nodes that are addressable. Nodes can obviously have labels, and by being addressable they can be easily connected together with lines or arrows.
Sunday, October 25, 2009
Wumpus-0.2
Copperbox revision 860.
I've made a release library of Wumpus - the main modules Core.Geometry, Core.Picture and Core.PostScript have taken shape and seem to be working. I haven't done any documenting or tidying for Haddock, but making a release now at least fixes the general functionality that these modules should have - extensions should go into other modules. Indeed, I moved the (currently rather superficial) polygon code out of Core.Picture into a new module for this release.
There was no Wumpus-0.1 release - the first version of Wumpus had more features than Wumpus-2.0 but it collapsed when I tried to make the picture type parametric over coordinate type to handle polar coordinates and I never packaged a release from it.
Copperbox revision 861
Adding a release tar.gz of fun-extras as Wumpus-0.2 depends on it.
I've made a release library of Wumpus - the main modules Core.Geometry, Core.Picture and Core.PostScript have taken shape and seem to be working. I haven't done any documenting or tidying for Haddock, but making a release now at least fixes the general functionality that these modules should have - extensions should go into other modules. Indeed, I moved the (currently rather superficial) polygon code out of Core.Picture into a new module for this release.
There was no Wumpus-0.1 release - the first version of Wumpus had more features than Wumpus-2.0 but it collapsed when I tried to make the picture type parametric over coordinate type to handle polar coordinates and I never packaged a release from it.
Copperbox revision 861
Adding a release tar.gz of fun-extras as Wumpus-0.2 depends on it.
Saturday, October 24, 2009
Wumpus
Copperbox revision 858.
I've changed the font attribute so that an update from Wumpus changes both font name and size. GhostScript (if not PostScript generally) seems unhappy processing a change of either rather than both.
Copperbox revision 859 - removed Fun.hs from Wumpus.Core. This file should have been deleted yesterday.
I've changed the font attribute so that an update from Wumpus changes both font name and size. GhostScript (if not PostScript generally) seems unhappy processing a change of either rather than both.
Copperbox revision 859 - removed Fun.hs from Wumpus.Core. This file should have been deleted yesterday.
Wumpus
Copperbox revision 855.
I've added graphics state changes to the label and path constructors of the Picture type, so now pictures can be coloured, have changes of line width etc. That said, I'm sure what a reasonable way of setting these attributes is going to be. Currently there is a simple prototype hack to change font properties but that isn't very good. As the picture type is really a tree, maybe I'll have to use downwards inheritance as per attribute grammars.
I've added graphics state changes to the label and path constructors of the Picture type, so now pictures can be coloured, have changes of line width etc. That said, I'm sure what a reasonable way of setting these attributes is going to be. Currently there is a simple prototype hack to change font properties but that isn't very good. As the picture type is really a tree, maybe I'll have to use downwards inheritance as per attribute grammars.
Wumpus
Copperbox revision 854.
First round of changes towards adding graphics state operations (colour change, line width change etc.) to the revised Wumpus.
The original Wumpus had a rather confused evaluation mechanism that attempted, via a reader monad, to track differences between the local graphics state and the world state during rendering and only transmit changes to PostScript. The new version has changed the environment data types of the original into 'update commands' that will instead be part of the syntax of pictures, paths and labels.
First round of changes towards adding graphics state operations (colour change, line width change etc.) to the revised Wumpus.
The original Wumpus had a rather confused evaluation mechanism that attempted, via a reader monad, to track differences between the local graphics state and the world state during rendering and only transmit changes to PostScript. The new version has changed the environment data types of the original into 'update commands' that will instead be part of the syntax of pictures, paths and labels.
Friday, October 23, 2009
Wumpus
Copperbox revisions 849, 850, 851 & 852.
I've changed Wumpus, replacing the out-of-date original version with the code developed as Wumpus-alt. I rather messed up the commit as I should have run svn cleanup on my local copy, hence the three commits. Also I missed deleting Wumpus.Drawing.
I've changed Wumpus, replacing the out-of-date original version with the code developed as Wumpus-alt. I rather messed up the commit as I should have run svn cleanup on my local copy, hence the three commits. Also I missed deleting Wumpus.Drawing.
Thursday, October 22, 2009
Wumpus
Copperbox revision 846.
An attempt to implement the full set of affine transformations on pictures - rotates, scales, translations (not yet shears!). There is a bug somewhere - pictures are displaced when they shouldn't be - possibly I am changing the origin in the affine frame when I shouldn't.
There's also a problem with the type classes - incoherent / overlapping instances - which needs fixing.
An attempt to implement the full set of affine transformations on pictures - rotates, scales, translations (not yet shears!). There is a bug somewhere - pictures are displaced when they shouldn't be - possibly I am changing the origin in the affine frame when I shouldn't.
There's also a problem with the type classes - incoherent / overlapping instances - which needs fixing.
Wednesday, October 21, 2009
fun-extras
Copperbox revision 839.
I've renamed pair-extras fun-extras so it can accommodate other functions that don't operate on pairs. It seems like the best place for the functions I commonly define for each project e.g. the specs.
I've renamed pair-extras fun-extras so it can accommodate other functions that don't operate on pairs. It seems like the best place for the functions I commonly define for each project e.g. the specs.
Tuesday, October 20, 2009
pair-extras
Copperbox revision 838.
A cabalized library for the useful functions on pairs prod and fork, plus a few less useful functions.
A cabalized library for the useful functions on pairs prod and fork, plus a few less useful functions.
Monday, October 19, 2009
Sunday, October 18, 2009
Wumpus
Copperbox revision 836.
I've added a bounding box module to Wumpus-alt. It replicates the functionality of Wumpus.Core.BoundingBox, but removes the type classes. With reflection the type classes in Core.BoundingBox weren't right, but I don't want to change the old Wumpus code at the moment, when I'll looking to replace it altogether.
I've added a bounding box module to Wumpus-alt. It replicates the functionality of Wumpus.Core.BoundingBox, but removes the type classes. With reflection the type classes in Core.BoundingBox weren't right, but I don't want to change the old Wumpus code at the moment, when I'll looking to replace it altogether.
metric-space
Copperbox revision 835.
I've added a new library to represent metric spaces - i.e some set (Haskell Type) with an operation distance (d :: A -> A -> Real), though I've generalized the result from Real to an associated type.
I think I'll spare Hackage, at least until I have some noteworthy derived functions. My last contribution to Hackage - groupoid - was somewhat tardy.
I've added a new library to represent metric spaces - i.e some set (Haskell Type) with an operation distance (d :: A -> A -> Real), though I've generalized the result from Real to an associated type.
I think I'll spare Hackage, at least until I have some noteworthy derived functions. My last contribution to Hackage - groupoid - was somewhat tardy.
Saturday, October 17, 2009
Wumpus
Copperbox revision 834.
I've chosen the polygon-with-points implementation of pictures as the best version of the current round, so I've deleted the others. As this representation carries around affine frames to model displacement of one picture within a composite picture, it can also use the affine frames for transformations - i.e. transform the frame rather than the points within it. One of the examples uses this to rotate a line of squares.
I've chosen the polygon-with-points implementation of pictures as the best version of the current round, so I've deleted the others. As this representation carries around affine frames to model displacement of one picture within a composite picture, it can also use the affine frames for transformations - i.e. transform the frame rather than the points within it. One of the examples uses this to rotate a line of squares.
Friday, October 16, 2009
Wumpus
Copperbox revision 832.
Another version of the picture type - this time polygons are lists of points rather than lists of vectors. Naturally, affine transformations (here rotation) seem more natural on points, so this looks like the best of the three experiments.
Another version of the picture type - this time polygons are lists of points rather than lists of vectors. Naturally, affine transformations (here rotation) seem more natural on points, so this looks like the best of the three experiments.
Wumpus
Copperbox revision 831.
I've added rotation to the current toy picture type. It's not satisfactory, for affine transformations I'd be happier working on points rather than vectors - all the literature I've read on affine spaces uses points to illustrate the affine transformations rather than vectors.
I've also worked through a version of the (vector) polygon and picture types that use displacement from some common origin rather than displacement from the last point in the vertex list. Neither seem to make the affine transformations more tangible.
I've added rotation to the current toy picture type. It's not satisfactory, for affine transformations I'd be happier working on points rather than vectors - all the literature I've read on affine spaces uses points to illustrate the affine transformations rather than vectors.
I've also worked through a version of the (vector) polygon and picture types that use displacement from some common origin rather than displacement from the last point in the vertex list. Neither seem to make the affine transformations more tangible.
Wumpus
Copperbox revision 830.
I've extracted the core types and operations from Wumpus main into a geometry module for Wumpus-alt - points, vectors, matrices, affine transformations etc. Yesterdays experiment with Wumpus-alt suggests I can build pictures, but I need to be able to transform them as well.
I've extracted the core types and operations from Wumpus main into a geometry module for Wumpus-alt - points, vectors, matrices, affine transformations etc. Yesterdays experiment with Wumpus-alt suggests I can build pictures, but I need to be able to transform them as well.
Thursday, October 15, 2009
Wumpus
Copperbox revision 829.
I've added a toy implementation of a new approach to vector drawing with a new the picture type. Currently it just has one geometric primitive (polygon) and one composition operator (<>) horizontal concatenation.
Its derived from Peter Henderson's original functional approach to pictures in that the primitives (polygons) are represented solely as vectors (no points not even an origin). Polygons are become pictures inside a binary tree which tracks the bounding rectangle (i.e. the coordinate free measures of width and height rather than alternate corners which would mean points and induce coordinates) of the child nodes and their displacement (again a vector). The only appearance of points so far is supplying the origin to the drawing / evaluation procedure. Adding other composition operators should be easy, but it remains to be seen whether this approach handles the affine transformations convincingly (scale, rotate, translate etc.).
I've added a toy implementation of a new approach to vector drawing with a new the picture type. Currently it just has one geometric primitive (polygon) and one composition operator (<>) horizontal concatenation.
Its derived from Peter Henderson's original functional approach to pictures in that the primitives (polygons) are represented solely as vectors (no points not even an origin). Polygons are become pictures inside a binary tree which tracks the bounding rectangle (i.e. the coordinate free measures of width and height rather than alternate corners which would mean points and induce coordinates) of the child nodes and their displacement (again a vector). The only appearance of points so far is supplying the origin to the drawing / evaluation procedure. Adding other composition operators should be easy, but it remains to be seen whether this approach handles the affine transformations convincingly (scale, rotate, translate etc.).
Monday, October 12, 2009
Sunday, October 11, 2009
MT
Copperbox revision 827.
I've reached a dead end with the current incarnation of Bala. The current examples do an adequate job of generating LilyPond, but they are poor models of music - the LilyPond output is shorter, more concise than the program code to generate it. So I'm going to work on something else - MT. I don't plan to make MT into a usable library, but keep it as a set of sketches translating some pieces of (mathematical) music theory into code. The first sketches are modules implementing the T/I (translation - inversion) and PLR groups.
I've reached a dead end with the current incarnation of Bala. The current examples do an adequate job of generating LilyPond, but they are poor models of music - the LilyPond output is shorter, more concise than the program code to generate it. So I'm going to work on something else - MT. I don't plan to make MT into a usable library, but keep it as a set of sketches translating some pieces of (mathematical) music theory into code. The first sketches are modules implementing the T/I (translation - inversion) and PLR groups.
Thursday, October 8, 2009
Bala, JoinList
Copperbox revision 826.
Updates to Bala to use a new beat pattern notation. Added snoc and cons to joinlist.
Updates to Bala to use a new beat pattern notation. Added snoc and cons to joinlist.
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2009
(651)
-
▼
October
(45)
- Wumpus
- Wumpus
- Wumpus
- More golf...
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus-0.2
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- fun-extras
- pair-extras
- Wumpus
- Wumpus
- metric-space
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- Wumpus
- MT
- MT
- Bala, JoinList
-
▼
October
(45)
About Me
- Stephen Tetley
- Disambiguating biog as there are a few Stephen Tetley's in the world. I'm neither a cage fighter or yachtsman. I studied Fine Art in the nineties (foundation Bradford 1992, degree Cheltenham 1992 - 95) then Computing part-time at Leeds Met graduating in 2003. I'm the Stephen Tetley on Haskell Cafe and Stackoverflow.