/// <summary> /// Returns the pseudo cross product calculated as the dot product between v1 and the perpendicular of v0. /// </summary> public static void Cross(Vec2d[] v0, Vec2d[] v1, int count, double[] result) { for (int i = 0; i < count; i++) { result[i] = Vec2d.Cross(v0[i], v1[i]); } }
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)); } } } }
/// <summary> /// Indica si los puntos estan alineados. /// </summary> /// <param name="pt0">Punto 1.</param> /// <param name="pt1">Punto 2.</param> /// <param name="pt2">Punto 3.</param> /// <returns> /// Indica si los puntos estan al /// ineados. /// </returns> public static bool AreAligned(Vec2d pt0, Vec2d pt1, Vec2d pt2) { Vec2d v13 = pt2.Sub(pt0); Vec2d v12 = pt1.Sub(pt0); double area = v13.Cross(v12) / 2; return(area.EpsilonEquals(0)); }
/// <summary> /// Returns the pseudo cross product calculated as the dot product between v1 and the perpendicular of v0. /// </summary> public static void Cross(Vec2d[] v0, Vec2d[] v1, int count, double[] result) { ForEach(Partitioner.Create(0, count), range => { for (int i = range.Item1; i < range.Item2; i++) { result[i] = Vec2d.Cross(v0[i], v1[i]); } }); }