public void RefineTest() { LineViewerSpline line = new LineViewerSpline(); line.colorManager = new MshToMatWPF.Preferences.ColorManager(); LinePointSegmentSpline lcpA = new LinePointSegmentSpline(); lcpA.vert.q.CopyValue(Vector.Create3D(0.0, 0.0, 0.0)); line.AddVertex(lcpA, LinePointAdditionMethod.last); LinePointSegmentSpline lcpB = new LinePointSegmentSpline(); lcpB.vert.q.CopyValue(Vector.Create3D(1.0, 0.0, 0.0)); line.AddVertex(lcpB, LinePointAdditionMethod.last); LinePointSegmentSpline lcpC = new LinePointSegmentSpline(); lcpC.vert.q.CopyValue(Vector.Create3D(2.0, 0.0, 0.0)); line.AddVertex(lcpC, LinePointAdditionMethod.last); LinePointSegmentSpline lcpD = new LinePointSegmentSpline(); lcpD.vert.q.CopyValue(Vector.Create3D(3.0, 0.0, 0.0)); line.AddVertex(lcpD, LinePointAdditionMethod.last); LinePointSegmentSpline lcpE = new LinePointSegmentSpline(); lcpE.vert.q.CopyValue(Vector.Create3D(4.0, 0.0, 0.0)); line.AddVertex(lcpE, LinePointAdditionMethod.last); line.Refine(); Assert.AreEqual(lcpA.next, lcpE); }
public void ConfirmCollectionAfterRemoveTest() { LineViewerSpline line = new LineViewerSpline(); line.colorManager = new MshToMatWPF.Preferences.ColorManager(); LinePointSegmentSpline lcpA = new LinePointSegmentSpline(); lcpA.vert.q.CopyValue(Vector.Create3D(0.0, 0.0, 0.0)); line.AddVertex(lcpA, LinePointAdditionMethod.last); LinePointSegmentSpline lcpB = new LinePointSegmentSpline(); lcpB.vert.q.CopyValue(Vector.Create3D(1.0, 0.0, 0.0)); line.AddVertex(lcpB, LinePointAdditionMethod.last); LinePointSegmentSpline lcpC = new LinePointSegmentSpline(); lcpC.vert.q.CopyValue(Vector.Create3D(2.0, 0.0, 0.0)); line.AddVertex(lcpC, LinePointAdditionMethod.last); line.RemoveVertex(lcpB); Assert.IsTrue(line.ConfirmCollection()); }
public LinePointSegmentSpline CreatePoint(double t) { LinePointSegmentSpline lcp = new LinePointSegmentSpline(); lcp.t = t; lcp.spline = this; return(lcp); }
public void inSegTest() { LinePointSegmentSpline lcp = new LinePointSegmentSpline(); SegmentSpline seg = new SegmentSpline(); lcp.inSeg = seg; Assert.AreEqual(seg.endPoint, lcp); }
public void outSegTest() { LinePointSegmentSpline lcp = new LinePointSegmentSpline(); SegmentSpline seg = new SegmentSpline(); lcp.outSeg = seg; Assert.AreEqual(seg.startPoint, lcp); }
public void inSegNullTest() { LinePointSegmentSpline lcp = new LinePointSegmentSpline(); SegmentSpline seg = new SegmentSpline(); lcp.inSeg = seg; lcp.inSeg = null; Assert.IsNull(seg.endPoint); }
public void outSegNullTest() { LinePointSegmentSpline lcp = new LinePointSegmentSpline(); SegmentSpline seg = new SegmentSpline(); lcp.outSeg = seg; lcp.outSeg = null; Assert.IsNull(seg.startPoint); }
public void nextNullTest() { LinePointSegmentSpline lcpA = new LinePointSegmentSpline(); LinePointSegmentSpline lcpB = new LinePointSegmentSpline(); lcpA.next = lcpB; lcpA.next = null; Assert.IsNull(lcpB.prev); }
private void FillLineViewer() { int N = 15; double dt = 1.0 / (N - 1); for (int n = 0; n < N; n++) { LinePointSegmentSpline lcp = spline.CreatePoint(n * dt); lineViewer.AddVertex(lcp, LinePointAdditionMethod.last); } }
public void tauTest2() { LinePointSegmentSpline lcpA = new LinePointSegmentSpline(); LinePointSegmentSpline lcpB = new LinePointSegmentSpline(); lcpA.vert.q.CopyValue(LinearMath.Vector.Create3D(0.0, 0.0, 0.0)); lcpB.vert.q.CopyValue(LinearMath.Vector.Create3D(1.0, 0.0, 0.0)); lcpA.next = lcpB; Assert.AreEqual(lcpB.tau, Vector.Create3D(1.0, 0.0, 0.0)); }
public void nextTest() { LinePointSegmentSpline lcpA = new LinePointSegmentSpline(); LinePointSegmentSpline lcpB = new LinePointSegmentSpline(); lcpA.vert.q.CopyValue(LinearMath.Vector.Create3D(0.0, 0.0, 0.0)); lcpB.vert.q.CopyValue(LinearMath.Vector.Create3D(1.0, 1.0, 1.0)); lcpA.next = lcpB; Assert.AreSame(lcpA, lcpB.prev); }
public void nextChangedNullTest() { LinePointSegmentSpline lcpA = new LinePointSegmentSpline(); LinePointSegmentSpline lcpB = new LinePointSegmentSpline(); LinePointSegmentSpline lcpC = new LinePointSegmentSpline(); lcpA.vert.q.CopyValue(LinearMath.Vector.Create3D(0.0, 0.0, 0.0)); lcpB.vert.q.CopyValue(LinearMath.Vector.Create3D(1.0, 1.0, 1.0)); lcpC.vert.q.CopyValue(LinearMath.Vector.Create3D(2.0, 2.0, 2.0)); lcpA.next = lcpB; lcpA.next = lcpC; Assert.IsNull(lcpB.prev); }
public void RemoveVertexTest() { LineViewerSpline line = new LineViewerSpline(); line.colorManager = new MshToMatWPF.Preferences.ColorManager(); LinePointSegmentSpline lcpA = new LinePointSegmentSpline(); lcpA.vert.q.CopyValue(Vector.Create3D(0.0, 0.0, 0.0)); line.AddVertex(lcpA, LinePointAdditionMethod.last); LinePointSegmentSpline lcpB = new LinePointSegmentSpline(); lcpB.vert.q.CopyValue(Vector.Create3D(1.0, 0.0, 0.0)); line.AddVertex(lcpB, LinePointAdditionMethod.last); line.RemoveVertex(lcpB); Assert.IsNull(lcpA.next); }
public void RefineAddTest() { LineViewerSpline line = new LineViewerSpline(); line.colorManager = new MshToMatWPF.Preferences.ColorManager(); SplineTestHelper spline = new SplineTestHelper(); LinePointSegmentSpline lcpA = spline.CreatePoint(0.0); line.AddVertex(lcpA, LinePointAdditionMethod.last); LinePointSegmentSpline lcpB = spline.CreatePoint(1.0); line.AddVertex(lcpB, LinePointAdditionMethod.last); line.Refine(); line.Refine(); Assert.AreEqual(lcpA.next.next, lcpB); }
public override List <LinePointSegmentSpline> Intersection(Vector pnt, Vector tau) { Vector z0 = Vector.Create3D(0.0, 0.0, 1.0); double[] A = new double[order + 1]; for (int n = 0; n <= order; n++) { A[n] = z0 * (base.a[n].q % tau); } double B = z0 * (pnt % tau); double a = A[3]; double b = A[2]; double c = A[1]; double d = A[0] - B; double[] t = null; if (a != 0.0) { double Q = (3.0 * a * c - b * b) / (9.0 * a * a); double R = (9.0 * a * b * c - 27.0 * a * a * d - 2.0 * b * b * b) / (54.0 * a * a * a); double D = Q * Q * Q + R * R; if (D == 0) { t = new double[2]; t[0] = 2.0 * Math.Pow(R, 1.0 / 3.0) - b / (3.0 * a); t[1] = -Math.Pow(R, 1.0 / 3.0) - b / (3.0 * a); } if (D > 0) { t = new double[1]; double S = Math.Pow(R + Math.Sqrt(D), 1.0 / 3.0); double T = Math.Pow(R - Math.Sqrt(D), 1.0 / 3.0); t[0] = S + T - b / (3.0 * a); } if (D < 0) { t = new double[3]; double E = Math.Sqrt(-D); double cos_phi = R / Math.Sqrt(R * R + E * E); double phi = Math.Acos(cos_phi); double C = Math.Pow(R * R + E * E, 1.0 / 6.0); double p = C * Math.Cos(phi / 3.0); double q = C * Math.Sin(phi / 3.0); double sqrt3 = Math.Sqrt(3.0); t[0] = 2.0 * p - b / (3.0 * a); t[1] = -p - sqrt3 * q - b / (3.0 * a); t[2] = -p + sqrt3 * q - b / (3.0 * a); } } else if (b != 0.0) { a = b; b = c; c = d; double D = b * b - 4 * a * c; if (D < 0.0) { t = new double[0]; } if (D == 0.0) { t = new double[1]; t[0] = -b / (2.0 * a); } if (D > 0.0) { t = new double[2]; double sqrtD = Math.Sqrt(D); t[0] = (-b - sqrtD) / (2.0 * a); t[1] = (-b - sqrtD) / (2.0 * a); } } else if (c != 0.0) { t = new double[1]; t[0] = -d / c; } else { t = new double[0]; } double eps = 1E-6; List <LinePointSegmentSpline> lst = new List <LinePointSegmentSpline>(); foreach (var tp in t) { if ((tp >= 0.0 - eps) & (tp <= 1.0 + eps)) { LinePointSegmentSpline lcp = new LinePointSegmentSpline(); lcp.spline = this; lcp.t = tp; lst.Add(lcp); } } return(lst); }