本文整理汇总了C#中System.Drawing.PointF.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# PointF.CopyTo方法的具体用法?C# PointF.CopyTo怎么用?C# PointF.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.PointF
的用法示例。
在下文中一共展示了PointF.CopyTo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: concatenar
private PointF[] concatenar(PointF[] trozo1, PointF[] trozo2)
{
PointF[] vectorSuma = new PointF[trozo1.Length + trozo2.Length];
trozo1.CopyTo(vectorSuma, 0);
trozo2.CopyTo(vectorSuma, trozo1.Length);
return vectorSuma;
}
示例2: GetConvexHull
/// <summary>
/// Vytvoří konvexní obal z daných vertexů
/// </summary>
/// <param name="Vertices">Vertexy</param>
/// <returns>Pole vertexů tvořící konvexní obal</returns>
public static PointF[] GetConvexHull(PointF[] Vertices)
{
int n = Vertices.Length, k = 0;
PointF[] Hull = new PointF[2 * n],Sorted = new PointF[Vertices.Length];
Vertices.CopyTo(Sorted, 0);
Array.Sort<PointF>(Sorted, new Comparison<PointF>(LexicalPointComparison));
for (int i = 0; i < n; i++)
{
while (k >= 2 && zc((PointF)Hull[k - 2],(PointF)Hull[k - 1], Sorted[i]) <= 0) k--;
Hull[k++] = Sorted[i];
}
for (int i = n - 2, t = k + 1; i >= 0; i--)
{
while (k >= t && zc((PointF)Hull[k - 2], (PointF)Hull[k - 1], Sorted[i]) <= 0) k--;
Hull[k++] = Sorted[i];
}
PointF[] Ret = new PointF[k-1];
for (int i = 0; i < k - 1; i++)
{
Ret[i].X = Hull[i].X;
Ret[i].Y = Hull[i].Y;
}
return Ret;
}
示例3: GeometryDescriptor
/// <summary>
/// Výchozí konstruktor
/// </summary>
public GeometryDescriptor(PointF[] Default)
{
Centroid = new PointF(0, 0);
Height = Width = Depth = FrontalArea = 0;
DefaultVertices = new PointF[Default.Length];
Default.CopyTo(DefaultVertices, 0);
}
示例4: Geometry
/// <summary>
/// Vytvoří fyzický model tělesa jako objekt z daných vertexů
/// </summary>
/// <param name="Vertices">Vertexy tělesa</param>
/// <param name="InitPosition">Počáteční poloha tělesa</param>
/// <param name="COG">Těžiště tělesa</param>
public Geometry(PointF[] Vertices,PointF InitPosition, PointF? COG)
{
if (Vertices == null || Vertices.Length < 3) throw new ArgumentException();
surf = vol = angle = 0;
scale = 1.0f;
desc = AnalyzeVertexGroup(Vertices);
geom = new PointF[Vertices.Length];
Vertices.CopyTo(geom, 0);
if (COG.HasValue)
center = (Vector)COG;
else center = (Vector)desc.Centroid;
Nail = (Vector)InitPosition;
Position = (Vector)InitPosition;
}
示例5: InsertPoints
/// <summary>
/// Определить отрисовываемые точки
/// </summary>
/// <param name="pts"></param>
public void InsertPoints(PointF[] pts)
{
points = new PointF[pts.Length];
pts.CopyTo(points, 0);
}
示例6: FillPoints
public static PointF[] FillPoints(PointF[] sourcePoints, float stepDistance)
{
if (sourcePoints.Length < 2)
{
PointF[] retArray = new PointF[sourcePoints.Length];
sourcePoints.CopyTo(retArray, 0);
return retArray;
}
List<PointF> result = new List<PointF>(sourcePoints.Length);
PointF lastPoint = sourcePoints[0];
int i = 1;
result.Add(lastPoint);
while (i < sourcePoints.Length)
{
float dist = Distance(lastPoint, sourcePoints[i]);
// point is within the proper distance
if (dist <= stepDistance)
{
result.Add(sourcePoints[i]);
lastPoint = sourcePoints[i];
i++;
}
else
{
// slope between lastPoint and sourcePoints[i]
float vX = (sourcePoints[i].X - lastPoint.X) / dist;
float vY = (sourcePoints[i].Y - lastPoint.Y) / dist;
PointF newPt = new PointF(lastPoint.X + vX * stepDistance, lastPoint.Y + vY * stepDistance);
result.Add(newPt);
lastPoint = newPt;
}
}
return result.ToArray();
}
示例7: TestRotationMatrix2D
public void TestRotationMatrix2D()
{
double angle = 32;
Size size = new Size(960, 480);
PointF center = new PointF(size.Width * 0.5f, size.Height * 0.5f);
using (RotationMatrix2D rotationMatrix = new RotationMatrix2D(center, -angle, 1))
{
PointF[] corners = new PointF[] {
new PointF(0, 0),
new PointF(size.Width - 1, 0),
new PointF(size.Width - 1, size.Height - 1),
new PointF(0, size.Height - 1)};
PointF[] oldCorners = new PointF[corners.Length];
corners.CopyTo(oldCorners, 0);
rotationMatrix.RotatePoints(corners);
Mat transformation = CvInvoke.EstimateRigidTransform(oldCorners, corners, true);
Matrix<double> delta = new Matrix<double>(transformation.Size);
CvInvoke.AbsDiff(rotationMatrix, transformation, delta);
double min = 0, max = 0;
Point minLoc = new Point(), maxLoc = new Point();
CvInvoke.MinMaxLoc(delta, ref min, ref max, ref minLoc, ref maxLoc, null);
double min2, max2;
int[] minLoc2 = new int[2], maxLoc2 = new int[2];
CvInvoke.MinMaxIdx(delta, out min2, out max2, minLoc2, maxLoc2, null);
EmguAssert.IsTrue(min == min2);
EmguAssert.IsTrue(max == max2);
EmguAssert.IsTrue(minLoc.X == minLoc2[1]);
EmguAssert.IsTrue(minLoc.Y == minLoc2[0]);
EmguAssert.IsTrue(maxLoc.X == maxLoc2[1]);
EmguAssert.IsTrue(maxLoc.Y == maxLoc2[0]);
EmguAssert.IsTrue(max < 1.0e-4, String.Format("Error {0} is too large. Expected to be less than 1.0e-4", max));
}
}
示例8: FindCentroid
//Code adapted and improved from: http://blog.csharphelper.com/2010/01/04/find-a-polygons-centroid-in-c.aspx
// refer to wikipedia for math formulas centroid of polygon http://en.wikipedia.org/wiki/Centroid
private PointF FindCentroid(PointF[] Hull)
{
// Add the first point at the end of the array.
int num_points = Hull.Length;
PointF[] pts = new PointF[num_points + 1];
Hull.CopyTo(pts, 0);
pts[num_points] = Hull[0];
// Find the centroid.
float X = 0;
float Y = 0;
float second_factor;
for (int i = 0; i < num_points; i++)
{
second_factor = pts[i].X * pts[i + 1].Y - pts[i + 1].X * pts[i].Y;
X += (pts[i].X + pts[i + 1].X) * second_factor;
Y += (pts[i].Y + pts[i + 1].Y) * second_factor;
}
// Divide by 6 times the polygon's area.
float polygon_area = Math.Abs(SignedPolygonArea(Hull));
X /= (6 * polygon_area);
Y /= (6 * polygon_area);
// If the values are negative, the polygon is
// oriented counterclockwise so reverse the signs.
if (X < 0)
{
X = -X;
Y = -Y;
}
return new PointF(X, Y);
}
示例9: OnMouseDown
//.........这里部分代码省略.........
}
case PolyOperate.MovePath:
{
goto Label_05F5;
}
case PolyOperate.MovePoint:
{
PointF tf3;
this.nextPoint = tf3 = PointF.Empty;
this.prePoint = tf3;
if ((this.moveindex < 0) || (this.moveindex >= this.points.Length))
{
goto Label_05F5;
}
flag3 = this.graph is Polygon;
if ((this.moveindex - 1) < 0)
{
if ((this.points.Length >= 3) && flag3)
{
this.prePoint = this.points[this.points.Length - 1];
}
goto Label_042C;
}
this.prePoint = this.points[this.moveindex - 1];
goto Label_042C;
}
case PolyOperate.Del:
{
if ((this.moveindex >= 0) && (this.moveindex < this.points.Length))
{
ArrayList list1 = new ArrayList(this.points);
list1.RemoveAt(this.moveindex);
this.points = new PointF[list1.Count];
list1.CopyTo(this.points);
Matrix matrix1 = this.graph.GraphTransform.Matrix.Clone();
matrix1.Invert();
if (this.points.Length > 0)
{
matrix1.TransformPoints(this.points);
}
}
goto Label_05F5;
}
case PolyOperate.Break://��·�Ͽ�
{
if ((this.moveindex > 0) && (this.moveindex < this.points.Length - 1))
{
ArrayList list1 = new ArrayList(this.points);
PointF[] points2 = new PointF[this.points.Length - moveindex];
this.points = new PointF[moveindex + 1];
list1.CopyTo(0, this.points, 0, this.moveindex + 1);
list1.CopyTo(moveindex, points2, 0, list1.Count - moveindex);
Matrix matrix1 = this.graph.GraphTransform.Matrix.Clone();
matrix1.Invert();
if (points2.Length > 0)
{
matrix1.TransformPoints(points2);
SvgElement copyEelement = (this.graph as XmlNode).CloneNode(true) as SvgElement;
IGraph graph1 = this.graph;
copyEelement.SetAttribute("info-name", ((SvgElement)graph1).GetAttribute("info-name") + "-2");
((SvgElement)graph).SetAttribute("info-name", ((SvgElement)graph1).GetAttribute("info-name") + "-1");
copyEelement = this.mouseAreaControl.PicturePanel.AddElement(copyEelement);
this.mouseAreaControl.SVGDocument.CurrentElement = graph1 as SvgElement;
示例10: AddBezierSpline
private static void AddBezierSpline(PointF[] points, GraphicsPath path)
{
PointF[] tempPoints = new PointF[points.Length];
float width = (float)Math.Sqrt(
Math.Pow(points[0].X - points[points.Length-1].X , 2) +
Math.Pow(points[0].Y - points[points.Length-1].Y , 2));
float step = 1.0f/width;
float t = 0;
PointF current = points[0];
PointF old = points[0];
while(t <= 1.0f) {
points.CopyTo(tempPoints, 0);
for(int j = points.Length - 1; j>0 ; j--) {
for(int i = 0; i<j; i++) {
tempPoints[i].X = (1.0f-t)*tempPoints[i].X + t*tempPoints[i+1].X;
tempPoints[i].Y = (1.0f-t)*tempPoints[i].Y + t*tempPoints[i+1].Y;
}
}
current = tempPoints[0];
path.AddLine(old, current);
old = current;
t+=step;
}
path.AddLine(current, points[points.Length -1]);
}
示例11: SplinePoint
private static PointF SplinePoint(PointF[] points, double t)
{
PointF[] p = new PointF[points.Length];
points.CopyTo(p, 0);
while (p.Length > 1)
{
p = SplineFunctionOo(p, t);
}
return p[0];
}
示例12: CalcSpline
//.........这里部分代码省略.........
int precision = (filecount - 1) / (Pcount - 1);
int npp = (Pcount * precision); // number of points used for drawing
for (int i = 0; i < Pcount; i++)
{
xCoords[i] = points[i].X;
yCoords[i] = points[i].Y;
}
float[] a = new float[Pcount];
float x1;
float x2;
float[] h = new float[Pcount];
for (int i = 1; i < Pcount; i++)
{
h[i] = xCoords[i] - xCoords[i - 1];
}
float[] sub = new float[Pcount - 1];
float[] diag = new float[Pcount - 1];
float[] sup = new float[Pcount - 1];
for (int i = 1; i < Pcount - 1; i++)
{
diag[i] = (h[i] + h[i + 1]) / 3;
sup[i] = h[i + 1] / 6;
sub[i] = h[i] / 6;
a[i] = (yCoords[i + 1] - yCoords[i]) / h[i + 1] - (yCoords[i] - yCoords[i - 1]) / h[i];
}
solveTridiag(sub, diag, sup, ref a, Pcount - 2);
int count = 1;
output[0].X = points[0].X;
output[0].Y = points[0].Y;
for (int i = 1; i < Pcount; i++)
{
for (int j = 1; j <= precision; j++)
{
x1 = (h[i] * j) / precision;
x2 = h[i] - x1;
y = ((-a[i - 1] / 6 * (x2 + h[i]) * x1 + yCoords[i - 1]) * x2 +
(-a[i] / 6 * (x1 + h[i]) * x2 + yCoords[i]) * x1) / h[i];
x = xCoords[i - 1] + x1;
output[count].X = x;
output[count].Y = y;
if (output[count].Y < minVal) { output[count].Y = minVal; }
else if (output[count].Y > maxVal) { output[count].Y = maxVal; }
if (start > 0 && i <= start)
{
output[count].X = points[i].X;
output[count].Y = points[i].Y;
if (output[count].Y < minVal) { output[count].Y = minVal; }
else if (output[count].Y > maxVal) { output[count].Y = maxVal; }
}
count++;
}
}
//interpolate if there isn´t the same amount of points and filecount:
if (npp - filecount - precision != 0)
{
int part = filecount / (Math.Abs(npp - filecount - precision) + 1);
PointF[] tmpOut = new PointF[output.Length];
output.CopyTo(tmpOut, 0);
int nr = 0;
for (int i = 0; i < filecount; i++)
{
if (i == part * (nr + 1) && nr < Math.Abs(npp - filecount - precision))
{
output[i].X = tmpOut[i - nr].X + ((tmpOut[i - nr].X - tmpOut[i - nr + 1].X) / 2);
output[i].Y = tmpOut[i - nr].Y + ((tmpOut[i - nr].Y - tmpOut[i - nr + 1].Y) / 2);
nr++;
}
else if (nr < Math.Abs(npp - filecount - precision))
{
output[i] = tmpOut[i - nr];
}
else
{
output[i] = tmpOut[i - nr + 1];
}
}
}
}
else
{
for (int i = 0; i < filecount; i++)
{
output[i].Y = points[0].Y;
output[i].X = points[0].X;
}
}
}