public void FirstTest() { double x0 = 0.0; double x1 = 10.0; double x2 = 8.0; double x3 = 2.0; double y0 = 0.0; double y1 = 1.0; double y2 = 8.0; double y3 = 9.0; double z0 = -10.0; double z1 = -7.0; double z2 = -8.0; double z3 = -12.0; double x = 5.0; double y = 5.0; InterpQuadrangle interpolator = new InterpQuadrangle() { DelVal = d }; InterpQuadrangle.Weights weights = InterpQuadrangle.InterpolationWeights(x, y, x0, y0, x1, y1, x2, y2, x3, y3); double value = interpolator.GetValue(weights, z0, z1, z2, z3); Assert.AreEqual(-9.34375, value); }
private void VisualDfs2Data(MeshWeights[][] weights, float[] data, double v1, double v2, double v3, bool sdc) { InterpQuadrangle interpQ = new InterpQuadrangle(); interpQ.DelVal = d; interpQ.SmoothDeleteChop = sdc; InterpTriangle interpT = new InterpTriangle(); interpT.DelVal = d; // Replace original quadrangle values for the 4 center nodes with new, // where now some are delete values double[] vcoords = new double[_meshVisual.NumberOfNodes]; Array.Copy(_meshVisual.X, vcoords, _meshVisual.NumberOfNodes); vcoords[3] = v1; vcoords[5] = v2; vcoords[7] = v3; int k = 0; for (int j = 0; j < 80; j++) { for (int i = 0; i < 80; i++) { int ielmt = weights[j][i].ElmtIndex; int[] nodes = _meshVisual.ElementTable[ielmt]; if (weights[j][i].QuadWeights.IsDefined) { double z1 = vcoords[nodes[0]]; double z2 = vcoords[nodes[1]]; double z3 = vcoords[nodes[2]]; double z4 = vcoords[nodes[3]]; data[k] = (float)interpQ.GetValue(weights[j][i].QuadWeights, z1, z2, z3, z4); } else if (weights[j][i].TriWeights.IsDefined) { double z1 = vcoords[nodes[0]]; double z2 = vcoords[nodes[1]]; double z3 = vcoords[nodes[2]]; data[k] = (float)interpT.GetValue(weights[j][i].TriWeights, z1, z2, z3); } else { data[k] = -7f; } k++; } } }
private void VisualDfs2Data(QuadWeights[][] weights, float[] data, double v0, double v1, double v2, double v3, bool sdc) { InterpQuadrangle interpolator = new InterpQuadrangle(); interpolator.DelVal = d; interpolator.SmoothDeleteChop = sdc; // Replace original quadrangle values for the 4 center nodes with new, // where now some are delete values double[] vcoords = new double[zcoords.Length]; Array.Copy(zcoords, vcoords, zcoords.Length); vcoords[ind(1, 1)] = v0; vcoords[ind(1 + 1, 1)] = v1; vcoords[ind(1 + 1, 1 + 1)] = v2; vcoords[ind(1, 1 + 1)] = v3; int k = 0; for (int j = 0; j < 200; j++) { for (int i = 0; i < 200; i++) { if (weights[j][i].Weights.IsDefined) { int ir = weights[j][i].IR; int jr = weights[j][i].JR; double z0 = vcoords[ind(ir, jr)]; double z1 = vcoords[ind(ir + 1, jr)]; double z2 = vcoords[ind(ir + 1, jr + 1)]; double z3 = vcoords[ind(ir, jr + 1)]; data[k] = (float)interpolator.GetValue(weights[j][i].Weights, z0, z1, z2, z3); } else if (i > 100) // Some arbitrary out-of-bounds values { data[k] = (float)13; } else { data[k] = (float)6; } k++; } } }
void DeleteValueTest(bool valOk, double x, double y, double z0, double z1, double z2, double z3, bool sdc = true) { InterpQuadrangle interpolator = new InterpQuadrangle() { DelVal = d, SmoothDeleteChop = sdc }; InterpQuadrangle.Weights weights = InterpQuadrangle.InterpolationWeights(x, y, 0, 0, 10, 0, 10, 10, 0, 10); double val = interpolator.GetValue(weights, z0, z1, z2, z3); if (valOk) { Assert.AreNotEqual(d, val); } else { Assert.AreEqual(d, val); } }