mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 10:55:04 +08:00
minor corrections
This commit is contained in:
@@ -193,7 +193,7 @@
|
|||||||
/// <param name="points">The points.</param>
|
/// <param name="points">The points.</param>
|
||||||
public static PdfRectangle MinimumAreaRectangle(IEnumerable<PdfPoint> points)
|
public static PdfRectangle MinimumAreaRectangle(IEnumerable<PdfPoint> points)
|
||||||
{
|
{
|
||||||
if (points == null || points.Count() == 0)
|
if (points?.Any() != true)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("MinimumAreaRectangle(): points cannot be null and must contain at least one point.", nameof(points));
|
throw new ArgumentException("MinimumAreaRectangle(): points cannot be null and must contain at least one point.", nameof(points));
|
||||||
}
|
}
|
||||||
@@ -210,7 +210,7 @@
|
|||||||
{
|
{
|
||||||
if (points == null || points.Count < 2)
|
if (points == null || points.Count < 2)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("OrientedBoundingBox(): points cannot be null and must contain at least two points.");
|
throw new ArgumentException("OrientedBoundingBox(): points cannot be null and must contain at least two points.", nameof(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fitting a line through the points
|
// Fitting a line through the points
|
||||||
@@ -252,8 +252,7 @@
|
|||||||
cos, sin, 0,
|
cos, sin, 0,
|
||||||
-sin, cos, 0,
|
-sin, cos, 0,
|
||||||
0, 0, 1);
|
0, 0, 1);
|
||||||
var obb = rotateBack.Transform(aabb);
|
return rotateBack.Transform(aabb);
|
||||||
return obb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -261,9 +260,9 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static IEnumerable<PdfPoint> GrahamScan(IEnumerable<PdfPoint> points)
|
public static IEnumerable<PdfPoint> GrahamScan(IEnumerable<PdfPoint> points)
|
||||||
{
|
{
|
||||||
if (points == null || points.Count() == 0)
|
if (points?.Any() != true)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("GrahamScan(): points cannot be null and must contain at least one point.");
|
throw new ArgumentException("GrahamScan(): points cannot be null and must contain at least one point.", nameof(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (points.Count() < 3) return points;
|
if (points.Count() < 3) return points;
|
||||||
@@ -814,7 +813,7 @@
|
|||||||
|
|
||||||
var solution = SolveCubicEquation(a, b, c, d);
|
var solution = SolveCubicEquation(a, b, c, d);
|
||||||
|
|
||||||
return solution.Where(s => !double.IsNaN(s)).Where(s => s >= -epsilon && (s - 1) <= epsilon).OrderBy(s => s).ToArray();
|
return solution.Where(s => !double.IsNaN(s) && s >= -epsilon && (s - 1) <= epsilon).OrderBy(s => s).ToArray();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -1056,7 +1055,6 @@
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private const double OneThird = 0.333333333333333333333;
|
private const double OneThird = 0.333333333333333333333;
|
||||||
@@ -1182,8 +1180,7 @@
|
|||||||
{
|
{
|
||||||
string BboxToRect(PdfRectangle box, string stroke)
|
string BboxToRect(PdfRectangle box, string stroke)
|
||||||
{
|
{
|
||||||
var overallBbox = $"<rect x='{box.Left}' y='{box.Bottom}' width='{box.Width}' height='{box.Height}' stroke-width='2' fill='none' stroke='{stroke}'></rect>";
|
return $"<rect x='{box.Left}' y='{box.Bottom}' width='{box.Width}' height='{box.Height}' stroke-width='2' fill='none' stroke='{stroke}'></rect>";
|
||||||
return overallBbox;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var glyph = p.ToSvg(height);
|
var glyph = p.ToSvg(height);
|
||||||
@@ -1202,9 +1199,7 @@
|
|||||||
var path = $"<path d='{glyph}' stroke='cyan' stroke-width='3'></path>";
|
var path = $"<path d='{glyph}' stroke='cyan' stroke-width='3'></path>";
|
||||||
var bboxRect = bbox.HasValue ? BboxToRect(bbox.Value, "yellow") : string.Empty;
|
var bboxRect = bbox.HasValue ? BboxToRect(bbox.Value, "yellow") : string.Empty;
|
||||||
var others = string.Join(" ", bboxes.Select(x => BboxToRect(x, "gray")));
|
var others = string.Join(" ", bboxes.Select(x => BboxToRect(x, "gray")));
|
||||||
var result = $"<svg width='500' height='500'><g transform=\"scale(0.2, -0.2) translate(100, -700)\">{path} {bboxRect} {others}</g></svg>";
|
return $"<svg width='500' height='500'><g transform=\"scale(0.2, -0.2) translate(100, -700)\">{path} {bboxRect} {others}</g></svg>";
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user