本文整理汇总了C#中Point2d.GetDistanceTo方法的典型用法代码示例。如果您正苦于以下问题:C# Point2d.GetDistanceTo方法的具体用法?C# Point2d.GetDistanceTo怎么用?C# Point2d.GetDistanceTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2d
的用法示例。
在下文中一共展示了Point2d.GetDistanceTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public static double Get(bool IsLeftComp, double r, Polyline line, Point2d TheIntersectPoint, int Index, Point2d StartPoint)
{
double oldBulge = line.GetBulgeAt(Index - 1);
if (oldBulge == 0)
return 0;//这里可能不对,可能有两个交点,而默认为一个交点
else
{
double delta = System.Math.Atan(System.Math.Abs(oldBulge)) * 2;
//这里计算新的半径时,要考虑方向因素,可能新半径会更小,也可能会更大
//取决于路径的偏移方向,以及圆心的位置
double newRadius = line.GetPoint2dAt(Index - 1).GetDistanceTo(line.GetPoint2dAt(Index)) / 2 / System.Math.Sin(delta);//新弧的半径
if (IsLeftComp)
{
if (oldBulge < 0)
newRadius += r;
else newRadius -= r;
}
else
{
if (oldBulge > 0)
newRadius += r;
else newRadius -= r;
}
double newChord = StartPoint.GetDistanceTo(TheIntersectPoint);
double newBulge = System.Math.Tan(
System.Math.Asin(newChord / 2 / newRadius) / 2
)
* line.GetBulgeAt(Index - 1) / System.Math.Abs(line.GetBulgeAt(Index - 1));
return -newBulge;
}
}
示例2: Sierpinski
public Sierpinski(Point2d a, Point2d b, Point2d c)
{
Triangle = new Polyline();
A = a;
B = b;
C = c;
this.Size = B.GetDistanceTo(A);
Triangle.AddVertexAt(0, A, 0, 0, 0);
Triangle.AddVertexAt(1, B, 0, 0, 0);
Triangle.AddVertexAt(2, C, 0, 0, 0);
Triangle.Closed = true;
depth = 0;
}
示例3: GetTangentsTo
/// <summary>
/// Returns the tangents between the active CircularArc2d instance complete circle and a point.
/// </summary>
/// <remarks>
/// Tangents start points are on the object to which this method applies, end points on the point passed as argument.
/// Tangents are always returned in the same order: the tangent on the left side of the line from the circular arc center
/// to the point before the other one.
/// </remarks>
/// <param name="arc">The instance to which this method applies.</param>
/// <param name="pt">The Point2d to which tangents are searched</param>
/// <returns>An array of LineSegement2d representing the tangents (2) or null if there is none.</returns>
public static LineSegment2d[] GetTangentsTo(this CircularArc2d arc, Point2d pt)
{
// check if the point is inside the circle
Point2d center = arc.Center;
if (pt.GetDistanceTo(center) <= arc.Radius)
return null;
Vector2d vec = center.GetVectorTo(pt) / 2.0;
CircularArc2d tmp = new CircularArc2d(center + vec, vec.Length);
Point2d[] inters = arc.IntersectWith(tmp);
if (inters == null)
return null;
LineSegment2d[] result = new LineSegment2d[2];
Vector2d v1 = inters[0] - center;
Vector2d v2 = inters[1] - center;
int i = vec.X * v1.Y - vec.Y - v1.X > 0 ? 0 : 1;
int j = i ^ 1;
result[i] = new LineSegment2d(inters[0], pt);
result[j] = new LineSegment2d(inters[1], pt);
return result;
}