本文整理汇总了C#中Point.Count方法的典型用法代码示例。如果您正苦于以下问题:C# Point.Count方法的具体用法?C# Point.Count怎么用?C# Point.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point.Count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getContourCurvatureIndices
public static int[] getContourCurvatureIndices(Contour<Point> contour, Point[] curvePoints)
{
int[] curveIndices = new int[curvePoints.Count()];
for (int j = 0; j < curvePoints.Count(); j++)
{
curveIndices[j] = Array.IndexOf(contour.ToArray(), curvePoints[j]);
Console.WriteLine(curveIndices[j] + ":" + curvePoints[j].ToString());
}
return curveIndices;
}
示例2: getStarPoints
Point[] getStarPoints()
{
Point[] starPoints = new Point[5];
for (int i = 0; i < starPoints.Count(); i++)
{
double x, y;
x = (radius * Math.Cos(-Math.PI / 2 - i * 2 * Math.PI / starPoints.Count()));
y = (radius * Math.Sin(-Math.PI / 2 - i * 2 * Math.PI / starPoints.Count()));
starPoints[i] = new Point((int)x, (int)y);
}
return starPoints;
}
示例3: getLinearRegressionData
public static double[] getLinearRegressionData(Point[] dataPoints)
{
int sumX = 0;
int sumY = 0;
int sumXY = 0;
int sumX2 = 0;
int n = dataPoints.Count();
// x will be equal to the last Point.X, find Point.Y
foreach (Point p in dataPoints)
{
sumX += p.X;
sumY += p.Y;
sumXY += p.X * p.Y;
sumX2 += p.X * p.X;
}
// intercept
double a = ((sumY * sumX2) - (sumX * sumXY)) / ((n * sumX2) - (sumX * sumX));
// slope
double b = ((n * sumXY) - (sumX * sumY)) / ((n * sumX2) - (sumX * sumX));
return new double[2]{a, b};
}
示例4: calculateMedianYCoordinate
private static int calculateMedianYCoordinate(Point[] locations)
{
int[] orderedYCoordinatesOfLocations = locations.Select(location => location.Y).OrderBy(yCoordinate => yCoordinate).ToArray();
int medianIndex = locations.Count() / 2;
int medianY = orderedYCoordinatesOfLocations[medianIndex];
return medianY;
}
示例5: Polyline
/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="points">通過点</param>
public Polyline(Point[] points)
{
if (points.Count() < 2)
{
throw new ArgumentOutOfRangeException("2点以上必要です。");
}
Points = points;
}
示例6: DrawPolygon
internal void DrawPolygon(Color color, Point[] vertices)
{
StreamGeometry streamGeometry = new StreamGeometry();
using (StreamGeometryContext geometryContext = streamGeometry.Open())
{
geometryContext.BeginFigure(vertices[0], true, true); //TODO check if this can be made in a more safe way the [0]
PointCollection points = new PointCollection();
for (int i = 1; i < vertices.Count();i++)
{
points.Add(vertices[i]);
}
geometryContext.PolyLineTo(points, true, true);
}
// Draw the polygon visual
DrawingContext drawingContext = drawingVisual.RenderOpen();
drawingContext.DrawGeometry(mySolidColorBrush, null, streamGeometry);
drawingContext.Close();
image.Render(drawingVisual);
}
示例7: CreateVertexColoredMesh
private static void CreateVertexColoredMesh(Point[] vertices, Color[] colors, IRenderPackage package, TessellationParameters parameters)
{
package.RequiresPerVertexColoration = true;
for (var i = 0; i <= vertices.Count()-3; i+=3)
{
var ptA = vertices[i];
var ptB = vertices[i+1];
var ptC = vertices[i+2];
if (ptA.IsAlmostEqualTo(ptB) ||
ptB.IsAlmostEqualTo(ptC) ||
ptA.IsAlmostEqualTo(ptC))
{
continue;
}
var alongLine = false;
using (var l = Line.ByStartPointEndPoint(ptA, ptC))
{
alongLine = ptB.DistanceTo(l) < 0.00001;
}
if (alongLine)
{
continue;
}
var cA = colors[i];
var cB = colors[i+1];
var cC = colors[i+2];
var s1 = ptB.AsVector().Subtract(ptA.AsVector()).Normalized();
var s2 = ptC.AsVector().Subtract(ptA.AsVector()).Normalized();
var n = s1.Cross(s2);
package.AddTriangleVertex(ptA.X, ptA.Y, ptA.Z);
package.AddTriangleVertexNormal(n.X, n.Y, n.Z);
package.AddTriangleVertexColor(cA.Red, cA.Green, cA.Blue, cA.Alpha);
package.AddTriangleVertexUV(0, 0);
package.AddTriangleVertex(ptB.X, ptB.Y, ptB.Z);
package.AddTriangleVertexNormal(n.X, n.Y, n.Z);
package.AddTriangleVertexColor(cB.Red, cB.Green, cB.Blue, cB.Alpha);
package.AddTriangleVertexUV(0, 0);
package.AddTriangleVertex(ptC.X, ptC.Y, ptC.Z);
package.AddTriangleVertexNormal(n.X, n.Y, n.Z);
package.AddTriangleVertexColor(cC.Red, cC.Green, cC.Blue, cC.Alpha);
package.AddTriangleVertexUV(0, 0);
}
}
示例8: convertToIntPoint
private List<AForge.IntPoint> convertToIntPoint(Point[] systemPoints)
{
List<AForge.IntPoint> intPoints = new List<AForge.IntPoint>(systemPoints.Count());
foreach (Point p in systemPoints)
{
intPoints.Add(new AForge.IntPoint(p.X, p.Y));
}
return intPoints;
}
示例9: DetectFingers
//.........这里部分代码省略.........
stopTracking = true;
fistClosed = false;
}
if (shouldControlMouse)
{
//clickMouse(fistClosed);
}
// Get the convexity defects from the contour
stopwatch.Restart();
Seq<Emgu.CV.Structure.MCvConvexityDefect> contourDefects = contours.GetConvexityDefacts(storage1, Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE);
stopwatch.Stop();
//Console.WriteLine(Math.Round(1000.0 * (double)stopwatch.ElapsedTicks / Stopwatch.Frequency, 4) + ", GetConvexityDefacts()");
// Draw the polygon that was converted from the contour
/*
for (int i = 0; i < polygon.Length; i++)
{
if (i == polygon.Length - 1)
g.DrawLine((new Pen(Brushes.Blue))), polygon[i], polygon[0]);
else
g.DrawLine((new Pen(Brushes.Blue))), polygon[i], polygon[i + 1]);
}
*/
// Draw more polygon stuff ??
foreach (Point p in poly)
{
significantPts.Add(new KeyValuePair<Point, bool>(p, false));
//g.DrawLine((new Pen(Brushes.Blue))), p.X, p.Y, p.X + 10, p.Y + 10);
}
int fingertips = 0;
Point[] defectPoints = new Point[contourDefects.Count()];
Point[] fingerPoints = new Point[contourDefects.Count()];
Point[] endPoints = new Point[contourDefects.Count()];
int count = 0;
int fingerCount = 0;
///--- DEFECTS
foreach (MCvConvexityDefect defect in contourDefects)
{
// Construct a triangle from the defect
Triangle2DF defectTriangle = new Triangle2DF(defect.DepthPoint, defect.StartPoint, defect.EndPoint);
// Check that the area of the defect triangle is between 1% and 33% of the contour area
if (defectTriangle.Area > contours.Area / 100 && defectTriangle.Area < contours.Area / 3)
{
///---
endPoints[count] = defect.EndPoint;
defectPoints[count] = defect.DepthPoint;
count++;
// Get the angle of the defect
double defectAngle = getVertexAngle(defect.DepthPoint, defect.StartPoint, defect.EndPoint);
if (defectAngle < 100 && !defect.EndPoint.Equals(Point.Empty))
fingerPoints[fingerCount++] = defect.EndPoint;
///---
//g.DrawPolygon(new Pen(Brushes.Pink), defectTriangle.GetVertices());
significantPts.Add(new KeyValuePair<Point, bool>(defect.DepthPoint, true));
g.DrawLine((new Pen(Brushes.Green)), defect.StartPoint, defect.EndPoint);
g.DrawLine((new Pen(Brushes.Red)), defect.DepthPoint, defect.StartPoint);
g.DrawLine((new Pen(Brushes.Blue)), defect.DepthPoint, defect.EndPoint);
// Draw the depth point of the defects (hull point)
示例10: getCentroid
private Point getCentroid(Point[] points)
{
int x = 0;
int y = 0;
foreach (Point p in points)
{
x += p.X;
y += p.Y;
}
x /= points.Count();
y /= points.Count();
return new Point((int)x, (int)y);
}
示例11: ApplyAnimationToBezierSegments
internal static void ApplyAnimationToBezierSegments(Int32 index, Storyboard storyBoard, BezierSegment bezierSegment,
Point[] oldCtrlPoints, Point[] newCtrlPoints, PathFigure pathFigure, Point oldFirstPointOfBezierSeg,
Point newFirstPointOfBezierSeg)
{
if (index == 1)
{
PointAnimation pointAnimation = new PointAnimation()
{
From = oldFirstPointOfBezierSeg,
To = newFirstPointOfBezierSeg,
SpeedRatio = 2,
Duration = new Duration(new TimeSpan(0, 0, 1))
};
Storyboard.SetTarget(pointAnimation, pathFigure);
Storyboard.SetTargetProperty(pointAnimation, new PropertyPath("StartPoint"));
Storyboard.SetTargetName(pointAnimation, (String)pathFigure.GetValue(FrameworkElement.NameProperty));
storyBoard.Children.Add(pointAnimation);
#if WPF
pathFigure.BeginAnimation(PathFigure.StartPointProperty, pointAnimation);
#endif
}
// Animate control points
if (oldCtrlPoints != null && newCtrlPoints != null && oldCtrlPoints.Count() == 3 && newCtrlPoints.Count() == 3)
{
// Loop for 3 control points
for (int i = 0; i < 3; i++)
{
// Creates PointAnimation for each control points
if (!oldCtrlPoints[i].Equals(newCtrlPoints[i]))
{
PointAnimation pointAnimation = new PointAnimation()
{
From = oldCtrlPoints[i],
To = newCtrlPoints[i],
SpeedRatio = 2,
Duration = new Duration(new TimeSpan(0, 0, 1))
};
Storyboard.SetTarget(pointAnimation, bezierSegment);
Storyboard.SetTargetProperty(pointAnimation, new PropertyPath("Point" + (i + 1).ToString()));
Storyboard.SetTargetName(pointAnimation, (String)bezierSegment.GetValue(FrameworkElement.NameProperty));
storyBoard.Children.Add(pointAnimation);
#if WPF
switch(i)
{
case 0:
bezierSegment.BeginAnimation(BezierSegment.Point1Property, pointAnimation);
break;
case 1:
bezierSegment.BeginAnimation(BezierSegment.Point2Property, pointAnimation);
break;
case 2:
bezierSegment.BeginAnimation(BezierSegment.Point3Property, pointAnimation);
break;
}
#endif
}
}
}
}
示例12: polyHitTest
private bool polyHitTest(Point[] vertices, Point testPoint)
{
int i, j;
bool c = false;
for (i = 0, j = vertices.Count() - 1; i < vertices.Count(); j = i++)
{
if (((vertices[i].Y > testPoint.Y) != (vertices[j].Y > testPoint.Y)) &&
(testPoint.X < (vertices[j].X - vertices[i].X) * (testPoint.Y - vertices[i].Y) / (vertices[j].Y - vertices[i].Y) + vertices[i].X))
c = !c;
}
return c;
}
示例13: LoadPoints
//Allow the user to import an array of points to be used to draw a signature in the view, with new
//lines indicated by a PointF.Empty in the array.
public void LoadPoints (Point [] loadedPoints)
{
if (loadedPoints == null || loadedPoints.Count () == 0)
return;
var startIndex = 0;
var emptyIndex = loadedPoints.ToList ().IndexOf (new Point (-10000, -10000));
if (emptyIndex == -1)
emptyIndex = loadedPoints.Count ();
//Clear any existing paths or points.
strokes = new List<Stroke> ();
points = new List<Point []> ();
do {
//Create a new path and set the line options
currentStroke = new Stroke ();
currentStroke.DrawingAttributes.Color = strokeColor;
currentStroke.DrawingAttributes.Width = lineWidth;
currentStroke.DrawingAttributes.Height = lineWidth;
currentPoints = new List<Point> ();
//Move to the first point and add that point to the current_points array.
currentStroke.StylusPoints.Add (GetPoint (loadedPoints [startIndex]));
currentPoints.Add (loadedPoints [startIndex]);
//Iterate through the array until an empty point (or the end of the array) is reached,
//adding each point to the current_path and to the current_points array.
for (var i = startIndex + 1; i < emptyIndex; i++) {
currentStroke.StylusPoints.Add (GetPoint (loadedPoints [i]));
currentPoints.Add (loadedPoints [i]);
}
//Add the current_path and current_points list to their respective Lists before
//starting on the next line to be drawn.
strokes.Add (currentStroke);
points.Add (currentPoints.ToArray ());
//Obtain the indices for the next line to be drawn.
startIndex = emptyIndex + 1;
if (startIndex < loadedPoints.Count () - 1) {
emptyIndex = loadedPoints.ToList ().IndexOf (new Point (-10000, -10000), startIndex);
if (emptyIndex == -1)
emptyIndex = loadedPoints.Count ();
} else
emptyIndex = startIndex;
} while (startIndex < emptyIndex);
//Obtain the image for the imported signature and display it in the image view.
image.Source = GetImage (false);
//Display the clear button.
btnClear.Visibility = Visibility.Visible;
}
示例14: PolygonContainsPoint
public static bool PolygonContainsPoint(Point[] polygon, Point point)
{
bool result = false;
int j = polygon.Count() - 1;
for (int i = 0; i < polygon.Count(); i++)
{
if (polygon[i].Y < point.Y && polygon[j].Y >= point.Y || polygon[j].Y < point.Y && polygon[i].Y >= point.Y)
{
if (polygon[i].X + (point.Y - polygon[i].Y) / (polygon[j].Y - polygon[i].Y) * (polygon[j].X - polygon[i].X) < point.X)
{
result = !result;
}
}
j = i;
}
return result;
}
示例15: translateDataPoints
/**
* Translate the data points so as to set the start point as the origin.
* Probably unnecessary but easier to work with at this point
*/
public static Point[] translateDataPoints(Point[] dataPoints, Point startPoint)
{
Point[] translatedDataPoints = new Point[dataPoints.Count()];
for (int i = 0; i < dataPoints.Count(); i++)
{
Point p = dataPoints[i];
translatedDataPoints[i] = new Point(p.X - startPoint.X, p.Y - startPoint.Y);
}
return translatedDataPoints;
}