Hello,
Im trying to write a program which is computing surface area of a 3D geometry by using Newell Methods.
Geometry data should be reading from a text file. The lines which has 3 columns point out coordinates of geometry's vertices. The lines which has 2 columns point out connectivities of edges by vertices. And other lines point out loops compositons by edges. So The text file defines the geometry. When I change the file, the geometry will change e.x: cube, rectangular prism...
I can create arrays to use in formulas of Newell Methods and I can compute the area of geometry surface by writing the data in program as hardcode.Also I can make line read from text file.But I cant create arrays and store datas from reading text file. I need to combine those.
The program is in below and attached which can calculate by hard code. I need help this to compute the area by reading from text file. Thanks for all suggestions.
import javax.swing.*;
import java.util.*;
class surfaces_area
{
public static void main(String args[])
{
double edges[][][]={
// V1 V2
{{0.0,0.0,0.0},{5.0,0.0,0.0}}, // E1
// V2 V3
{{5.0,0.0,0.0},{5.0,4.0,0.0}}, // E2
// V4 V3
{{0.0,4.0,0.0},{5.0,4.0,0.0}}, // E3
// V1 V4
{{0.0,0.0,0.0},{0.0,4.0,0.0}}, // E4
// V5 V4
{{0.0,4.0,3.0},{0.0,4.0,0.0}}, // E5
// V6 V5
{{5.0,4.0,3.0},{0.0,4.0,3.0}}, // E6
// V7 V6
{{5.0,0.0,3.0},{5.0,4.0,3.0}}, // E7
// V7 V8
{{5.0,0.0,3.0},{0.0,0.0,3.0}}, // E8
// V8 V5
{{0.0,0.0,3.0},{0.0,4.0,3.0}}, // E9
// V2 V7
{{5.0,0.0,0.0},{5.0,0.0,3.0}}, // E10
// V8 V1
{{0.0,0.0,3.0},{0.0,0.0,0.0}}, // E11
// V3 V6
{{5.0,4.0,0.0},{5.0,4.0,3.0}}, // E12
};
double Nx=0;
int j=0;
int k;
for (j=0;j<4;j++)
{
k=0;
for (k=0;k<2;k++)
{
if (k==1)
{
}
else
{
Nx = Nx+ 0.5*((edges[j][k][1]-edges[j][k+1][1])*(edges[j][k][2]+edges[j][k+1][2])); //Newell Methods's Formula
System.out.println("sonuc = "+Nx);
// I can compute Ny and Nz as above. So total surface equals as
//N=squareroot(Nx*Nx+Ny*Ny+Nz*Nz)
}}
}}}