public void PoinsAreEquals() { DcPoint point1 = new DcPoint(new Point(100, 300), PointHash.CreateHash(1, 2)); DcPoint point2 = new DcPoint(new Point(100, 300), PointHash.CreateHash(2, 3)); Assert.IsTrue(point1.Equals(point2)); }
public void PoinsAreNotEquals() { DcPoint point1 = new DcPoint(new Point(100, 250), PointHash.CreateHash(1, 2)); DcPoint point2 = new DcPoint(new Point(100, 300), PointHash.CreateHash(2, 2)); Assert.IsFalse(point1.Equals(point2)); }
public void SetConstraint_Depended_Reference_Added_To_Active() { // Init IDictionary <int, DcPoint> pointCollection = new Dictionary <int, DcPoint>(); DcLineSegment lineSegment = new DcLineSegment(100, 100, 100, 200); PointManager.AddPrimitivePoints(pointCollection, lineSegment); DcPoint point = new DcPoint(100, 200, PointHash.CreateHash(1, 1)); // Action point = PointManager.SetConstraint(point, pointCollection); var ActiveHash = 0; foreach (var item in lineSegment.Points) { if (item.Value.X == 100 && item.Value.Y == 200) { ActiveHash = item.Key; } } DcPoint activePoint = pointCollection[ActiveHash]; var expected = point.GetHashCode(); var actual = activePoint.DependedHash; Assert.AreEqual(expected, actual); }
public void CreateHash_Test_2_348() { int expected = 2097500; var actual = PointHash.CreateHash(2, 348); Assert.AreEqual(expected, actual); }
public void CreateHash_Test_1_0() { int expected = 1048576; var actual = PointHash.CreateHash(1, 0); Assert.AreEqual(expected, actual); }
public void CreateHash_Test_0_1() { int expected = 1; var actual = PointHash.CreateHash(0, 1); Assert.AreEqual(expected, actual); }
/// <summary> /// /// </summary> /// <param name="originPoint"></param> /// <param name="length"></param> /// <param name="angle"></param> public DcLineSegment(Point originPoint, double length, double angle) { _x1 = originPoint.X; _y1 = originPoint.Y; while (angle >= 360) { angle -= 360; } while (angle <= -360) { angle += 360; } _angle = angle < 0 ? angle + 360 : angle; _length = length; if (angle == 0) { _x2 = _x1 + length; _y2 = _y1; } else if (angle == 180) { _x2 = _x1 - length; _y2 = _y1; } else if (angle == 90) { _x2 = _x1; _y2 = _y1 + length; } else if (angle == 270) { _x2 = _x1; _y2 = _y1 - length; } else { _x2 = _x1 + DcMath.Xoffset(length, angle); _y2 = _y1 + DcMath.Yoffset(length, angle); } _height = DcMath.GetHeight(Y1, Y2); _width = DcMath.GetWidth(X1, X2); _p1Hash = PointHash.CreateHash(1, _id); _p2Hash = PointHash.CreateHash(2, _id); _points = new Dictionary <int, Point>() { { _p1Hash, new Point(_x1, _y1) }, { _p2Hash, new Point(_x2, _y2) } }; }
public void SetConstraint_No_Active_References() { // Init IDictionary <int, DcPoint> pointCollection = new Dictionary <int, DcPoint>(); DcLineSegment lineSegment = new DcLineSegment(100, 100, 100, 200); PointManager.AddPrimitivePoints(pointCollection, lineSegment); DcPoint point = new DcPoint(110, 200, PointHash.CreateHash(1, 1)); // Action point = PointManager.SetConstraint(point, pointCollection); var expected = 0; var actual = point.ActiveHash; Assert.AreEqual(expected, actual); }
/// <summary> /// /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> public DcLineSegment(double x1, double y1, double x2, double y2) { _x1 = x1; _y1 = y1; _x2 = x2; _y2 = y2; _p1Hash = PointHash.CreateHash(1, _id); _p2Hash = PointHash.CreateHash(2, _id); _points = new Dictionary <int, Point>() { { _p1Hash, new Point(X1, Y1) }, { _p2Hash, new Point(X2, Y2) } }; _length = DcMath.GetDistance(X1, Y1, X2, Y2); _angle = DcMath.GetLineSegmentAngle(this); _height = DcMath.GetHeight(Y1, Y2); _width = DcMath.GetWidth(X1, X2); }