예제 #1
0
        public double GetContactLength(Side target)
        {
            if (this.IsParallelToX() && target.IsParallelToX())
            {
                double max = Math.Max(this.Start.X, target.Start.X);
                double min = Math.Min(this.End.X, target.End.X);

                if (max < min)
                {
                    return(Math.Abs(max - min));
                }
                else
                {
                    return(0);
                }
            }
            else if (this.IsParallelToY() && target.IsParallelToY())
            {
                double max = Math.Max(this.Start.Y, target.Start.Y);
                double min = Math.Min(this.End.Y, target.End.Y);

                if (max < min)
                {
                    return(Math.Abs(max - min));
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
예제 #2
0
        public bool IsContact(Side target)
        {
            if (this.IsParallelToX() && target.IsParallelToX() && this.Start.Y == target.Start.Y)
            {
                double max = Math.Max(this.Start.X, target.Start.X);
                double min = Math.Min(this.End.X, target.End.X);

                if (max < min)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (this.IsParallelToY() && target.IsParallelToY() && this.Start.X == target.Start.X)
            {
                double max = Math.Max(this.Start.Y, target.Start.Y);
                double min = Math.Min(this.End.Y, target.End.Y);

                if (max < min)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        public Side GetContact(Side target)
        {
            if (this.IsParallelToX() && target.IsParallelToX())
            {
                double max = Math.Max(this.Start.X, target.Start.X);
                double min = Math.Min(this.End.X, target.End.X);

                if (max < min)
                {
                    Cord p1 = new Cord(min, this.Start.Y, this.Start.Z);
                    Cord p2 = new Cord(max, this.End.Y, this.End.Z);
                    return(new Side(this.Position, this.Type, p1, p2));
                }
                else
                {
                    return(null);
                }
            }
            else if (this.IsParallelToY() && target.IsParallelToY())
            {
                double max = Math.Max(this.Start.Y, target.Start.Y);
                double min = Math.Min(this.End.Y, target.End.Y);

                if (max < min)
                {
                    Cord p1 = new Cord(this.Start.X, min, this.Start.Z);
                    Cord p2 = new Cord(this.End.X, max, this.End.Z);
                    return(new Side(this.Position, this.Type, p1, p2));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }