public override Vector2d GetFirstDerivative(double t) { /* * Maxima: * s: t * m + n; * x: a*sqrt(%pi)*fresnel_c(s/(a*sqrt(%pi))); * y: a*sqrt(%pi)*fresnel_s(s/(a*sqrt(%pi))); * z: 1; * result: diff([ x, y, z ], t, 1); * * result: [m*cos((m*t+n)^2 / (2*a^2)), * m*sin((m*t+n)^2 / (2*a^2)), * 0] * * m*[cos((m*t+n)^2 / (2*a^2)), * sin((m*t+n)^2 / (2*a^2)), * 0] * * m*[cos(s^2 / (2*a^2)), * sin(s^2 / (2*a^2)), * 0] */ double m = this.ttransform.A; double dl = this.GetL(t); Vector2d v = ClothoUtils.DClotho(dl, this.InvertY, this.A); v = v.Mul(m); return(this.transform.DoTransform(v)); }
public void Test1() { for (double a = 0.5; a < 10; a += 0.5) { foreach (bool invertY in new[] { false, true }) { int ysign = invertY ? -1 : 1; double[] angles = { ysign * 0, ysign *SysMath.PI / 4, ysign *SysMath.PI / 2, ysign * 3 *SysMath.PI / 4 }; foreach (double angle in angles) { Vec2d v = vecMath.NewRotate(angle); double l = ClothoUtils.FindTangent(invertY, a, v); double l_v2 = ClothoUtils.FindTangent(invertY, a, angle); // Se comprueba que las busquedas de tangente sean equivalentes. Assert.IsTrue(l.EpsilonEquals(l_v2)); // Se comprueba que la solucion corresponde con el vector tangente. Vec2d d_pos = ClothoUtils.DClotho(l, invertY, a); Assert.IsTrue(d_pos.Cross(v).EpsilonEquals(0)); Vec2d d_neg = ClothoUtils.DClotho(-l, invertY, a); Assert.IsTrue(d_neg.Cross(v).EpsilonEquals(0)); } } } }