当前位置: 首页>>代码示例>>C#>>正文


C# Line.Lerp方法代码示例

本文整理汇总了C#中System.Line.Lerp方法的典型用法代码示例。如果您正苦于以下问题:C# Line.Lerp方法的具体用法?C# Line.Lerp怎么用?C# Line.Lerp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Line的用法示例。


在下文中一共展示了Line.Lerp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
        }
开发者ID:AyyTee,项目名称:Aventyr,代码行数:22,代码来源:GeometryUtil.cs

示例2: PlaceOnPortal

 private static void PlaceOnPortal(IPortalCommon instance, IPortal portal, float t)
 {
     Line portalLine = new Line(Vector2Ext.ToDouble(Portal.GetWorldVerts(portal)));
     Transform2d transform = (Transform2d)instance.WorldTransform;
     transform.Position = (Vector2d)portalLine.Lerp(t);
     instance.WorldTransform = (Transform2)transform;
 }
开发者ID:AyyTee,项目名称:Aventyr,代码行数:7,代码来源:SimulationStep.cs


注:本文中的System.Line.Lerp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。