polygon-clipping

library for polygon clipping

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.github.random-dwi
ArtifactId

ArtifactId

polygon-clipping
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

polygon-clipping
library for polygon clipping
Project URL

Project URL

https://github.com/random-dwi/polygonclipping
Source Code Management

Source Code Management

https://github.com/random-dwi/polygonclipping

Download polygon-clipping

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.random-dwi/polygon-clipping/ -->
<dependency>
    <groupId>com.github.random-dwi</groupId>
    <artifactId>polygon-clipping</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.random-dwi/polygon-clipping/
implementation 'com.github.random-dwi:polygon-clipping:1.0.2'
// https://jarcasting.com/artifacts/com.github.random-dwi/polygon-clipping/
implementation ("com.github.random-dwi:polygon-clipping:1.0.2")
'com.github.random-dwi:polygon-clipping:jar:1.0.2'
<dependency org="com.github.random-dwi" name="polygon-clipping" rev="1.0.2">
  <artifact name="polygon-clipping" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.random-dwi', module='polygon-clipping', version='1.0.2')
)
libraryDependencies += "com.github.random-dwi" % "polygon-clipping" % "1.0.2"
[com.github.random-dwi/polygon-clipping "1.0.2"]

Dependencies

compile (1)

Group / Artifact Type Version
org.jetbrains : annotations jar 15.0

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.20

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.9.0

Project Modules

There are no modules declared in this project.

polygon clipping

CircleCI Maven Central

Description

A library for polygon clipping written in Java. It implements the algorithm described in the paper F. Martínez, A.J. Rueda, F.R. Feito. A new algorithm for computing Boolean operations on polygons. Computers & Geosciences, 35 (2009)

Features

  • Boolean operations on polygons with double precision
  • Supports complex polygons with holes

Maven Dependency

<dependency>
    <groupId>com.github.random-dwi</groupId>
    <artifactId>polygon-clipping</artifactId>
    <version>1.0.1</version>
</dependency>

Examples

Apply boolean operation

Polygon subject = new Polygon(new File("/polygons/samples/rectangle1"));
Polygon clipping = new Polygon(new File("/polygons/samples/triangle2"));

Polygon result1 = BooleanOperation.INTERSECTION(subject, clipping);
Polygon result2 = BooleanOperation.DIFFERENCE(subject, clipping);
Polygon result3 = BooleanOperation.UNION(subject, clipping);
Polygon result4 = BooleanOperation.XOR(subject, clipping);
ORIGINAL INTERSECTION DIFFERENCE UNION XOR
Sample1 Sample1 Sample1 Sample1 Sample1

Create polygons

Simple polygon

Code
double[][] points = {{2.5,7.5}, {5.0, 5.0}, {7.5, 7.5}, {5.0, 10.0}};
Polygon p = Polygon.from(points);
Result

Simple Polygon

Polygon with holes

Code
double[][] outerContour = {{0.0,0.0}, {10.0, 0.0}, {10.0, 10.0}, {0.0, 10.0}};
double[][] hole1 = {{0.5,0.5}, {4.0, 0.5}, {2.0, 4.0}};
double[][] hole2 = {{2.5,7.5}, {5.0, 5.0}, {7.5, 7.5}, {5.0, 10.0}};

Polygon p = Polygon.from(Contour.from(outerContour), Contour.from(hole1), Contour.from(hole2));
Result

Polygon with holes

Polygon Offset

Code
Polygon polygon = new Polygon(new File("/polygons/samples/polygonwithhole"));
Polygon offset = PolygonOffset.createOffsetPolygon(polygon, 0.05);
Result
Offset=0.05 Offset=0.1 Offset=0.2
Polygon with hole offset Polygon with hole offset 1 Polygon with hole offset

Versions

Version
1.0.2
1.0.1
1.0