I am looking for a language, or package in an existing language, that is good for specifying and drawing geometric diagrams.
For example, I would like to draw a hexagonal grid, with its dual triangular grid superimposed on it. Now, I could sit down, put some elbow grease in to work out the trig by hand and come up with some Postscript or SVG that will display such a grid. But I'm wondering if there are any languages or packages that will help me out with this; that make it easy to specify a hexagonal grid, find the centers, and draw a triangular grid over it.
What's the easiest way to do this?
Code examples, showing how easy it is to create such geometrically specified diagrams, would be appreciated. In particular, please demonstrate how easy it is to draw a hexagonal grid; while I could do that in any language by drawing all the lines by hand, I'm interested in languages or packages which make that sort of geometric diagram easy and clear.
Bounty
Since this question has been answered, but the answer is more complicated than I would prefer, I will offer a bounty to the person who can produce the shortest and simplest code, in any pre-existing language and using any pre-existing package, for drawing a hexagonal grid with its dual triangular grid superimposed on top of it; the dual triangular grid is the triangular grid you get if you connect the center of each hexagon to the center of each of the neighboring hexagons. See Antal S-Z's answer for example; his example does the job, but I was looking for a language that would make this problem easier. You may either produce a grid which is roughly rectangular, as in his example (the odd rows aligned, and the even rows aligned), or one in the style of a Hex board (every row shifted right by a half hex, forming a rhombus); both are acceptable.
The program may take input either in the form of a function or subroutine in the language which takes a number of rows and number of columns, or take input passed in on the command line indicating rows and columns. It should produce output in any standard and common graphics format, such as Postscript, PDF, SVG, PNG or PNM; the output should contain the hex grid and triangular grid, in some contrasting color, line weight, or line style to make the diagram clear.
I'm looking for the shortest and simplest answer, as a way to find the language or package that is best for describing these sorts of diagrams; the bounty will go to the shortest program that solves the problem. This is not code golf, so I won't be counting by character count or lines of code. If there is not an obvious shortest answer, then I will measure based on token count; how many tokens in your language does it take to express this problem? Thus, readable constants and variable names, using library functions, comments, whitespace and the like are all fine, as they don't increase the token count. It's still not a perfect metric (Lisps will have a few more tokens as you need more parentheses to delimit your arithmetic expressions, and I'm sure that if you over-optimize for this metric you can still produce some unreadable code), but it's a rough guide to how complex your code is.
So, the challenge, for the bounty, is to create the shortest program that draws a hex grid with its superimposed triangular grid. Please post your code, links to the language and any packages you've used, a rough token count if possible, and an example output image. The existing answer is the bar you'll have to beat to qualify; it does the job, but I would like something shorter and simpler.
In order to give me enough time to look at the answers and award the bounty, all answers must be submitted at least 24 hours before the bounty deadline. I may or may not consider any answers submitted less than 24 hours before the deadline.