Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

java objects , total surface area

$
0
0
hello , im writing a program that outputs a picture of a teapot using a bunch of triangles. im stuck on one part of my program were i find the total surface area by summing the areas of the triangles. but im a little lost. the program is pretty lengthy , so ill post the 2 parts that matter. first of all , i got the area of the triangles down. and the values are stored in area. im having trouble getting the total surface area. now im just supposed to sum them all up by looping through each triangle. so im guessing we use a for loop , but im not sure what im looping through.

this is the method that gets the area of each triangle
double computeArea() {
		
		double area = 0.0;
		
		D3V uu = D3V.sub(points[0].position, points[2].position);
		D3V vv = D3V.sub(points[1].position, points[2].position);
		
		area = 0.5 * Vector.length(Vector.cross(uu,vv));
		
		return area;
	}







heres my method for the surface area , im not sure about how to make the for loop , and id just be adding up every triangle in the for loop right?

double computeSurfaceArea() {
		double v = 0;
		for(int i =0; i<   ; i++){


                }
		return v;
	}



Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>