コード例 #1
0
ファイル: C2DArc.cs プロジェクト: kasznare/DIP1
        /// <summary>
        /// Returns the projection of this onto the vector provided, given as the interval on
        /// (or off) the vector. Interval given as distance from the start of the vector.
        /// The vector is equivalent to a line from (0, 0).
        /// </summary>
        /// <param name="Vector">The projection vector.</param>
        /// <param name="Interval">The interval to recieve the result.</param>
        public override void Project(C2DVector Vector, CInterval Interval)
        {
            C2DArc    ThisCopy = new C2DArc(this);
            C2DVector VecCopy  = new C2DVector(Vector);

            double dAng = VecCopy.AngleFromNorth();

            VecCopy.TurnLeft(dAng);
            ThisCopy.RotateToRight(-dAng, new C2DPoint(0, 0));

            C2DRect rect = new C2DRect();

            ThisCopy.GetBoundingRect(rect);

            Interval.dMax = rect.GetTop() - VecCopy.j;
            Interval.dMin = Interval.dMax;

            Interval.ExpandToInclude(rect.GetBottom() - VecCopy.j);
        }
コード例 #2
0
ファイル: C2DArc.cs プロジェクト: kasznare/DIP1
        /// <summary>
        /// Returns the projection of this onto the line provided, given as the interval on
        /// (or off) the line. Interval given as distance from the start of the line.
        /// </summary>
        /// <param name="TestLine">The projection line.</param>
        /// <param name="Interval">The interval to recieve the result.</param>
        public override void Project(C2DLine TestLine, CInterval Interval)
        {
            C2DArc  ThisCopy = new C2DArc(this);
            C2DLine LineCopy = new C2DLine(TestLine);

            double dAng = LineCopy.vector.AngleFromNorth();

            LineCopy.vector.TurnLeft(dAng);
            ThisCopy.RotateToRight(-dAng, LineCopy.point);

            C2DRect rect = new C2DRect();

            ThisCopy.GetBoundingRect(rect);

            Interval.dMax = rect.GetTop() - LineCopy.point.y;
            Interval.dMin = Interval.dMax;

            Interval.ExpandToInclude(rect.GetBottom() - LineCopy.point.y);
        }
コード例 #3
0
ファイル: C2DPolyArc.cs プロジェクト: projektorkraft/PiGo
        /// <summary>
        /// Creates a random shape.
        /// </summary>
        /// <param name="cBoundary">The boundary.</param>
        /// <param name="nMinPoints">The minimum points.</param>
        /// <param name="nMaxPoints">The maximum points.</param>
        public bool CreateRandom(C2DRect cBoundary, int nMinPoints, int nMaxPoints)
        {
            C2DPolygon Poly = new C2DPolygon();

            if (!Poly.CreateRandom(cBoundary, nMinPoints, nMaxPoints))
            {
                return(false);
            }

            CRandomNumber rCenOnRight = new CRandomNumber(0, 1);

            this.Set(Poly);

            for (int i = 0; i < Lines.Count; i++)
            {
                C2DLineBase pLine = Lines[i];

                bool          bCenOnRight = (rCenOnRight.GetInt() > 0);
                double        dLength     = pLine.GetLength();
                CRandomNumber Radius      = new CRandomNumber(dLength, dLength * 3);


                C2DArc pNew = new C2DArc(pLine.GetPointFrom(), pLine.GetPointTo(),
                                         Radius.Get(), bCenOnRight, !bCenOnRight);

                if (!this.Crosses(pNew))
                {
                    Lines[i] = pNew;
                    pNew.GetBoundingRect(LineRects[i]);
                    BoundingRect.ExpandToInclude(LineRects[i]);
                }
            }

            //     this.MakeLineRects();
            //      this.MakeBoundingRect();

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Creates a random shape.
        /// </summary>
        /// <param name="cBoundary">The boundary.</param> 
        /// <param name="nMinPoints">The minimum points.</param> 
        /// <param name="nMaxPoints">The maximum points.</param> 
        public bool CreateRandom(C2DRect cBoundary, int nMinPoints, int nMaxPoints)
        {
            C2DPolygon Poly = new C2DPolygon();
            if (!Poly.CreateRandom(cBoundary, nMinPoints, nMaxPoints))
                return false;

            CRandomNumber rCenOnRight = new CRandomNumber(0, 1);

            this.Set( Poly );

            for (int i = 0 ; i < Lines.Count; i ++)
            {
                C2DLineBase pLine = Lines[i];

                bool bCenOnRight = (rCenOnRight.GetInt() > 0 );
                double dLength = pLine.GetLength();
                CRandomNumber Radius = new CRandomNumber(dLength , dLength * 3);

                C2DArc pNew = new C2DArc( pLine.GetPointFrom(), pLine.GetPointTo(),
                                    Radius.Get(), bCenOnRight, !bCenOnRight);

                if (!this.Crosses( pNew ))
                {
                    Lines[i] = pNew;
                    pNew.GetBoundingRect(LineRects[i]);
                    BoundingRect.ExpandToInclude(LineRects[i]);
                }
            }

               //     this.MakeLineRects();
              //      this.MakeBoundingRect();

            return true;
        }
コード例 #5
0
ファイル: C2DArc.cs プロジェクト: micrak/rakomeister-attic
        /// <summary>
        /// Returns the projection of this onto the vector provided, given as the interval on
        /// (or off) the vector. Interval given as distance from the start of the vector.
        /// The vector is equivalent to a line from (0, 0).
        /// </summary>
        /// <param name="Vector">The projection vector.</param>
        /// <param name="Interval">The interval to recieve the result.</param>
        public override void Project(C2DVector Vector,  CInterval Interval)
        {
	        C2DArc ThisCopy = new C2DArc(this);
	        C2DVector VecCopy = new C2DVector(Vector);

	        double dAng = VecCopy.AngleFromNorth();

	        VecCopy.TurnLeft(dAng);
	        ThisCopy.RotateToRight( -dAng, new C2DPoint(0, 0));

	        C2DRect rect = new C2DRect();
	        ThisCopy.GetBoundingRect( rect);

	        Interval.dMax = rect.GetTop() - VecCopy.j;
	        Interval.dMin = Interval.dMax;

	        Interval.ExpandToInclude( rect.GetBottom() - VecCopy.j );
        }
コード例 #6
0
ファイル: C2DArc.cs プロジェクト: micrak/rakomeister-attic
       /// <summary>
       /// Returns the projection of this onto the line provided, given as the interval on
       /// (or off) the line. Interval given as distance from the start of the line.
       /// </summary>
       /// <param name="TestLine">The projection line.</param>
       /// <param name="Interval">The interval to recieve the result.</param>
        public override void Project(C2DLine TestLine,  CInterval Interval) 
        {
	        C2DArc ThisCopy = new C2DArc(this);
            C2DLine LineCopy = new C2DLine(TestLine);

	        double dAng = LineCopy.vector.AngleFromNorth();

	        LineCopy.vector.TurnLeft(dAng);
	        ThisCopy.RotateToRight( -dAng, LineCopy.point);

	        C2DRect rect = new C2DRect();
	        ThisCopy.GetBoundingRect( rect);

            Interval.dMax = rect.GetTop() - LineCopy.point.y;
	        Interval.dMin = Interval.dMax;

            Interval.ExpandToInclude(rect.GetBottom() - LineCopy.point.y);


        }