JaRMoS  1.1
Java Reduced Model Simulations
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
AffineLinearMeshTransform.java
Go to the documentation of this file.
1 package jarmos.geometry;
2 
15 public class AffineLinearMeshTransform implements MeshTransform {
16 
20  private float[][] functions;
21 
25  private int[] vertexLTFuncNr;
26 
27  public AffineLinearMeshTransform(float[][] functions) {
28  this(functions, null);
29  }
30 
31  public AffineLinearMeshTransform(float[][] functions, int[] vertexLTFuncNr) {
32  this.functions = functions;
33  this.vertexLTFuncNr = vertexLTFuncNr;
34  }
35 
39  @Override
40  public float[] transformMesh(float[] vertices) {
41  float[] res = new float[vertices.length];
42  float baseX, baseY, baseZ;
54  for (int vertexNr = 0; vertexNr < res.length / 3; vertexNr++) {
55  baseX = vertices[vertexNr * 3 + 0];
56  baseY = vertices[vertexNr * 3 + 1];
57  baseZ = vertices[vertexNr * 3 + 2];
58  /*
59  * Get transformation function for this vertex (possibly due to different functions on different subdomains)
60  */
61  float[] fun = functions[0];
62  if (vertexLTFuncNr != null) {
63  fun = functions[vertexLTFuncNr[vertexNr]];
64  }
65  /*
66  * Apply affine linear transformation
67  */
68  res[vertexNr * 3 + 0] = fun[0] * baseX + fun[1] * baseY + fun[2] * baseZ + fun[9];
69  res[vertexNr * 3 + 1] = fun[3] * baseX + fun[4] * baseY + fun[5] * baseZ + fun[10];
70  res[vertexNr * 3 + 2] = fun[6] * baseX + fun[7] * baseY + fun[8] * baseZ + fun[11];
71  }
72  return res;
73  }
74 }
An affine linear mesh transformation.
AffineLinearMeshTransform(float[][] functions, int[] vertexLTFuncNr)
A common interface for classes providing a mesh transformation.