当前位置: 首页>>代码示例>>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;未经允许,请勿转载。