Exemplo n.º 1
0
        /// <summary>
        /// Returns all edges to the right when crossing from edge 'source' through this vertex towards edge 'destination'
        /// </summary>
        /// <param name="source"></param>
        /// <param name="destination"></param>
        /// <returns></returns>
        public IEnumerable <Edge> GetRightCrossings(Edge source, Edge destination)
        {
            var    deltaSource      = (source.GetOtherEnd(this).Location - this.Location);
            var    deltaDestination = (destination.GetOtherEnd(this).Location - this.Location);
            double angleSource      = Math.Atan2(deltaSource.Y, deltaSource.X);
            double angleDestination = Math.Atan2(deltaDestination.Y, deltaDestination.X);

            if (angleDestination < angleSource)
            {
                angleDestination += Math.PI * 2;
            }
            foreach (var edge in Edges.Where(e => e != source && e != destination))
            {
                var    deltaEdge = (edge.GetOtherEnd(this).Location - this.Location);
                double angleEdge = Math.Atan2(deltaEdge.Y, deltaEdge.X);
                if (angleEdge < angleSource)
                {
                    angleEdge += Math.PI * 2;
                }
                if (angleEdge < angleDestination)
                {
                    yield return(edge);
                }
            }
        }
Exemplo n.º 2
0
        public double AngleBetween(Edge source, Edge destination)
        {
            var deltaSource      = (this.Location - source.GetOtherEnd(this).Location);
            var deltaDestination = (destination.GetOtherEnd(this).Location - this.Location);

            //return Vector2.AngleBetween(deltaSource, deltaDestination);
            return(0f);
        }