/** * Sets the eigenvector u for the tensor with specified indices. * The specified vector is assumed to have length one. If the 3rd * component is negative, this method stores the negative of the * specified vector, so that the 3rd component is positive. * @param i1 index for 1st dimension. * @param i2 index for 2nd dimension. * @param i3 index for 3rd dimension. * @param u {u1,u2,u3} of eigenvector components. */ public void setEigenvectorU(int i1, int i2, int i3, float[] u) { setEigenvectorU(i1,i2,i3,u[0],u[1],u[2]); }
float av = (float)ev[1]; if (av<0.0f) av = 0.0f; float aw = (float)ev[2]; if (aw<0.0f) aw = 0.0f; setEigenvectorU(i1,i2,i3,u1,u2,u3); setEigenvectorW(i1,i2,i3,w1,w2,w3); setEigenvalues(i1,i2,i3,au,av,aw);
/** * Constructs tensors from the specified tensors. * @param t the tensors from which to copy eigenvectors and eigenvalues. */ public EigenTensors3(EigenTensors3 t) { this(t._n1,t._n2,t._n3,t._compressed); float[] a = new float[3]; float[] u = new float[3]; float[] w = new float[3]; for (int i3=0; i3<_n3; ++i3) { for (int i2=0; i2<_n2; ++i2) { for (int i1=0; i1<_n1; ++i1) { t.getEigenvalues(i1,i2,i3,a); t.getEigenvectorU(i1,i2,i3,u); t.getEigenvectorW(i1,i2,i3,w); setEigenvalues(i1,i2,i3,a); setEigenvectorU(i1,i2,i3,u); setEigenvectorW(i1,i2,i3,w); } } } }
float w3i = c3(w1i,w2i); setEigenvalues(i1,i2,i3,aui,avi,awi); setEigenvectorU(i1,i2,i3,u1i,u2i,u3i); setEigenvectorW(i1,i2,i3,w1i,w2i,w3i);
float[] w = makeOrthogonalVector(u); et1.setEigenvalues(i1,i2,i3,a); et1.setEigenvectorU(i1,i2,i3,u); et1.setEigenvectorW(i1,i2,i3,w);
public static void demo3() { int n1 = 111; int n2 = 111; int n3 = 1; EigenTensors3 et = new EigenTensors3(n1,n2,n3,false); float eu = 0.01f, ev = 1.00f, ew = 1.00f; float u1 = 1.00f, u2 = 0.00f, u3 = 0.00f; float w1 = 0.00f, w2 = 0.00f, w3 = 1.00f; int i3 = 0; for (int i2=0; i2<n2; ++i2) { float a = i2*FLT_PI/2.0f/(n2-1); u1 = cos(a); u2 = sin(a); for (int i1=0; i1<n1; ++i1) { et.setEigenvalues(i1,i2,i3,eu,ev,ew); et.setEigenvectorU(i1,i2,i3,u1,u2,u3); et.setEigenvectorW(i1,i2,i3,w1,w2,w3); } } TensorsPanel tp = new TensorsPanel(et); AxisAlignedQuad aaq = new AxisAlignedQuad(Axis.X, new Point3(i3, 0, 0), new Point3(i3,n2-1,n1-1)); aaq.getFrame().addChild(tp); show(aaq); }
public static void demo1() { int n1 = 1; int n2 = 111; int n3 = 111; EigenTensors3 et = new EigenTensors3(n1,n2,n3,false); float eu = 1.00f, ev = 1.00f, ew = 0.01f; float u1 = 1.00f, u2 = 0.00f, u3 = 0.00f; float w1 = 0.00f, w2 = 0.00f, w3 = 1.00f; int i1 = 0; for (int i3=0; i3<n3; ++i3) { float a = i3*FLT_PI/2.0f/(n3-1); w2 = sin(a); w3 = cos(a); for (int i2=0; i2<n2; ++i2) { et.setEigenvalues(i1,i2,i3,eu,ev,ew); et.setEigenvectorU(i1,i2,i3,u1,u2,u3); et.setEigenvectorW(i1,i2,i3,w1,w2,w3); } } TensorsPanel tp = new TensorsPanel(et); AxisAlignedQuad aaq = new AxisAlignedQuad(Axis.Z, new Point3( 0, 0,i1), new Point3(n3-1,n2-1,i1)); aaq.getFrame().addChild(tp); show(aaq); }
public static void demo2() { int n1 = 111; int n2 = 1; int n3 = 111; EigenTensors3 et = new EigenTensors3(n1,n2,n3,false); float eu = 0.01f, ev = 1.00f, ew = 1.00f; float u1 = 1.00f, u2 = 0.00f, u3 = 0.00f; float w1 = 0.00f, w2 = 1.00f, w3 = 0.00f; int i2 = 0; for (int i3=0; i3<n3; ++i3) { float a = i3*FLT_PI/2.0f/(n3-1); u1 = cos(a); u3 = sin(a); for (int i1=0; i1<n1; ++i1) { et.setEigenvalues(i1,i2,i3,eu,ev,ew); et.setEigenvectorU(i1,i2,i3,u1,u2,u3); et.setEigenvectorW(i1,i2,i3,w1,w2,w3); } } TensorsPanel tp = new TensorsPanel(et); AxisAlignedQuad aaq = new AxisAlignedQuad(Axis.Y, new Point3( 0,i2, 0), new Point3(n3-1,i2,n1-1)); aaq.getFrame().addChild(tp); show(aaq); }
private static void testRandom( boolean compressed, double errorAngle, double errorValue, double errorTensor) { int n1 = 19, n2 = 20, n3 = 21; EigenTensors3 et = new EigenTensors3(n1,n2,n3,compressed); for (int i3=0; i3<n3; ++i3) { for (int i2=0; i2<n2; ++i2) { for (int i1=0; i1<n1; ++i1) { float[] a = makeRandomEigenvalues(); float[] u = makeRandomEigenvector(); float[] w = makeOrthogonalVector(u); et.setEigenvalues(i1,i2,i3,a); et.setEigenvectorU(i1,i2,i3,u); et.setEigenvectorW(i1,i2,i3,w); float[] c; c = et.getEigenvectorU(i1,i2,i3); checkEigenvectors(u,c,errorAngle); c = et.getEigenvectorW(i1,i2,i3); checkEigenvectors(w,c,errorAngle); c = et.getEigenvalues(i1,i2,i3); checkEigenvalues(a,c,errorValue); float[] t1 = et.getTensor(i1,i2,i3); et.setTensor(i1,i2,i3,t1); float[] t2 = et.getTensor(i1,i2,i3); checkTensors(t1,t2,errorTensor); } } } }