mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
improve length computation
tidy up IntersectsWith()
This commit is contained in:
@@ -19,9 +19,9 @@
|
||||
{
|
||||
get
|
||||
{
|
||||
var l = (Point1.X - Point2.X) * (Point1.X - Point2.X) +
|
||||
(Point1.Y - Point2.Y) * (Point1.Y - Point2.Y);
|
||||
return Math.Sqrt(l);
|
||||
var dx = Point1.X - Point2.X;
|
||||
var dy = Point1.Y - Point2.Y;
|
||||
return Math.Sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -418,9 +418,9 @@
|
||||
{
|
||||
get
|
||||
{
|
||||
var l = (From.X - To.X) * (From.X - To.X) +
|
||||
(From.Y - To.Y) * (From.Y - To.Y);
|
||||
return Math.Sqrt(l);
|
||||
var dx = From.X - To.X;
|
||||
var dy = From.Y - To.Y;
|
||||
return Math.Sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,6 @@
|
||||
private static readonly DoubleComparer PreciseDoubleComparer = new DoubleComparer(6);
|
||||
private static readonly PointComparer PointComparer = new PointComparer(DoubleComparer);
|
||||
|
||||
//public static void Split()
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
[Fact]
|
||||
public static void IntersectLine()
|
||||
{
|
||||
@@ -461,7 +456,11 @@
|
||||
Assert.Contains(new PdfPoint(437.64489679831945, 366.67203176073724), intersection8195, PointComparer);
|
||||
Assert.Contains(new PdfPoint(402.2532927052592, 368.66065578145003), intersection8195, PointComparer);
|
||||
Assert.Empty(bezierCurve8.Intersect(new PdfLine(215.7243893126156, 170.98261058939812, 82.23950334821318, 90.3908237786144)));
|
||||
|
||||
}
|
||||
|
||||
//public static void Split()
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,8 +531,7 @@
|
||||
/// </summary>
|
||||
public static bool IntersectsWith(this PdfPath.Line line, PdfPath.Line other)
|
||||
{
|
||||
return (ccw(line.From, line.To, other.From) != ccw(line.From, line.To, other.To)) &&
|
||||
(ccw(other.From, other.To, line.From) != ccw(other.From, other.To, line.To));
|
||||
return IntersectsWith(line.From, line.To, other.From, other.To);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -540,8 +539,7 @@
|
||||
/// </summary>
|
||||
public static bool IntersectsWith(this PdfPath.Line line, PdfLine other)
|
||||
{
|
||||
return (ccw(line.From, line.To, other.Point1) != ccw(line.From, line.To, other.Point2)) &&
|
||||
(ccw(other.Point1, other.Point2, line.From) != ccw(other.Point1, other.Point2, line.To));
|
||||
return IntersectsWith(line.From, line.To, other.Point1, other.Point2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user