# Geomerative: intersection not accurate

**URL:** <https://discourse.processing.org/t/geomerative-intersection-not-accurate/27210>\
**Category:** Processing\
**Created:** [January 19, 2021, 9:18pm UTC](https://discourse.processing.org/t/geomerative-intersection-not-accurate/27210 "2021-01-19T21:18:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robottini](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@robottini](https://discourse.processing.org/u/robottini)\
**Post date:** [January 19, 2021, 9:18pm UTC](https://discourse.processing.org/t/geomerative-intersection-not-accurate/27210/1 "2021-01-19T21:18:18Z")

</div>

I draw a simple intersection between two rectangles but the result is not accurate.  
The simple code is:

```auto
import geomerative.*;

void setup() 
{
  size(600, 400); 
  smooth();
  background(255);
  noFill();
  RG.init(this);
  strokeWeight(4);
  RShape R = RShape.createRectangle(100, 50, 100, 100);
  RShape S = RShape.createRectangle(130, 70, 100, 100);
  RShape T = S.intersection(R);
  S=S.diff(T);
  stroke(0,255,0);
  S.draw();
  stroke(255,0,0);
  R.draw();
}

void draw() {
}

```

The result is this:  
 ![immagine_2021-01-19_221801](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a145d08b53f5b07b08ee652f26b4c7a49e9215c4.png)

Why??

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [January 20, 2021, 10:40am UTC](https://discourse.processing.org/t/geomerative-intersection-not-accurate/27210/2 "2021-01-20T10:40:54Z")

</div>

I’m not sure why, depending on your requirements you might want to try toxiclibs:-

```java
import toxi.geom.*;
import toxi.processing.*;
import java.util.List;

ToxiclibsSupport gfx;

void setup() {
  size(600, 400); 
  smooth();
  background(255);
  noFill();
  strokeWeight(4);
  gfx = new ToxiclibsSupport(this);
  BooleanShapeBuilder builder = new BooleanShapeBuilder(
  BooleanShapeBuilder.Type.UNION);
  stroke(255, 0, 0);
  builder.addShape(new Rect(100, 50, 100, 100));
  stroke(255, 255, 0);
  builder.addShape(new Rect(130, 70, 100, 100));  
  List<Polygon2D> polies = builder.computeShapes();
  for (Polygon2D p : polies) {
    gfx.polygon2D(p);
  }
}

```

![boolean](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e4eb80147f7dd729e04dcb3d1303b73599e2f181.png)
