That sounds fine; and can be used to explain to people how to transform a mouse click on the screen; to a world coordinate etc... Jody
On 15/09/2010, at 5:32 PM, [email protected] wrote: > I thought about an example for transforming world coords to pixel coords and > the other way around. > There are 3 operations involved, mirroring the y coordinate, shifting to 0.0 > and scaling. Additionally it is a good use case for showing the benefits of > the inversion of a matrix. > > Is a nice example. What do you think ? > > Quoting Jody Garnett <[email protected]>: > >> If you are game more documentation is always welcome; I think the best >> sport would be grouped with the documentation on referencing; since that is >> where we introduce the generic MathTransform. >> You don't have to write all documentation yourself; referencing wikipedia >> and others also works. >> >> Before writing documentation you should have some goals on what you want to >> communicate; perhaps in this case it is how to scale and manipulate a >> single Geometry (to show what affine transform does); and then mention that >> it is used during rendering (so you can adjust your affine transform for >> the entire map). >> >> http://docs.codehaus.org/display/GEOTDOC/07+Referencing >> >> Jody >> >> On 14/09/2010, at 8:14 AM, [email protected] wrote: >> >>> Hi Jody, after doing my exams there is time for adding some mathematical >>> basics about Affine Transforms to the WIKI. >>> >>> 1) Do you still want me to add these concepts to the WIKI ? >>> 2) Where would be the best place ? >>> >>> Cheers >>> Christian >>> >>> Quoting Jody Garnett <[email protected]>: >>> >>>> You may wish to add some of that to the wiki page :-) >>>> >>>> I will note if you don't like math, you can just use the methods of >>>> the AffineTransform object. >>>> >>>> Jody >>>> >>>> >>>> On Thu, Aug 19, 2010 at 1:01 PM, <[email protected]> wrote: >>>>> >>>>> Some mathematical basics here. >>>>> An affine transform is a powerful mechanism to transform coordinates. >>>>> To get the new coordinates x' and y', the following calculation is done. >>>>> >>>>> [ x'] [ m00 m01 m02 ] [ x ] [ m00x + m01y + m02 ] >>>>> [ y'] = [ m10 m11 m12 ] [ y ] = [ m10x + m11y + m12 ] >>>>> [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ] >>>>> >>>>> A simple example: >>>>> if you want to shift a point 5 units on the x axis and -7 units at the >>>>> y axis, the following matrix is needed >>>>> >>>>> [ 1 0 5 ] >>>>> [ 0 1 -7 ] >>>>> [ 0 0 1 ] >>>>> >>>>> Of course, you can say this is easy, x'=x+5 and y'=y-7 would do the same. >>>>> >>>>> Another one, lets do some scaling, say factor 3 >>>>> >>>>> [ 3 0 0 ] >>>>> [ 0 3 0 ] >>>>> [ 0 0 1 ] >>>>> >>>>> This is easy too, x'=x*3 and y'=y*3 would the job. >>>>> >>>>> The power of affine transforms is that you can combine multiple >>>>> matrices into a single one, doing a set of individual transformations >>>>> within one step. There is a java method "concatenate(AffineTransform)" >>>>> for the AffineTransform class. But be careful, given 3 transformatons >>>>> A,B,C and you want to combine them in this order, you have to go from >>>>> right to left. >>>>> C concatenate B concatenate A will give you the expected result. >>>>> >>>>> A mapping from world coordinates to pixel coordinates needs some >>>>> operations but can be done within one affine transformation. >>>>> >>>>> The second powerful feature is that you can create an inverse >>>>> transform (Method createInverse), which will do the mapping in the >>>>> other direction out of the box. >>>>> >>>>> Believe me, if you are used to use AffineTransform objects, you will >>>>> use them forever. >>>>> >>>>> Hope this helps >>>>> Cheers >>>>> Christian >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> Quoting andrea antonello <[email protected]>: >>>>> >>>>>> Hi Tommaso, >>>>>> the easiest way to do a rotation for example is: >>>>>> >>>>>> Coordinate ancorPoint = ...; >>>>>> AffineTransform affineTransform = >>>>>> AffineTransform.getRotateInstance(angleRad, ancorPoint.x, >>>>>> ancorPoint.y); >>>>>> MathTransform mathTransform = new AffineTransform2D(affineTransform); >>>>>> >>>>>> Point point = ...point to rotate; >>>>>> Geometry rotatedPoint = JTS.transform(point, mathTransform); >>>>>> >>>>>> Where point can be any geometry. >>>>>> >>>>>> Does that help? >>>>>> >>>>>> Ciao >>>>>> Andrea >>>>>> >>>>>> >>>>>> On Wed, Aug 18, 2010 at 11:26 PM, tommaso <[email protected]> >>>>>> wrote: >>>>>>> Hallo List, >>>>>>> >>>>>>> I would like to perform some geometry transformations on polygons, i.e >>>>>>> rotate about a point, scale and translate. >>>>>>> >>>>>>> So I create the polygon: >>>>>>> >>>>>>> import com.vividsolutions.jts.geom.Coordinate >>>>>>> import org.geotools.geometry.jts.JTSFactoryFinder >>>>>>> import com.vividsolutions.jts.geom.GeometryFactory >>>>>>> import com.vividsolutions.jts.geom.LinearRing >>>>>>> import com.vividsolutions.jts.geom.Polygon >>>>>>> >>>>>>> GeometryFactory geometryFactory = >>>>>>> JTSFactoryFinder.getGeometryFactory( null ); >>>>>>> >>>>>>> Coordinate[] coords = [new Coordinate(0, 0), new >>>>>>> Coordinate(2, 0), >>>>>>> new Coordinate(2, 2), new Coordinate(0, 2), new Coordinate(0, 0)] >>>>>>> LinearRing ring = new LinearRing(coords, geometryFactory) >>>>>>> Polygon polygon = geometryFactory.createPolygon(ring) >>>>>>> >>>>>>> I guess I have to use AffineTransform >>>>>>> (com.vividsolutions.jts.geom.util.AffineTransformation ?) but I don't >>>>>>> know >>>>>>> exactly how. >>>>>>> A code example or a link to a tutorial were very appreciated. >>>>>>> >>>>>>> Cheers, >>>>>>> Tom >>>>>>> ------------------------------------------------------------------------------ >>>>>>> This SF.net email is sponsored by >>>>>>> >>>>>>> Make an app they can't live without >>>>>>> Enter the BlackBerry Developer Challenge >>>>>>> http://p.sf.net/sfu/RIM-dev2dev >>>>>>> _______________________________________________ >>>>>>> Geotools-gt2-users mailing list >>>>>>> [email protected] >>>>>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>>>>>> >>>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> This SF.net email is sponsored by >>>>>> >>>>>> Make an app they can't live without >>>>>> Enter the BlackBerry Developer Challenge >>>>>> http://p.sf.net/sfu/RIM-dev2dev >>>>>> _______________________________________________ >>>>>> Geotools-gt2-users mailing list >>>>>> [email protected] >>>>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>>>>> >>>>> >>>>> >>>>> >>>>> ---------------------------------------------------------------- >>>>> This message was sent using IMP, the Internet Messaging Program. >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> This SF.net email is sponsored by >>>>> >>>>> Make an app they can't live without >>>>> Enter the BlackBerry Developer Challenge >>>>> http://p.sf.net/sfu/RIM-dev2dev >>>>> _______________________________________________ >>>>> Geotools-gt2-users mailing list >>>>> [email protected] >>>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>>>> >>>> >>> >>> >>> >>> ---------------------------------------------------------------- >>> This message was sent using IMP, the Internet Messaging Program. >>> >>> >> >> > > > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
