Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 384059

Summary: [GEF4] Point.getCentroid(Point...) returns wrong centroid
Product: [Tools] GEF Reporter: Matthias Wienand <matthias.wienand>
Component: GEF GeometryAssignee: Matthias Wienand <matthias.wienand>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: matthias.wienand, nyssen
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Fixes the getCentroid() bug none

Description Matthias Wienand CLA 2012-07-02 11:37:33 EDT
Build Identifier: 

The Point.getCentroid(Point...) method returns the wrong centroid for almost all input point lists, because of an error in the computation. Instead of including the closing segment of the given point list in the calculation, the segment before the closing segment is regarded twice. Moreover, when the calculation is repeated for that segment, the y-coordinates are not correctly computed.

A patch will be provided by me as an attachment.

Reproducible: Always
Comment 1 Matthias Wienand CLA 2012-07-02 11:57:31 EDT
Created attachment 218173 [details]
Fixes the getCentroid() bug

This patch corrects the Point.getCentroid() calculations for the closing segment.
Comment 2 Matthias Wienand CLA 2012-07-19 05:29:33 EDT
The computation of the centroid is based on assuming that the points are forming a polygon of constant density. The x and y coordinates are iteratively computed for each segment of that polygon. A typo in the computation of the coordiante values for the closing segment led to false values there. Fixed that computation. Pushed changes to master. Resolving as FIXED.