/// <summary>
 /// Constructs a new instance of <see cref="TrackableObjectChangedEventArgs"/> from the specified values.
 /// </summary>
 /// <param name="newPosition">The <see cref="NewPosition"/>.</param>
 /// <param name="oldPosition">The <see cref="OldPosition"/>.</param>
 /// <param name="newSize">The <see cref="NewSize"/>.</param>
 /// <param name="oldSize">The <see cref="OldSize"/>.</param>
 public TrackableObjectChangedEventArgs(PointF newPosition, PointF oldPosition, SizeF newSize, SizeF oldSize)
 {
     NewPosition = newPosition;
     OldPosition = oldPosition;
     NewSize = newSize;
     OldSize = oldSize;
 }
Beispiel #2
0
        public void CreatePointFStructure_0_1f_1_56f()
        {
            var expectedX = 0.1f;
            var expectedY = 1.56f;

            PointF point = new PointF(0.1f, 1.56f);

            Assert.AreEqual(expectedX, point.X);
            Assert.AreEqual(expectedY, point.Y);
        }
Beispiel #3
0
        public void CreatePointFStructure_0_0f_0_0f()
        {
            var expectedX = 0.0f;
            var expectedY = 0.0f;

            PointF point = new PointF(0.0f, 0.0f);

            Assert.AreEqual(expectedX, point.X);
            Assert.AreEqual(expectedY, point.Y);
        }
Beispiel #4
0
        public void Round_0_1f_1_56f()
        {
            var expectedX = 0x00;
            var expectedY = 0x02;

            PointF point = new PointF(0.1f, 1.56f);
            Point rounded = Point.Round(point);

            Assert.AreEqual(expectedX, rounded.X);
            Assert.AreEqual(expectedY, rounded.Y);
        }
Beispiel #5
0
        public void Intersect_OnePositive_OneNegative_Line_0_0_2_2_Line_2_0_0_2()
        {
            // \  /
            //  \/
            //  /\
            // /  \
            var expected = new PointF(1f, 1f);
            var l1 = new Line(new Point(0, 0), new Point(2, 2));
            var l2 = new Line(new Point(2, 0), new Point(0, 2));

            var actual = Line.Intersect(l1, l2).Value;

            Assert.AreEqual(expected, actual);
        }
Beispiel #6
0
        public void Intersect_OneHorizontal_OnePositive_Line_0_0_2_2_Line_0_1_2_1()
        {
            //    /
            // __/_
            //  /
            // /
            var expected = new PointF(1f, 1f);
            var l1 = new Line(new Point(0, 0), new Point(2, 2));
            var l2 = new Line(new Point(0, 1), new Point(2, 1));

            var actual = Line.Intersect(l1, l2).Value;

            Assert.AreEqual(expected, actual);
        }
Beispiel #7
0
        public void Intersect_OneVertical_OnePositive_Line_0_0_2_2_Line_1_0_1_2()
        {
            //   |/
            //   |
            //  /|
            // / |
            var expected = new PointF(1f, 1f);
            var l1 = new Line(new Point(0, 0), new Point(2, 2));
            var l2 = new Line(new Point(1, 0), new Point(1, 2));

            var actual = Line.Intersect(l1, l2).Value;

            Assert.AreEqual(expected, actual);
        }
Beispiel #8
0
        public void Intersect_BothPositive_Line_0_0_2_2_Line_1_0_2_2()
        {
            //   _/
            // _//
            //  /
            // /
            var expected = new PointF(2f, 2f);
            var l1 = new Line(new Point(0, 0), new Point(2, 2));
            var l2 = new Line(new Point(1, 0), new Point(2, 2));

            var actual = Line.Intersect(l1, l2);

            Assert.AreEqual(expected, actual);
        }
Beispiel #9
0
 /// <summary>
 /// Offsets a <see cref="PointF"/> by the specified <see cref="SizeF"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointF"/> that should be offset.</param>
 /// <param name="sz">The <see cref="SizeF"/> to offset by.</param>
 /// <returns>A new <see cref="PointF"/> that has been offset.</returns>
 public static PointF Add(PointF pt, SizeF sz) => pt + sz;
Beispiel #10
0
 /// <summary>
 /// Updates the <see cref="Position"/> of the current <see cref="Camera"/> instance to the value specified.
 /// </summary>
 /// <param name="position">A <see cref="PointF"/> representing the new <see cref="Position"/> of the <see cref="Camera"/>.</param>
 public void SetPosition(PointF position)
 {
     Position = position;
 }
Beispiel #11
0
 public bool WithinY(PointF pt) => (pt.Y >= Start.Y && pt.Y <= End.Y) || (pt.Y <= Start.Y && pt.Y >= End.Y);
Beispiel #12
0
 /// <summary>
 /// Determines if the <see cref="Bounds"/> contains the specified <see cref="PointF"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointF"/> to test.</param>
 /// <returns>True if the <see cref="PointF"/> fits in the current <see cref="Bounds"/>.</returns>
 /// <remarks>
 /// If it is already know that the <see cref="PointF"/> fits on the <see cref="Line"/> at <b>some</b> location, then this is an inexpensive operation to see if the <see cref="PointF"/> is within the current <see cref="Line"/> segment.
 /// </remarks>
 public bool RectContainsPoint(PointF pt) => WithinX(pt) && WithinY(pt);
Beispiel #13
0
 /// <summary>
 /// Constructs a new <see cref="PointShort"/> from the specified <see cref="PointF"/> by rounding all values down to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded down.</param>
 /// <returns>The <see cref="PointShort"/> representing the rounded <see cref="PointF"/>.</returns>
 public static PointShort Truncate(PointF value) => new PointShort((short)(value.X), (short)(value.Y));
Beispiel #14
0
 /// <summary>
 /// Constructs a new <see cref="PointShort"/> from the specified <see cref="PointF"/> by rounding all float values up to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded up.</param>
 /// <returns>The <see cref="PointShort"/> representing the rounded <see cref="PointF"/>.</returns>
 public static PointShort Ceiling(PointF value) => new PointShort((short)Math.Ceiling(value.X), (short)Math.Ceiling(value.Y));
Beispiel #15
0
        public void Truncate_0_1f_1_56f()
        {
            var expectedX = 0x00;
            var expectedY = 0x01;

            PointF point = new PointF(0.1f, 1.56f);
            Point rounded = Point.Truncate(point);

            Assert.AreEqual(expectedX, rounded.X);
            Assert.AreEqual(expectedY, rounded.Y);
        }
Beispiel #16
0
 /// <summary>
 /// Constructs a new <see cref="Point"/> from the specified <see cref="PointF"/> by rounding all values to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded.</param>
 /// <returns>The <see cref="Point"/> representing the rounded <see cref="PointF"/>.</returns>
 public static Point Round(PointF value) => new Point((int)Math.Round(value.X), (int)Math.Round(value.Y));
Beispiel #17
0
 /// <summary>
 /// Constructs a new <see cref="Point"/> from the specified <see cref="PointF"/> by rounding all float values up to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded up.</param>
 /// <returns>The <see cref="Point"/> representing the rounded <see cref="PointF"/>.</returns>
 public static Point Ceiling(PointF value) => new Point((int)Math.Ceiling(value.X), (int)Math.Ceiling(value.Y));
Beispiel #18
0
 /// <summary>
 /// Constructs a new <see cref="Point"/> from the specified <see cref="PointF"/> by rounding all values down to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded down.</param>
 /// <returns>The <see cref="Point"/> representing the rounded <see cref="PointF"/>.</returns>
 public static Point Truncate(PointF value) => new Point((int)(value.X), (int)(value.Y));
Beispiel #19
0
 /// <summary>
 /// Determines if a <see cref="PointF"/> is contained within the current <see cref="RectangleF"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointF"/> to test.</param>
 /// <returns>True if pt is contained within this <see cref="RectangleF"/>.</returns>
 public bool Contains(PointF pt) => Contains(pt.X, pt.Y);
Beispiel #20
0
 /// <summary>
 /// Constructs a new instance of <see cref="RectangleF"/> from the specified <see cref="PointF"/> and <see cref="SizeF"/>.
 /// </summary>
 /// <param name="location">The <see cref="Location"/> of the <see cref="RectangleF"/>.</param>
 /// <param name="size">The <see cref="Size"/> of the <see cref="RectangleF"/>.</param>
 public RectangleF(PointF location, SizeF size)
 {
     Location = location;
     Size = size;
 }
Beispiel #21
0
 /// <summary>
 /// Constructs a new <see cref="PointShort"/> from the specified <see cref="PointF"/> by rounding all values to the nearest whole number.
 /// </summary>
 /// <param name="value">The <see cref="PointF"/> to be rounded.</param>
 /// <returns>The <see cref="PointShort"/> representing the rounded <see cref="PointF"/>.</returns>
 public static PointShort Round(PointF value) => new PointShort((short)Math.Round(value.X), (short)Math.Round(value.Y));
Beispiel #22
0
 /// <summary>
 /// Moves this <see cref="RectangleF"/> by the specified <see cref="PointF"/>.
 /// </summary>
 /// <param name="pos">The <see cref="PointF"/> containing the values to move by.</param>
 /// <returns>A new <see cref="RectangleF"/> moved by the <see cref="PointF"/> values.</returns>
 public RectangleF Offset(PointF pos) => new RectangleF(new PointF(Location.X + pos.X, Location.Y + pos.Y), Size);
Beispiel #23
0
 public Line(PointF start, PointF end)
 {
     Start = start;
     End = end;
     Vector = new Vector2F(End.X - Start.X, End.Y - Start.Y);
 }
Beispiel #24
0
 /// <summary>
 /// Constructs a new instance of <see cref="RectangleF"/> from the specified <see cref="X"/>, <see cref="Y"/>, <see cref="Width"/> and <see cref="Height"/>.
 /// </summary>
 /// <param name="x">A value representing the <see cref="X"/> of the <see cref="RectangleF"/>.</param>
 /// <param name="y">A value representing the <see cref="Y"/> of the <see cref="RectangleF"/>.</param>
 /// <param name="width">A value representing the <see cref="Width"/> of the <see cref="RectangleF"/>.</param>
 /// <param name="height">A value representing the <see cref="Height"/> of the <see cref="RectangleF"/>.</param>
 public RectangleF(float x, float y, float width, float height)
 {
     Location = new PointF(x, y);
     Size = new SizeF(width, height);
 }
Beispiel #25
0
 public bool WithinX(PointF pt) => (pt.X >= Start.X && pt.X <= End.X) || (pt.X <= Start.X && pt.X >= End.X);
Beispiel #26
0
 /// <summary>
 /// Constructs a new instance of <see cref="SizeF"/> from the specified <see cref="PointF"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointF"/> to construct the <see cref="SizeF"/> from.</param>
 /// <remarks>
 /// The <see cref="PointF.X"/> will become the <see cref="Width"/> and the <see cref="PointF.Y"/> will be the <see cref="Height"/>.
 /// </remarks>
 public SizeF(PointF pt)
 {
     Width = pt.X;
     Height = pt.Y;
 }
Beispiel #27
0
 private void trackObject_TrackableObjectChanged(object sender, TrackableObjectChangedEventArgs e)
 {
     // We should make the new camera position the same as the position of the entity, minus the centering
     _position = new PointF((e.NewPosition.X + e.NewSize.Width) / 2.0f - RelativeCenter.X, (e.NewPosition.Y + e.NewSize.Height) / 2.0f - RelativeCenter.Y);
 }
Beispiel #28
0
        public void Intersect_OneVertical_OneHorizontal_Line_1_0_1_2_Line_0_1_2_1()
        {
            //   |
            // __|_
            //   |
            //   |
            var expected = new PointF(1f, 1f);
            var l1 = new Line(new Point(1, 0), new Point(1, 2));
            var l2 = new Line(new Point(0, 1), new Point(2, 1));

            var actual = Line.Intersect(l1, l2);

            Assert.AreEqual(expected, actual);
        }
Beispiel #29
0
 /// <summary>
 /// Alters the <see cref="Position"/> of the current <see cref="Camera"/> instance by the specified <see cref="Vector2F"/>.
 /// </summary>
 /// <param name="vector">The distance to move the <see cref="Camera"/>.</param>
 public void MoveCamera(Vector2F vector)
 {
     Position = new PointF(Position.X + vector.X, Position.Y + vector.Y);
 }
Beispiel #30
0
 /// <summary>
 /// Subtracts a <see cref="PointF"/> by a <see cref="SizeF"/>.
 /// </summary>
 /// <param name="pt">The <see cref="PointF"/> to be subtracted from.</param>
 /// <param name="sz">The <see cref="SizeF"/> to subtract.</param>
 /// <returns>A <see cref="PointF"/> representing the difference.</returns>
 public static PointF Subtract(PointF pt, SizeF sz) => pt - sz;