本文整理汇总了C#中Vector2d.LerpProjectOnto方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2d.LerpProjectOnto方法的具体用法?C# Vector2d.LerpProjectOnto怎么用?C# Vector2d.LerpProjectOnto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2d
的用法示例。
在下文中一共展示了Vector2d.LerpProjectOnto方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenLineSweepsPoint
/// <summary>
/// Enumerates the times and places, if any, where a moving line crosses a point during a time step.
/// The line's endpoints move at a constant rate along their linear paths.
/// </summary>
/// <remarks>Original code found here https://github.com/Strilanc/Methods/blob/master/Methods/Methods/LineSweepPoint/GeometryUtil.cs </remarks>
public static IEnumerable<Sweep> WhenLineSweepsPoint(Vector2d point, Line pathOfLineStartPoint, Line pathOfLineEndPoint)
{
var a = point - pathOfLineStartPoint[0];
var b = -pathOfLineStartPoint.Delta;
var c = pathOfLineEndPoint[0] - pathOfLineStartPoint[0];
var d = pathOfLineEndPoint.Delta - pathOfLineStartPoint.Delta;
//return from t in QuadraticRoots(b.Cross(d), a.Cross(d) + b.Cross(c), a.Cross(c))
return from across in QuadraticRoots(Vector2Ext.Cross(b, d), Vector2Ext.Cross(a, d) + Vector2Ext.Cross(b, c), Vector2Ext.Cross(a, c))
where across >= 0 && across <= 1
let start = pathOfLineStartPoint.Lerp(across)
let end = pathOfLineEndPoint.Lerp(across)
let time = point.LerpProjectOnto(new Line(start, end))
where time >= 0 && time <= 1
orderby time
select new Sweep(timeProportion: time, acrossProportion: across);
}