thank you, I will definitely try your approach.
By the way, the first drawing was partially wrong, it showed the “parametric width” on the wrong side.
Here is the fixed one:
I’ll let you know, thank you
On Fri, Jul 22, 2011 at 9:28 PM, Oleksandr Huziy <guziy.sasha@...> wrote:
> I would do it as follows.
> 1. define Affine transform to the plane where your target rectangle
> has axes parallel to the coordinate axes (actually in the example I also
> made the transformed rectangle to be of width=1 and height=1, and the lower
> left corner to coinside with the origin of the coordinate system).
> 2. then using the inverse get the rectangle on original plane
> see attached file.
> 2011/7/22 Errico Demly Chirulli <echirulli@...>
>> I need to build a geometry object, it requires some complex operation
>> and I'm a bit lost in the API so I'm asking here to find if someone
>> more experienced with GT can help.
>> I start with two points.
>> I need to build a Rectangle with these two points being at the center
>> of two opposite sides.
>> So the two points define one of the two dimensions(let's call it
>> "height"), the other one (the "width") is from a known parameter.
>> Here is a bad drawing of what I need to do :
>> Thank you
>> 10 Tips for Better Web Security
>> Learn 10 ways to better secure your business today. Topics covered
>> Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
>> security Microsoft Exchange, secure Instant Messaging, and much more.
>> Geotools-gt2-users mailing list
From: Michael Bedward <michael.bedward@gm...> - 2011-07-23 03:28:07
You might also like to have a look at the very useful JTS
GeometricShapeFactory class. Here is an example based on your
// two reference points
Coordinate c0 = new Coordinate( x0, y0 );
Coordinate c1 = new Coordinate( x1, y1 );
// length of perpendicular dimension
double dist = ...
GeometricShapeFactory shapeFactory = new GeometricShapeFactory();
Coordinate centre = new Coordinate(
c0.x + (c1.x - c0.x) / 2,
c0.y + (c1.y - c0.y) / 2);
shapeFactory.setCentre( centre );
shapeFactory.setWidth( c0.distance( c1 ) );
shapeFactory.setHeight( dist );
double radians = Math.atan2( c1.y - c0.y, c1.x - c0.x );
shapeFactory.setRotation( radians );
Geometry rect = shapeFactory.createRectangle();
From: Michael Bedward <michael.bedward@gm...> - 2011-07-25 10:59:30
> Ouch, GeometricShapeFactory doesn't have a setRotation method, any alternative?
> I'm using GT 2.7.1.
The setRotation method is available in JTS version 1.12. GeoTools
2.7.1 is using JTS 1.11 but GeoTools version 8.0 uses JTS 1.12, so you
can switch your project to version 8.0-M1 or the development version
8.0-SNAPSHOT you will get that method.
Alternatively, you can build the version 2.7.1 sources locally but
change the JTS version used to 1.12 in the top pom.xml file (assuming
you use Maven to build).
Hope this helps.