當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。