1 package org.textensor.vis;
2
3 import org.textensor.report.E;
4
5 public class VolElt {
6
7 int[] lens;
8 float[] verts;
9 float[] norms;
10
11
12 double cx;
13 double cy;
14 double cz;
15
16 public VolElt(int[] l, float[] v, float[] n) {
17 lens = l;
18 verts = v;
19 norms = n;
20
21 }
22
23 public int getNvert() {
24 return verts.length;
25 }
26
27 public int[] getLens() {
28 return lens;
29 }
30
31 public float[] getVerts() {
32 return verts;
33 }
34
35 public float[] getNorms() {
36 return norms;
37 }
38
39
40 public void centroidize() {
41 int nv = verts.length / 3;
42 cx = 0;
43 cy = 0;
44 cz = 0;
45 for (int i = 0; i < nv; i++) {
46 cx += verts[3 * i];
47 cy += verts[3 * i + 1];
48 cz += verts[3 * i + 2];
49 }
50 cx /= nv;
51 cy /= nv;
52 cz /= nv;
53
54
55 for (int i = 0; i < nv; i++) {
56 verts[3 * i] -= cx;
57 verts[3 * i + 1] -= cy;
58 verts[3 * i + 2] -= cz;
59 }
60 }
61
62 public double getCX() {
63 return cx;
64 }
65
66 public double getCY() {
67 return cy;
68 }
69
70 public double getCZ() {
71 return cz;
72 }
73 }