I'm hoping to use your library in a small project involving a solid polygon shaped region that scales to a max area. The geometry of it all is way over my head. From what I've read in your API, this should be possible with this lib, am I correct? I would then need to use this region to check if a point is inside or out.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Mike,
I'm not sure I understand your problem: you start from a polygon, then do you want to scale it such as its area reaches a given value (i.e. a given measure), or do want to make the input polygon large enough to fill a given rectangular region (or box) ?
In the first case, you simply need to (1) measure the area of the input polygon, (2) compute the scaling ratio, (3) create a scaling transform, and (4) apply the transform to the polygon.
Try something like:
Polygon poly = …
double area = Math.abs(poly.getArea());
double ratio = targetArea / area;
AffineTransform2D scaling = AffineTransform2D.createScaling(ratio, ratio);
Polygon2D poly2 = poly.transform(poly);
double area2 = poly.getArea(); // Should be equal to the target area
regards,
David
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks, that's pretty much exactly what I was thinking, just wasn't sure where to get the ratios. I was also hoping to use getBuffer to accomplish something similiar to this, http://imgur.com/yWxd8 Is that something your library can do? basically the buffer would just expand until it's area is roughly equal to the given area. All in all, I think your library is amazing, I looked at JTS, but it's far too complex for what I need. Your library is short sweet and to the point, yet very robust. Two thumbs up.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes, the buffer is what you expect ! However, I the buffer computation is still not very robust for some cases, so handle with care… And there is no method for computing area of a buffer shape. This should be possible, but I need to take time to implement it.
And thanks for your feedback, this is always welcome!
regards,
David
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm hoping to use your library in a small project involving a solid polygon shaped region that scales to a max area. The geometry of it all is way over my head. From what I've read in your API, this should be possible with this lib, am I correct? I would then need to use this region to check if a point is inside or out.
Hi Mike,
I'm not sure I understand your problem: you start from a polygon, then do you want to scale it such as its area reaches a given value (i.e. a given measure), or do want to make the input polygon large enough to fill a given rectangular region (or box) ?
In the first case, you simply need to (1) measure the area of the input polygon, (2) compute the scaling ratio, (3) create a scaling transform, and (4) apply the transform to the polygon.
Try something like:
Polygon poly = …
double area = Math.abs(poly.getArea());
double ratio = targetArea / area;
AffineTransform2D scaling = AffineTransform2D.createScaling(ratio, ratio);
Polygon2D poly2 = poly.transform(poly);
double area2 = poly.getArea(); // Should be equal to the target area
regards,
David
David,
Thanks, that's pretty much exactly what I was thinking, just wasn't sure where to get the ratios. I was also hoping to use getBuffer to accomplish something similiar to this, http://imgur.com/yWxd8 Is that something your library can do? basically the buffer would just expand until it's area is roughly equal to the given area. All in all, I think your library is amazing, I looked at JTS, but it's far too complex for what I need. Your library is short sweet and to the point, yet very robust. Two thumbs up.
Hi,
yes, the buffer is what you expect ! However, I the buffer computation is still not very robust for some cases, so handle with care… And there is no method for computing area of a buffer shape. This should be possible, but I need to take time to implement it.
And thanks for your feedback, this is always welcome!
regards,
David