本文整理汇总了C#中System.Edge.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Edge.Contains方法的具体用法?C# Edge.Contains怎么用?C# Edge.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Edge
的用法示例。
在下文中一共展示了Edge.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEdgeContains
public void TestEdgeContains()
{
Edge edge;
edge = new Edge(1, 8, 4, 8);
Assert.Equals(edge.Contains(new Point(2, 8)), true);
Assert.Equals(edge.Contains(new Point(4, 8)), true);
Assert.Equals(edge.Contains(new Point(6, 8)), false);
Assert.Equals(edge.Contains(new Point(3, 7)), false);
edge = new Edge(3, 7, 7, 9);
Assert.Equals(edge.Contains(new Point(5, 8)), true);
Assert.Equals(edge.Contains(new Point(5, 9)), false);
Assert.Equals(edge.Contains(new Point(9, 10)), false);
Assert.Equals(edge.Contains(new Point(3, -7)), false);
}
示例2: MergeEdge
bool MergeEdge(Edge edge)
{
// Tries to merge edge into another, if they are parralel and close.
foreach (Edge e in edges)
if (Util.IsEqual(e.Angle, edge.Angle, EpsilonAngle) && edge.P1.DistanceTo(e) < Epsilon)
{
Point h1 = edge.IntersectWithPerpendicular(e.P1);
Point h2 = edge.IntersectWithPerpendicular(e.P2);
// If edge and (h1, h2) do not intersect and are too far away, ignore e.
if (!edge.Contains(h1) && !edge.Contains(h2))
{
if (Epsilon <= Math.Min(
Math.Min(e.P1.DistanceTo(edge.P1), e.P1.DistanceTo(edge.P2)),
Math.Min(e.P2.DistanceTo(edge.P1), e.P2.DistanceTo(edge.P2)))
)
continue;
}
Point boxL1, boxL2, boxR1, boxR2;
boxL1 = Point.Min(edge.P1, edge.P2, h1, h2);
boxR1 = Point.Max(edge.P1, edge.P2, h1, h2);
Point g1, g2;
g1 = e.IntersectWithPerpendicular(edge.P1);
g2 = e.IntersectWithPerpendicular(edge.P2);
boxL2 = Point.Min(e.P1, e.P2, g1, g2);
boxR2 = Point.Max(e.P1, e.P2, g1, g2);
bool wrong = false;
if (boxL1.DistanceTo(boxL2) > 0.5) wrong = true;
if (boxR1.DistanceTo(boxR2) > 0.5) wrong = true;
if (wrong)
{
throw new Exception("muie");
}
// Merging:
double W = edge.Weight + e.Weight;
double w1 = edge.Weight / W;
double w2 = e.Weight / W;
Point old1 = e.P1;
Point old2 = e.P2;
e.P1 = (boxL1 * w1) + (boxL2 * w2);
e.P2 = (boxR1 * w1) + (boxR2 * w2);
// if (Math.Max(old1.DistanceTo(e.P1), old2.DistanceTo(e.P2)) > 0.5)
// throw new Exception(string.Format("Muie {0}!", e));
e.Weight = W;
int max = 14;
if (e.P1.X > max || e.P2.X > max || e.P2.Y > max || e.P1.Y > max)
throw new Exception(string.Format("Muie {0}!", e));
return true;
}
return false;
}