Ejemplo n.º 1
0
        /// <summary>
        /// Returns the lines that go to make this up based on the set of points
        /// provided which are assumed to be on the line.
        /// </summary>
        /// <param name="PtsOnLine">The points defining how the line is to be split.</param>
        /// <param name="LineSet">The line set to recieve the result.</param>
        public override void GetSubLines(List <C2DPoint> PtsOnLine, List <C2DLineBase> LineSet)
        {
            // if there are no points on the line to split on then add a copy of this and return.
            int usPointsCount = PtsOnLine.Count;

            if (usPointsCount == 0)
            {
                LineSet.Add(new C2DArc(this));
                return;
            }
            else
            {
                // Make a copy of the points for sorting.
                C2DPointSet TempPts = new C2DPointSet();
                TempPts.MakeCopy(PtsOnLine);

                if (usPointsCount > 1)         // They need sorting
                {
                    // Make a line from the mid point of my line to the start
                    C2DLine CenToStart = new C2DLine(Line.GetMidPoint(), Line.point);
                    // Now sort the points according to the order in which they will be encountered
                    if (ArcOnRight)
                    {
                        TempPts.SortByAngleToLeft(CenToStart);
                    }
                    else
                    {
                        TempPts.SortByAngleToRight(CenToStart);
                    }
                }

                C2DPoint ptCentre = new C2DPoint(GetCircleCentre());

                // Add the line from the start of this to the first.
                C2DLine NewLine = new C2DLine(Line.point, TempPts[0]);
                LineSet.Add(new C2DArc(NewLine, Radius,
                                       NewLine.IsOnRight(ptCentre), ArcOnRight));

                // Add all the sub lines.
                for (int i = 1; i < usPointsCount; i++)
                {
                    NewLine.Set(TempPts[i - 1], TempPts[i]);
                    LineSet.Add(new C2DArc(NewLine, Radius,
                                           NewLine.IsOnRight(ptCentre), ArcOnRight));
                }
                // Add the line from the last point on this to the end of this.
                NewLine.Set(TempPts[TempPts.Count - 1], Line.GetPointTo());
                LineSet.Add(new C2DArc(NewLine, Radius,
                                       NewLine.IsOnRight(ptCentre), ArcOnRight));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the point half way along the curve as a new object.
        /// </summary>
        public C2DPoint GetMidPoint()
        {
            Debug.Assert(IsValid(), "Invalid arc defined, cannot calculate midpoint");
            // Make a line from the circle centre to the middle of the line
            C2DPoint ptCentre = new C2DPoint(GetCircleCentre());

            C2DPoint ptLineCentre = new C2DPoint(Line.GetMidPoint());

            C2DLine CenToMid = new C2DLine(ptCentre, ptLineCentre);

            if (CenToMid.vector.i == 0 && CenToMid.vector.j == 0)
            {
                // The centre of the line is the same as the centre of the circle
                // i.e. this arc is 180 degrees or half a circle.
                CenToMid.Set(Line);
                CenToMid.SetPointFrom(ptLineCentre);
                if (ArcOnRight)
                {
                    CenToMid.vector.TurnRight();
                }
                else
                {
                    CenToMid.vector.TurnLeft();
                }
            }
            else
            {
                // extend it to the edge of the arc
                CenToMid.SetLength(Radius);
                // if the arc on the opposite side to the centre then reverse the line.
                if (ArcOnRight == CentreOnRight)
                {
                    CenToMid.vector.Reverse();
                }
            }

            return(CenToMid.GetPointTo());
        }
Ejemplo n.º 3
0
        /// <summary>
	    /// Returns the lines that go to make this up based on the set of points 
	    /// provided which are assumed to be on the line.
        /// </summary>
        /// <param name="PtsOnLine">The points defining how the line is to be split.</param> 
        /// <param name="LineSet">The line set to recieve the result.</param> 
        public override void GetSubLines(List<C2DPoint> PtsOnLine,  List<C2DLineBase> LineSet) 
        {
            
	        // if there are no points on the line to split on then add a copy of this and return.
	        int usPointsCount = PtsOnLine.Count;
	        if (usPointsCount == 0 )
	        {
		        LineSet.Add(new C2DArc(this));
		        return;
	        }
	        else
	        {
		        // Make a copy of the points for sorting.
		        C2DPointSet TempPts = new C2DPointSet();
		        TempPts.MakeCopy(PtsOnLine);

		        if (usPointsCount > 1) // They need sorting
		        {
			        // Make a line from the mid point of my line to the start
			        C2DLine CenToStart = new C2DLine( Line.GetMidPoint(), Line.point );
			        // Now sort the points according to the order in which they will be encountered
			        if (ArcOnRight)
				        TempPts.SortByAngleToLeft( CenToStart );
			        else
				        TempPts.SortByAngleToRight( CenToStart );
		        }

		        C2DPoint ptCentre = new C2DPoint(GetCircleCentre());

		        // Add the line from the start of this to the first.
		        C2DLine NewLine = new C2DLine( Line.point, TempPts[0] );
                LineSet.Add(new C2DArc(NewLine, Radius,
                                          NewLine.IsOnRight(ptCentre), ArcOnRight));

		        // Add all the sub lines.
		        for (int i = 1; i < usPointsCount; i++)
		        {
                    NewLine.Set(TempPts[i - 1], TempPts[i]);
                    LineSet.Add(new C2DArc(NewLine, Radius,
                                            NewLine.IsOnRight(ptCentre), ArcOnRight));
		        }
		        // Add the line from the last point on this to the end of this.
                NewLine.Set(TempPts[TempPts.Count - 1], Line.GetPointTo());
                LineSet.Add(new C2DArc(NewLine, Radius,
                                           NewLine.IsOnRight(ptCentre), ArcOnRight));
	        }
            
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the point half way along the curve as a new object.
        /// </summary>
        public C2DPoint GetMidPoint() 
        {
	        Debug.Assert(IsValid(), "Invalid arc defined, cannot calculate midpoint");
	        // Make a line from the circle centre to the middle of the line
	        C2DPoint ptCentre = new C2DPoint(GetCircleCentre());

	        C2DPoint ptLineCentre = new C2DPoint(Line.GetMidPoint());

	        C2DLine CenToMid = new C2DLine(ptCentre, ptLineCentre);

	        if ( CenToMid.vector.i == 0 && CenToMid.vector.j == 0)
	        {
		        // The centre of the line is the same as the centre of the circle
		        // i.e. this arc is 180 degrees or half a circle.
		        CenToMid.Set(Line);
		        CenToMid.SetPointFrom( ptLineCentre );
		        if ( ArcOnRight )
			        CenToMid.vector.TurnRight();
		        else
			        CenToMid.vector.TurnLeft();
	        }
	        else
	        {
		        // extend it to the edge of the arc
		        CenToMid.SetLength( Radius );
		        // if the arc on the opposite side to the centre then reverse the line.
		        if ( ArcOnRight == CentreOnRight)
		        {
			        CenToMid.vector.Reverse();
		        }
	        }

	        return CenToMid.GetPointTo();

        }