# PGS: problem invoking centroid()

**URL:** <https://discourse.processing.org/t/pgs-problem-invoking-centroid/46030>\
**Category:** Libraries\
**Created:** [March 19, 2025, 9:46am UTC](https://discourse.processing.org/t/pgs-problem-invoking-centroid/46030 "2025-03-19T09:46:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eamoex](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@Eamoex](https://discourse.processing.org/u/Eamoex)\
**Post date:** [March 19, 2025, 9:46am UTC](https://discourse.processing.org/t/pgs-problem-invoking-centroid/46030/1 "2025-03-19T09:46:11Z")

</div>

Hi, coming back to Processing after a long while; just dicovered the amazing PGS library. Problem: how do I make Processing see method `centroid()`?

I have included line `import micycle.pgs.*;`, but my instruction to get a vector `PVector cntr = centroid(child);` is not recognized. Processing complains about the method not existing.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [March 19, 2025, 12:27pm UTC](https://discourse.processing.org/t/pgs-problem-invoking-centroid/46030/2 "2025-03-19T12:27:17Z")

</div>

Hi @Eamoex and welcome back to the forum!

Could you share a minimal sketch showing the error?

Pinging @micycle too 👀

---

<div class="post-metadata">

**Author:** ![Eamoex](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@Eamoex](https://discourse.processing.org/u/Eamoex)\
**Post date:** [March 19, 2025, 12:47pm UTC](https://discourse.processing.org/t/pgs-problem-invoking-centroid/46030/3 "2025-03-19T12:47:54Z")

</div>

Hi sableRalph, thanks!

Sure, here: [link](http://www.emyamstein.ch/media/forums/test_sm_matrix_03.zip)

EDIT: Meh. Testing my link ends up in a rebuttal because my domain is not secure http… hope you can dl the file anyway.

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [March 19, 2025, 10:56pm UTC](https://discourse.processing.org/t/pgs-problem-invoking-centroid/46030/4 "2025-03-19T22:56:41Z")

</div>

Since this is an external library you have to _qualify_ the method with the class it comes from: `PGS_ShapePredicates.centroid()`.

However if you still want reference it in Processing-style (like you’ve been trying), you can do so using Java’s _static import_: `import static micycle.pgs.PGS_ShapePredicates.centroid;`

---

<div class="post-metadata">

**Author:** ![Eamoex](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@Eamoex](https://discourse.processing.org/u/Eamoex)\
**Post date:** [March 22, 2025, 1:59am UTC](https://discourse.processing.org/t/pgs-problem-invoking-centroid/46030/5 "2025-03-22T01:59:07Z")

</div>

Great, thanks a lot.
