public void GetSideTests(Point a, Point b, Point p, int expected)
        {
            var sut    = new VectorGeometry();
            var actual = sut.GetSide(a, b, p);

            Assert.AreEqual(expected, actual);
        }
        public void GetMinDistanceTests(Point a, Point b, Point c, Point d,
                                        Point r1, Point r2, double distance)
        {
            var sut    = new VectorGeometry();
            var actual = sut.GetMinDistance(a, b, c, d);

            Assert.AreEqual(distance, actual.Item3);
            Assert.AreEqual(r1, actual.Item1);
            Assert.AreEqual(r2, actual.Item2);
        }
        public void CalculateProjectionTests(
            Point w,
            Point v,
            Point p,
            Point expected,
            double distanceSqr)
        {
            var sut    = new VectorGeometry();
            var actual = sut.CalculateProjection(w, v, p);

            Assert.AreEqual(expected, actual.Item1);
            Assert.AreEqual(distanceSqr, actual.Item2);
        }
Beispiel #4
0
        /// <summary>
        /// Given two outgoing hald-edges from figureVertex create a WavefrontVertex whose
        /// velocity vector bisects the two half-edges. Assumes the Second half-edge is
        /// anticlockwise of the first half-edge.
        /// </summary>
        /// <param name="figureEdgeHalves">A pair of half-edges originating from the same vertex, where Second is anticlockwise from First</param>
        /// <param name="figureVertex">A vertex whose position is coincident with the source of the two half-edges provided</param>
        /// <returns>A new WavefrontVertex with the same position as figureVertex with a velocity vector that bisects the half-edges.</returns>
        private static WavefrontVertex BisectingWavefrontVertex(Pair <Half, Half> figureEdgeHalves, TVertex figureVertex)
        {
            Point2D current = figureVertex.Position;

            Debug.Assert(current == ((IPositionable2D)figureEdgeHalves.First.Source).Position);
            Debug.Assert(current == ((IPositionable2D)figureEdgeHalves.Second.Source).Position);
            Point2D     trailing = ((IPositionable2D)figureEdgeHalves.First.Target).Position;
            Point2D     leading  = ((IPositionable2D)figureEdgeHalves.Second.Target).Position;
            Vector2D    incoming = current - trailing;
            Vector2D    outgoing = leading - current;
            Direction2D bisector = VectorGeometry.Bisector(ref incoming, ref outgoing);
            // Determine the speed of wave propagation along the direction of the bisector
            double   angle    = (-incoming).Angle(outgoing);
            double   speed    = 1.0 / Math.Sin(angle);
            Vector2D velocity = new Vector2D(bisector, speed);

            return(new WavefrontVertex(figureVertex, velocity));
        }
 public ClockwiseOrderComparer(Point origin, Point reference)
 {
     _origin         = origin;
     _reference      = reference;
     _vectorGeometry = new VectorGeometry();
 }