I have a 3D mesh defined by verteces and triangles. I have also normals of the mesh. I'd like to calculate the area of the mesh, assuming it's always closed. I found an interesting implementation of calculation of the 3D volume in this question, and I applied it in a C code to build a function called by R. This is the code:
double SignedVolumeOfTriangle(double p1X, double p1Y, double p1Z,
double p2X, double p2Y, double p2Z, double p3X, double p3Y, double p3Z) {
double v321 = p3X*p2Y*p1Z;
double v231 = p2X*p3Y*p1Z;
double v312 = p3X*p1Y*p2Z;
double v132 = p1X*p3Y*p2Z;
double v213 = p2X*p1Y*p3Z;
double v123 = p1X*p2Y*p3Z;
return (double)(1.0/6.0)*(-v321 + v231 + v312 - v132 - v213 + v123);
}
void MeshVolume(double *X, double *Y, double *Z, int *numT, int *V1, int *V2, int *V3, double *Volume) {
int n;
*Volume=0;
for (n=0; n<*numT; n++) {
*Volume = *Volume + SignedVolumeOfTriangle(X[V1[n]], Y[V1[n]], Z[V1[n]], X[V2[n]], Y[V2[n]], Z[V2[n]], X[V3[n]], Y[V3[n]], Z[V3[n]]);
}
*Volume = fabs(*Volume);
}
Neither in the question nor in the article linked I found the algorithm for calculating the Area of the mesh. Is there anybody can help me please?