//----- LSD function with user scale ----- public void FindLines(double scale) { _lines.Clear(); int n = 0; IntPtr result = lsd_scale(ref n, _lsdImage, _lsdImage.Length, _X, _Y, scale); //LSD function if (n > 0) { int n_out = 7 * n; double[] outLSD = new double[n_out]; Marshal.Copy(result, outLSD, 0, n_out); //The seven values are: // - x1,y1,x2,y2,width,p,-log10(NFA) for (int i = 0; i < n; i++) { int pX1, pX2, pY1, pY2; pX1 = (int)outLSD[7 * i + 0]; pY1 = (int)outLSD[7 * i + 1]; pX2 = (int)outLSD[7 * i + 2]; pY2 = (int)outLSD[7 * i + 3]; Point pX = new Point(pX1, pY1); Point pY = new Point(pX2, pY2); LSDLine line = new LSDLine(pX, pY); _lines.Add(line); } } }
/// <summary> /// Get the exterior angle between this line and <paramref name="otherLine"/> /// </summary> /// <param name="otherLine">The other line</param> /// <returns>The exterior angle between this line and <paramref name="otherLine"/></returns> public double GetExteriorAngleDegree(LSDLine otherLine) { PointF direction1 = Direction; PointF direction2 = otherLine.Direction; double radianAngle = Math.Atan2(direction2.Y, direction2.X) - Math.Atan2(direction1.Y, direction1.X); double degreeAngle = radianAngle * (180.0 / Math.PI); return (degreeAngle <= -180.0 ? degreeAngle + 360 : degreeAngle > 180.0 ? degreeAngle - 360 : degreeAngle); }