本文整理汇总了C#中LineSegment.ProjectOnto方法的典型用法代码示例。如果您正苦于以下问题:C# LineSegment.ProjectOnto方法的具体用法?C# LineSegment.ProjectOnto怎么用?C# LineSegment.ProjectOnto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LineSegment
的用法示例。
在下文中一共展示了LineSegment.ProjectOnto方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollidesWith
public bool CollidesWith(LineSegment lineSegment)
{
var axisA = new Line(Point1, Point2.Substract(Point1));
if (axisA.OnOneSide(lineSegment))
{
return false;
}
var axisB = new Line(lineSegment.Point1, lineSegment.Point2.Substract(lineSegment.Point1));
if (axisB.OnOneSide(this))
{
return false;
}
if (axisA.Direction.IsParallel(axisB.Direction))
{
Range rangeA = ProjectOnto(axisA.Direction);
Range rangeB = lineSegment.ProjectOnto(axisA.Direction);
return rangeA.Overlaps(rangeB);
}
return true;
}
示例2: SeparatingAxisForRectangle
public bool SeparatingAxisForRectangle(Rectangle rectangle)
{
IVector2D n = Point1.Substract(Point2);
var rEdgeA = new LineSegment(rectangle.Corner(0), rectangle.Corner(1));
var rEdgeB = new LineSegment(rectangle.Corner(2), rectangle.Corner(3));
Range rEdgeARange = rEdgeA.ProjectOnto(n);
Range rEdgeBRange = rEdgeB.ProjectOnto(n);
Range rProjection = rEdgeARange.Hull(rEdgeBRange);
Range axisRange = ProjectOnto(n);
return !axisRange.Overlaps(rProjection);
}