C# - 将 PointF 转换为 Point
C# - Convert PointF to Point
我认为这是一个简单的问题,但我想不通。
//verifica qual o ponto mais proximo do centroide_circulo
PointF ponto_mais_proximo = pontos_medios.OrderBy(x => Math.Pow(x.X - centroide_circulo.X, 2) + Math.Pow(x.Y - centroide_circulo.Y, 2)).FirstOrDefault();
LineSegment2D linha_circulo_vertice = new LineSegment2D(centroide_circulo, ponto_mais_proximo);
cannot convert from 'System.Drawing.PointF' to 'System.Drawing.Point'
我的问题是如何转换它? ponto_mais_proximo第一行代码需要PointF。
最简单的方法是使用 Point.Round()
:
LineSegment2D linha_circulo_vertice =
new LineSegment2D(centroide_circulo, Point.Round(ponto_mais_proximo));
Converts the specified PointF to a Point object by rounding the Point values to the nearest integer.
我认为这是一个简单的问题,但我想不通。
//verifica qual o ponto mais proximo do centroide_circulo
PointF ponto_mais_proximo = pontos_medios.OrderBy(x => Math.Pow(x.X - centroide_circulo.X, 2) + Math.Pow(x.Y - centroide_circulo.Y, 2)).FirstOrDefault();
LineSegment2D linha_circulo_vertice = new LineSegment2D(centroide_circulo, ponto_mais_proximo);
cannot convert from 'System.Drawing.PointF' to 'System.Drawing.Point'
我的问题是如何转换它? ponto_mais_proximo第一行代码需要PointF。
最简单的方法是使用 Point.Round()
:
LineSegment2D linha_circulo_vertice =
new LineSegment2D(centroide_circulo, Point.Round(ponto_mais_proximo));
Converts the specified PointF to a Point object by rounding the Point values to the nearest integer.