sgillies/shapely — pull request #34 by mwtoews (2012-11-03 03:16:03+00:00)
Title: Transform functions: affine, rotate, scale, skew and translate

The initial functionality to transform has been implemented:
* `affine` : provides basic affine transform on on 2D or 3D geometries
* `rotate`: rotate a geometry on a 2D map plane (normal to Z-axis)
* `scale`: scale a geometry
* `skew`: skew or shear a geometry on a 2D map plane (normal to Z-axis)
* `translate`: translate or shift a geometry

The functions `rotate`, `scale` and `skew` use an `origin` parameter to define a point of origin (also called an anchor point), where the default `None` uses the centroid of the input geometry.

The functions `rotate` and `skew` have `use_degrees=True` by default for the input angle(s), but can be set `False` for native angle(s) in radians.

Currently I have this functionality implemented in `shapely/algorithms/transform.py`, but I'm not sure if this is the ideal place. Please suggest if there is a better location.

This pull request is incomplete, as it lacks documentation, examples and test cases. However, I'll finish these after any discussion. I'd like to have some review of the functionality, terminology and particularly the mathematical accuracy. Much of the math is described in the code help.

Here are some examples of what you can do:
```python
from shapely.wkt import loads
from shapely.geometry import Point
from shapely.algorithms import transform

help(transform)

ls = loads('LINESTRING(240 400, 240 300, 300 300)')

transform.rotate(ls, 90).wkt
transform.rotate(ls, 180).wkt
transform.scale(ls, -1).wkt
transform.skew(ls, 10, 20, origin=Point(ls.coords[1])).wkt
transform.translate(ls, 10, 20).wkt
```