# Complex Polygon Area (java +constructor)

Page 1 of 1

## 1 Replies - 709 Views - Last Post: 18 April 2013 - 03:27 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=318831&amp;s=7727d958fc92fb9671d07ba965bab4ac&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Catfish1783

Reputation: 0
• Posts: 1
• Joined: 17-April 13

# Complex Polygon Area (java +constructor)

Posted 17 April 2013 - 08:48 PM

cloneList = Point[] (series of points put into constructor)
I have tried so many different times to fix this formula, but am coming up wanting. The formula was found on
http://en.wikipedia....hoelace_formula
index(i) is a point which has both x and y values.
The values in the cloneList are taken into a constructor (Point[]....)

```    public double getArea() {
double area = 0;

for (int i = 0; i < cloneList.length-1; i++){

area += cloneList[i].getX()*cloneList[i+1].getY() - cloneList[i+1].getX()+cloneList[i].getY();

}

area = area/2;
//System.out.println(Math.abs(area));
return Math.abs(area);
}

```

Sorry about posting the code incorrectly, I do not know how to edit post.

This post has been edited by macosxnerd101: 17 April 2013 - 09:10 PM
Reason for edit:: Please use code tags

Is This A Good Question/Topic? 0

## Replies To: Complex Polygon Area (java +constructor)

### #2 GregBrannon

• D.I.C Lover

Reputation: 2250
• Posts: 5,340
• Joined: 10-September 10

## Re: Complex Polygon Area (java +constructor)

Posted 18 April 2013 - 03:27 AM

Your question isn't clear. I don't see a constructor or a class that should have one, and I'm not sure what you'd do with it if you had it. Can you copy/paste the assignment so that we can figure out what you're trying to do?