calculating volume (tetrahedron)

Hello,
I currently work on a generation of 3D tetrahedra in VS2010 c + +.
The tetrahedra are generated sizes of small, medium or large randomly and of course not in contact with each other.
I use v = H * B * 1/3 to calculate volume.

volume (codes)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
double Tetraedre3D::Volume(Vertex _point) const
{
   double aire_base;
   double hauteur,hauteur1;
   double norme;

  Vecteur v1;
  Vecteur v2;
  Vecteur v3;

v1.setCoordx(this->getpVertex(1).getCoordx() - this->getpVertex(0).getCoordx());
v1.setCoordy(this->getpVertex(1).getCoordy() - this->getpVertex(0).getCoordy());
v1.setCoordz(this->getpVertex(1).getCoordz() - this->getpVertex(0).getCoordz());
v2.setCoordx(this->getpVertex(2).getCoordx() - this->getpVertex(0).getCoordx());
v2.setCoordy(this->getpVertex(2).getCoordy() - this->getpVertex(0).getCoordy());
v2.setCoordz(this->getpVertex(2).getCoordz() - this->getpVertex(0).getCoordz());

  v3 = v2 ^ v1;
  norme = (double) sqrt(v3.getCoordx()*v3.getCoordx() + 
			v3.getCoordy()*v3.getCoordy() + 
			v3.getCoordz()*v3.getCoordz());

	aire_base = norme / 2;

   v1 = this->normale;
   v2.setCoordx(_point.getCoordx() - this->getpVertex(0).getCoordx());
   v2.setCoordy(_point.getCoordy() - this->getpVertex(0).getCoordy());
   v2.setCoordz(_point.getCoordz() - this->getpVertex(0).getCoordz());
	
   hauteur1 = v2 % v1;
   hauteur = fabs(hauteur1);

   return  (aire_base * hauteur)/3;

}


I would like to help with the correction of the calculation volume.
thank you
Topic archived. No new replies allowed.