... | ... | @@ -174,16 +174,14 @@ Some operations offered by ``IMesh`` require the construction of new points ``P` |
|
|
|
|
|
```java
|
|
|
var mesh = new PMesh<>((x,y) -> new VPoint(x,y));
|
|
|
mesh.toFace(new VPoint(0,0),new VPoint(1,0),
|
|
|
new VPoint(1,1),new VPoint(0,1));
|
|
|
mesh.toFace(new VPoint(0,0),new VPoint(1,0),new VPoint(1,1),new VPoint(0,1));
|
|
|
```
|
|
|
|
|
|
To use the array-based implementation instead, we only have to exchange ``PMesh`` by ``AMesh``:
|
|
|
|
|
|
```java
|
|
|
var mesh = new AMesh<>((x,y) -> new VPoint(x,y));
|
|
|
mesh.toFace(new VPoint(0,0),new VPoint(1,0),
|
|
|
new VPoint(1,1),new VPoint(0,1));
|
|
|
mesh.toFace(new VPoint(0,0),new VPoint(1,0),new VPoint(1,1),new VPoint(0,1));
|
|
|
```
|
|
|
|
|
|
#### Result
|
... | ... | @@ -377,17 +375,14 @@ Random random = new Random(0); |
|
|
int width = 10;
|
|
|
int height = 10;
|
|
|
int numberOfPoints = 100;
|
|
|
var supply = () -> new VPoint(
|
|
|
random.nextDouble()*width,
|
|
|
random.nextDouble()*height);
|
|
|
var supply = () -> new VPoint(random.nextDouble()*width,random.nextDouble()*height);
|
|
|
Stream<VPoint> randomPoints = Stream.generate(supply);
|
|
|
List<VPoint> points = randomPoints
|
|
|
.limit(numberOfPoints)
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
// (2) compute the Delaunay triangulation
|
|
|
var dT = new PDelaunayTriangulator<VPoint, Double, Double>(points,
|
|
|
(x,y) -> new VPoint(x,y));
|
|
|
var dT = new PDelaunayTriangulator<VPoint, Double, Double>(points,(x,y) -> new VPoint(x,y));
|
|
|
var triangulation = dT.generate();
|
|
|
```
|
|
|
|
... | ... | |