當前位置: 首頁>>代碼示例>>C#>>正文


C# PointF.Length方法代碼示例

本文整理匯總了C#中System.Drawing.PointF.Length方法的典型用法代碼示例。如果您正苦於以下問題:C# PointF.Length方法的具體用法?C# PointF.Length怎麽用?C# PointF.Length使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.PointF的用法示例。


在下文中一共展示了PointF.Length方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RebuildGraph


//.........這裏部分代碼省略.........
                    }
                }
            }

            // Let Glee calculate a layout
            var layout_rnd = new Microsoft.Glee.GraphViewerGdi.GraphRenderer(layout_g);
            layout_rnd.CalculateLayout();

            // Extract and replicate layout
            // Nodes
            foreach( var kv in layout_nodes )
                kv.Key.Position = this.FromGleePoint(kv.Value.Attr.Pos);

            // Edges
            foreach( var kv in layout_edges )
            {
                var edge = kv.Key;
                var layout_edge = kv.Value;

                var curve = layout_edge.Attr.EdgeCurve as Microsoft.Glee.Splines.Curve;
                if( curve != null )
                {
                    var segments = new List<CurveSegment>();

                    foreach( Microsoft.Glee.Splines.ICurve segment in curve.Segs )
                    {
                        if( segment is Microsoft.Glee.Splines.CubicBezierSeg )
                        {
                            var b = (Microsoft.Glee.Splines.CubicBezierSeg)segment;

                            segments.Add(new CurveSegment(new PointF[]
                                {
                                    this.FromGleePoint(b.B(0)),
                                    this.FromGleePoint(b.B(1)),
                                    this.FromGleePoint(b.B(2)),
                                    this.FromGleePoint(b.B(3)),
                                }));
                        }
                        else // Fallback to linearity, even if it is not a LineSeg.
                        {
                            segments.Add(new CurveSegment(new PointF[]
                                {
                                    this.FromGleePoint(segment.Start),
                                    this.FromGleePoint(segment.End),
                                }));
                        }
                    }

                    // Snap edge ends to nodes
                    var e = new PointF(
                        edge.StartNode.Position.X - segments[0].Points[0].X,
                        edge.StartNode.Position.Y - segments[0].Points[0].Y);
                    var diff = e.Norm().Multiply(e.Length() - this.node_radius);
                    edge.StartPosition = segments[0].Points[0] = segments[0].Points[0].Add(diff);

                    var seg = segments[segments.Count - 1];
                    e = new PointF(
                        edge.EndNode.Position.X - seg.Points[seg.Points.Length - 1].X,
                        edge.EndNode.Position.Y - seg.Points[seg.Points.Length - 1].Y);
                    diff = e.Norm().Multiply(e.Length() - this.node_radius);
                    edge.EndPosition = seg.Points[seg.Points.Length - 1] =
                        seg.Points[seg.Points.Length - 1].Add(diff);

                    edge.Segments = segments.ToArray();
                }
                else
                {
                    // Fallback to line
                    edge.StartPosition = edge.StartNode.Position;
                    edge.EndPosition = edge.EndNode.Position;

                    // Snap edge ends to nodes
                    var e = new PointF(
                        edge.EndPosition.X - edge.StartPosition.X,
                        edge.EndPosition.Y - edge.StartPosition.Y)
                        .Norm().Multiply(this.node_radius);

                    edge.StartPosition = edge.StartPosition.Add(e);
                    edge.EndPosition = edge.EndPosition.Substract(e);
                }

                // Label
                edge.LabelPosition = new PointF(
                    -(float)layout_edge.Attr.LabelTop,
                    (float)layout_edge.Attr.LabelLeft);
            }

            // Add an 'in-edge' to the start state node
            var start_edge = new Edge();
            start_edge.LinePen = this.edge_pen;
            start_edge.EndNode = this.node_map[0];
            start_edge.EndPosition = new PointF(
                start_edge.EndNode.Position.X - this.node_radius,
                start_edge.EndNode.Position.Y);
            start_edge.StartPosition = new PointF(
                start_edge.EndPosition.X - this.node_diameter,
                start_edge.EndPosition.Y);

            this.Graph.Edges.Add(start_edge);
        }
開發者ID:mqrelly,項目名稱:Syntan,代碼行數:101,代碼來源:DfsmView.cs

示例2: AngleBetween

 public static float AngleBetween(this PointF p1, PointF p2)
 {
     float dotproduct = p1.Dotproduct(p2);
     return dotproduct / p1.Length() / p2.Length();
 }
開發者ID:huangfuyang,項目名稱:Sign-Language-with-Kinect,代碼行數:5,代碼來源:PointHelper.cs


注:本文中的System.Drawing.PointF.Length方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。