本文整理汇总了C#中System.Point.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Point.Clone方法的具体用法?C# Point.Clone怎么用?C# Point.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Point
的用法示例。
在下文中一共展示了Point.Clone方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Point
public void Point()
{
//Do various Point method calls to cover the point class with sufficient testing
Point p0 = new Point();
Point p1 = new Point(0,0);
Point p2 = new Point(450, 120);
Assert.IsTrue(p0.IsEmpty());
Assert.IsFalse(p1.IsEmpty());
Assert.AreNotEqual(p0, p1);
Assert.AreEqual(450, p2.X);
Assert.AreEqual(120, p2.Y);
Assert.AreNotSame(p2.Clone(), p2);
p0 = p2.Clone();
p0.X += 100; p0.Y = 150;
p0[0] += p0[1];
Assert.AreEqual(new Point(700, 150),p0);
Assert.AreEqual(p2, p2.GetBoundingBox().Min);
Assert.AreEqual(p2, p2.GetBoundingBox().Max);
Assert.IsTrue(p2.IsSimple());
Assert.IsFalse(p2.IsEmpty());
Assert.AreEqual(2, p2.NumOrdinates);
Assert.AreEqual(new Point(400, 100), p2 + new Point(-50, -20));
Assert.AreEqual(new Point(500, 100), p2 - new Point(-50, 20));
Assert.AreEqual(new Point(900, 240), p2 * 2);
Assert.AreEqual(0, p2.Dimension);
Assert.AreEqual(450, p2[0]);
Assert.AreEqual(120, p2[1]);
Assert.IsNull(p2.Boundary());
Assert.AreEqual(p2.X.GetHashCode() ^ p2.Y.GetHashCode() ^ p2.IsEmpty().GetHashCode(), p2.GetHashCode());
Assert.Greater(p2.CompareTo(p1), 0);
Assert.Less(p1.CompareTo(p2), 0);
Assert.AreEqual(p2.CompareTo(new Point(450,120)), 0);
}
示例2: AABB
private double _yw; //y width
#endregion Fields
#region Constructors
public AABB(Point pos, double xw, double yw)
{
_pos = pos;
_oldPos = (Point)pos.Clone();
_xw = xw;
_yw = yw;
}
示例3: Main
public static void Main(string[] args)
{
var point = new Point(1, 2);
var point2 = point.Clone() as Point;
point.Move(2, 3);
point.Print();
point2.Print();
var personWithChildren = new PersonWithChildren("John", "Doe");
Console.WriteLine(personWithChildren.Name);
personWithChildren.Children.Add(new PersonWithChildren("John", "Little"));
Console.WriteLine(personWithChildren["John Little"].Name);
}
示例4: raycast
public Point raycast(Point start, Point goal)
{
List<Point> pointsOnLine = Bresenham.getCellsOnLine(start, goal);
Point hitPoint = (Point) start.Clone();
foreach(Point p in pointsOnLine) {
AStarCell cell = map.getCell(p.x, p.y);
if(cell == null || cell.isObstacle()) {
break;
} else {
hitPoint = p;
}
}
return hitPoint;
}
示例5: MoveNodePositions
/// <summary>
/// Lets the tree grow according to the ideal distances.
/// </summary>
/// <param name="treeEdges"></param>
/// <param name="nodePositions"></param>
/// <param name="rootNodeId"></param>
static void MoveNodePositions(List<Tuple<int, int, double, double, double>> treeEdges, Point[] nodePositions,
int rootNodeId) {
var posOld = (Point[]) nodePositions.Clone();
var visited = new Set<int>();
visited.Insert(rootNodeId);
for (int i = 0; i < treeEdges.Count; i++) {
var tupleEdge = treeEdges[i];
if (visited.Contains(tupleEdge.Item1))
MoveUpperSite(tupleEdge, nodePositions, posOld, visited);
else {
Debug.Assert(visited.Contains(tupleEdge.Item2));
MoveLowerSite(tupleEdge, nodePositions, posOld, visited);
}
}
}
示例6: Transform
/// <summary>
/// Transforms a coordinate point. The passed parameter point should not be modified.
/// </summary>
/// <param name="point"></param>
/// <returns></returns>
public override Point Transform(Point point)
{
Point pOut = point.Clone() as Point;
pOut.X /= SourceGCS.AngularUnit.RadiansPerUnit;
pOut.X -= SourceGCS.PrimeMeridian.Longitude/SourceGCS.PrimeMeridian.AngularUnit.RadiansPerUnit;
pOut.X += TargetGCS.PrimeMeridian.Longitude/TargetGCS.PrimeMeridian.AngularUnit.RadiansPerUnit;
pOut.X *= SourceGCS.AngularUnit.RadiansPerUnit;
return pOut;
}
示例7: SetVertices
/// <summary>
/// Sets the vertices making a copy of the specified array.
/// The polygon vertices must be clock-wise and not overlap.
/// </summary>
/// <param name="vertices">The vertices.</param>
/// <exception cref="ArgumentNullException">
/// Vertices cannot be null.
/// </exception>
public void SetVertices(Point[] vertices)
{
if (vertices == null)
{
throw new ArgumentNullException("vertices");
}
this.vertices = vertices.Clone() as Point[];
this.UpdateArea();
}
示例8: Rectilinearise
/// <summary>
/// sometimes we have very small mistakes in the positions that have to be fixed
/// </summary>
/// <returns></returns>
static Point Rectilinearise(Point a, Point b) {
#if SHARPKIT //https://code.google.com/p/sharpkit/issues/detail?id=369
b = b.Clone();
#endif
if (a.X != b.X && a.Y != b.Y) {
var dx = Math.Abs(a.X - b.X);
var dy = Math.Abs(a.Y - b.Y);
if (dx < dy)
b.X = a.X;
else
b.Y = a.Y;
}
return b;
}