mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-21 04:17:57 +08:00
Create generic methods for lines in GeometryExtensions
This commit is contained in:
@@ -411,6 +411,19 @@
|
||||
/// </summary>
|
||||
public PdfPoint To { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Length of the line.
|
||||
/// </summary>
|
||||
public double Length
|
||||
{
|
||||
get
|
||||
{
|
||||
var l = (From.X - To.X) * (From.X - To.X) +
|
||||
(From.Y - To.Y) * (From.Y - To.Y);
|
||||
return Math.Sqrt(l);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="Line"/>.
|
||||
/// </summary>
|
||||
|
@@ -86,7 +86,18 @@
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetT() * 180 / Math.PI;
|
||||
double t;
|
||||
if (!BottomRight.Equals(BottomLeft))
|
||||
{
|
||||
t = Math.Atan2(BottomRight.Y - BottomLeft.Y, BottomRight.X - BottomLeft.X);
|
||||
}
|
||||
else
|
||||
{
|
||||
// handle the case where both bottom points are identical
|
||||
t = Math.Atan2(TopLeft.Y - BottomLeft.Y, TopLeft.X - BottomLeft.X) - Math.PI / 2;
|
||||
}
|
||||
|
||||
return t * 180 / Math.PI;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,22 +184,6 @@
|
||||
BottomLeft.Translate(dx, dy), BottomRight.Translate(dx, dy));
|
||||
}
|
||||
|
||||
private double GetT()
|
||||
{
|
||||
double t;
|
||||
if (!BottomRight.Equals(BottomLeft))
|
||||
{
|
||||
t = Math.Atan2(BottomRight.Y - BottomLeft.Y, BottomRight.X - BottomLeft.X);
|
||||
}
|
||||
else
|
||||
{
|
||||
// handle the case where both bottom points are identical
|
||||
t = Math.Atan2(TopLeft.Y - BottomLeft.Y, TopLeft.X - BottomLeft.X) - Math.PI / 2;
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
private void GetWidthHeight()
|
||||
{
|
||||
var tm = TransformationMatrix.GetRotationMatrix(Rotation).Inverse();
|
||||
|
Reference in New Issue
Block a user