예제 #1
0
        /// <summary>
        /// 计算指定点相对于当前线段的转弯方向
        /// </summary>
        /// <param name="otherPoint"></param>
        /// <returns></returns>
        public TurnDirectionType GetTurnDirection(Point3D otherPoint)
        {
            Point3D v1       = BeginPoint.Vector(EndPoint);
            Point3D v2       = EndPoint.Vector(otherPoint);
            double  vProduct = (v2 as Point3D).VectorProduct(v1);

            return(vProduct > 0 ? TurnDirectionType.Right : vProduct < 0 ? TurnDirectionType.Left : TurnDirectionType.Stright);
        }
예제 #2
0
        public override int GetHashCode()
        {
            const int hashIndex = 307;
            var       result    = (BeginPoint != null) ? BeginPoint.GetHashCode() : 0;

            result = (result * hashIndex) ^ ((EndPoint != null) ? EndPoint.GetHashCode() : 0);

            return(result);
        }
예제 #3
0
        /// <summary>
        /// 获取线段长度
        /// </summary>
        /// <returns></returns>
        public double GetLength()
        {
            if (BeginPoint == null)
            {
                throw new ArgumentNullException("计算线段长度时,线段起始点出现空引用");
            }

            return(BeginPoint.DisTo(EndPoint));
        }
예제 #4
0
        /// <summary>
        /// 获取线段方向(弧度)
        /// </summary>
        /// <returns></returns>
        public double GetDirection()
        {
            if (BeginPoint == null)
            {
                throw new ArgumentNullException("计算线段方向时,线段起始点出现空引用");
            }

            return(BeginPoint.DirTo(EndPoint));
        }
예제 #5
0
        public override int GetHashCode()
        {
            const int hashIndex = 307;
            var       result    = (Center != null) ? Center.GetHashCode() : 0;

            result = (result * hashIndex) ^ ((BeginPoint != null) ? BeginPoint.GetHashCode() : 0);
            result = (result * hashIndex) ^ ((EndPoint != null) ? EndPoint.GetHashCode() : 0);
            result = (result * hashIndex) ^ ArcDirection.GetHashCode();

            return(result);
        }
예제 #6
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (obj == null || !GetType().IsEquivalentTo(obj.GetType()))
            {
                return(false);
            }

            LineSegment other = (LineSegment)obj;

            return(BeginPoint.Equals(other.BeginPoint) &&
                   EndPoint.Equals(other.EndPoint));
        }
예제 #7
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (obj == null || !GetType().IsEquivalentTo(obj.GetType()))
            {
                return(false);
            }

            ArcSegment other = (ArcSegment)obj;

            return(BeginPoint.Equals(other.BeginPoint) &&
                   EndPoint.Equals(other.EndPoint) &&
                   Center.Equals(other.Center) &&
                   ArcDirection.Equals(other.ArcDirection));
        }
예제 #8
0
        /// <summary>
        /// 延长直线段
        /// </summary>
        /// <param name="type">延长类型:0都延长,1延长尾点,-1延长首点</param>
        /// <param name="expandDis"></param>
        /// <returns></returns>
        public LineSegment Expand(int type, double expandDis)
        {
            switch (type)
            {
            case 0:
                return(new LineSegment(BeginPoint.GetNextPoint(GetDirection() + Math.PI, expandDis),
                                       EndPoint.GetNextPoint(GetDirection(), expandDis)));

            case -1:
                return(new LineSegment(BeginPoint.GetNextPoint(GetDirection() + Math.PI, expandDis), EndPoint));

            case 1:
                return(new LineSegment(BeginPoint, EndPoint.GetNextPoint(GetDirection(), expandDis)));

            default:
                break;
            }

            throw new ArgumentOutOfRangeException("扩展线段(LineSegment.Expand)时,出现了非法的延长类型");
        }
예제 #9
0
 public override void Draw()
 {
     Console.WriteLine($"Тип фигуры: {FigureType} ({GetType()}).");
     Console.WriteLine($"Ее параметры: координаты начальной точки {BeginPoint.ToString()}, конечной точки {EndPoint.ToString()}.");
 }
예제 #10
0
    public override int GetHashCode()
    {
        int hash = 1;

        if (Key.Length != 0)
        {
            hash ^= Key.GetHashCode();
        }
        if (Type != 0)
        {
            hash ^= Type.GetHashCode();
        }
        if (Broadcast != false)
        {
            hash ^= Broadcast.GetHashCode();
        }
        if (Name.Length != 0)
        {
            hash ^= Name.GetHashCode();
        }
        if (Avatar.Length != 0)
        {
            hash ^= Avatar.GetHashCode();
        }
        if (Seat != 0)
        {
            hash ^= Seat.GetHashCode();
        }
        if (RoomKey.Length != 0)
        {
            hash ^= RoomKey.GetHashCode();
        }
        if (RoomName.Length != 0)
        {
            hash ^= RoomName.GetHashCode();
        }
        if (Message.Length != 0)
        {
            hash ^= Message.GetHashCode();
        }
        if (BeginPoint != 0D)
        {
            hash ^= BeginPoint.GetHashCode();
        }
        if (EndPoint != 0D)
        {
            hash ^= EndPoint.GetHashCode();
        }
        if (PenSize != 0)
        {
            hash ^= PenSize.GetHashCode();
        }
        if (Color != 0)
        {
            hash ^= Color.GetHashCode();
        }
        hash ^= users_.GetHashCode();
        hash ^= rooms_.GetHashCode();
        if (Code != 0)
        {
            hash ^= Code.GetHashCode();
        }
        if (Error.Length != 0)
        {
            hash ^= Error.GetHashCode();
        }
        if (Id != 0)
        {
            hash ^= Id.GetHashCode();
        }
        return(hash);
    }
예제 #11
0
 public override string ToString()
 {
     return(string.Format("{0};{1}", BeginPoint.ToString(), EndPoint.ToString()));
 }
예제 #12
0
 /// <summary>
 /// 根据指定方向和距离平移直线段
 /// </summary>
 /// <param name="radian"></param>
 /// <param name="distance"></param>
 public override void Move(double radian, double distance)
 {
     SetBeginPoint(BeginPoint.GetNextPoint(radian, distance));
     SetEndPoint(EndPoint.GetNextPoint(radian, distance));
 }
예제 #13
0
 public override string ToString()
 {
     return(string.Format("{0};{1};{2};{3}", Center.ToString(), BeginPoint.ToString(), EndPoint.ToString(), ArcDirection.ToString()));
 }
예제 #14
0
 public override string ToString()
 {
     return(BeginPoint.ToString() + " - " + EndPoint.ToString());
 }
예제 #15
0
 /// <summary>
 /// Возвращает информацию о дороге в виде «НАЧАЛЬНАЯ ТОЧКА->КОНЕЧНАЯ ТОЧКА».
 /// </summary>
 /// <returns>Информация о дороге в виде «НАЧАЛЬНАЯ ТОЧКА->КОНЕЧНАЯ ТОЧКА».</returns>
 public override string ToString()
 {
     return($"{BeginPoint.ToString()}->{EndPoint.ToString()}");
 }