1 Replies - 385 Views - Last Post: 18 April 2013 - 03:27 AM Rate Topic: -----

#1 Catfish1783  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • 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?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1