コード例 #1
0
        /// <summary>
        /// Projection onto a line.
        /// </summary>
        /// <param name="TestLine">The line to project this on.</param>
        /// <param name="Interval">Output. The interval.</param>
        public override void Project(C2DLine TestLine, CInterval Interval)
        {
            var dP1 = point.Project(TestLine);

            Interval.dMax = dP1;
            Interval.dMin = dP1;
            Interval.ExpandToInclude(GetPointTo().Project(TestLine));
        }
コード例 #2
0
        /// <summary>
        /// Projects this onto the vector given.
        /// </summary>
        /// <param name="Vector">The Vector.</param>
        /// <param name="Interval">The projection.</param>
        public override void Project(C2DVector Vector, CInterval Interval)
        {
            Arc.Project(Vector, Interval);
            var LineInterval = new CInterval();

            Arc.Line.Project(Vector, LineInterval);
            Interval.ExpandToInclude(LineInterval);
        }
コード例 #3
0
        /// <summary>
        /// Projection onto a vector.
        /// </summary>
        /// <param name="Vector">The vector to project this on.</param>
        /// <param name="Interval">Output. The interval.</param>
        public override void Project(C2DVector Vector, CInterval Interval)
        {
            var dP1 = point.Project(Vector);

            Interval.dMax = dP1;
            Interval.dMin = dP1;
            Interval.ExpandToInclude(GetPointTo().Project(Vector));
        }
コード例 #4
0
ファイル: C2DSegment.cs プロジェクト: kasznare/DIP1
        /// <summary>
        /// Projects this onto the line given.
        /// </summary>
        /// <param name="Line">The line.</param>
        /// <param name="Interval">The projection.</param>
        public override void Project(C2DLine Line, CInterval Interval)
        {
            Arc.Project(Line, Interval);
            CInterval LineInterval = new CInterval();

            Arc.Line.Project(Line, LineInterval);
            Interval.ExpandToInclude(LineInterval);
        }
コード例 #5
0
        /// <summary>
        /// Projection onto the line
        /// </summary>
        /// <param name="Line">Line to project on.</param>
        /// <param name="Interval">Ouput. Projection.</param>
        public override void Project(C2DLine Line, CInterval Interval)
        {
            this.TopLeft.Project(Line, Interval);
            Interval.ExpandToInclude(BottomRight.Project(Line));
            var TR = new C2DPoint(BottomRight.x, TopLeft.y);
            var BL = new C2DPoint(TopLeft.x, BottomRight.y);

            Interval.ExpandToInclude(TR.Project(Line));
            Interval.ExpandToInclude(BL.Project(Line));
        }
コード例 #6
0
ファイル: C2DRect.cs プロジェクト: kasznare/DIP1
        /// <summary>
        /// Projection onto the Vector.
        /// </summary>
        /// <param name="Vector">Vector to project on.</param>
        /// <param name="Interval">Ouput. Projection.</param>
        public override void Project(C2DVector Vector, CInterval Interval)
        {
            this.TopLeft.Project(Vector, Interval);
            Interval.ExpandToInclude(BottomRight.Project(Vector));
            C2DPoint TR = new C2DPoint(BottomRight.x, TopLeft.y);
            C2DPoint BL = new C2DPoint(TopLeft.x, BottomRight.y);

            Interval.ExpandToInclude(TR.Project(Vector));
            Interval.ExpandToInclude(BL.Project(Vector));
        }
コード例 #7
0
 /// <summary>
 /// Expands the interval to include the other
 /// </summary>
 public void ExpandToInclude(CInterval Other)
 {
     if (Other.dMax > dMax)
     {
         dMax = Other.dMax;
     }
     if (Other.dMin < dMin)
     {
         dMin = Other.dMin;
     }
 }
コード例 #8
0
 /// <summary>
 /// True is this overlaps the other.
 /// </summary>
 /// <param name="Other"></param>
 /// <param name="Overlap"></param>
 /// <returns></returns>
 public bool Overlaps(CInterval Other, CInterval Overlap)
 {
     if (Other.dMin < dMax &&
         Other.dMax > dMin)
     {
         Overlap.dMin = Math.Max(Other.dMin, dMin);
         Overlap.dMax = Math.Min(Other.dMax, dMax);
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #9
0
ファイル: C2DCircle.cs プロジェクト: kasznare/DIP1
        /// <summary>
        /// Projection onto the vector as distance along the line from the start of the vector.
        /// Result is stored as an CInterval Min and Max,
        /// </summary>
        /// <param name="Vector">Vector to project this onto.</param>
        /// <param name="Interval">Interval to recieve the result.</param>
        public override void Project(C2DVector Vector, CInterval Interval)
        {
            // Create a line that goes through the circle from edge to edge and with the same vector.
            C2DLine Line = new C2DLine(_Centre, Vector);

            Line.vector.SetLength(Radius * 2);

            C2DVector V2 = new C2DVector(Vector);

            V2.Multiply(-0.5);
            Line.Move(V2);

            // Now just project the line onto the interval.
            Line.Project(Vector, Interval);
        }
コード例 #10
0
ファイル: C2DPolyBase.cs プロジェクト: projektorkraft/PiGo
        /// <summary>
        /// Projection onto the line.
        /// </summary>
        /// <param name="Line">The line.</param>
        /// <param name="Interval">Output. The interval.</param>
        public override void Project(C2DLine Line, CInterval Interval)
        {
            if (Lines.Count == 0)
            {
                return;
            }

            Lines[0].Project(Line, Interval);

            for (int i = 1; i < Lines.Count; i++)
            {
                CInterval LineInt = new CInterval();
                Lines[i].Project(Line, LineInt);
                Interval.ExpandToInclude(LineInt);
            }
        }
コード例 #11
0
        /// <summary>
        /// Projection onto the vector.
        /// </summary>
        /// <param name="Vector">The vector.</param>
        /// <param name="Interval">Output. The interval.</param>
        public override void Project(C2DVector Vector, CInterval Interval)
        {
            if (Lines.Count == 0)
            {
                return;
            }

            Lines[0].Project(Vector, Interval);

            for (var i = 1; i < Lines.Count; i++)
            {
                var LineInt = new CInterval();
                Lines[i].Project(Vector, LineInt);
                Interval.ExpandToInclude(LineInt);
            }
        }
コード例 #12
0
        /// <summary>
        /// Projection onto the line as distance along the line from the start of the line.
        /// Result is stored as an CInterval Min and Max,
        /// </summary>
        /// <param name="Line">Line to project this onto.</param>
        /// <param name="Interval">Interval to recieve the result.</param>
        public override void Project(C2DLine Line, CInterval Interval)
        {
            // Create a line that goes through the circle from edge to edge and with the same vector as the
            // Line to project on.
            var LineCopy = new C2DLine(_Centre, Line.vector);

            LineCopy.vector.SetLength(Radius * 2);

            var V2 = new C2DVector(LineCopy.vector);

            V2.Multiply(-0.5);

            LineCopy.Move(V2);

            // Now just project the line onto the interval.
            LineCopy.Project(Line, Interval);
        }
コード例 #13
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);
        }
コード例 #14
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);
        }
コード例 #15
0
ファイル: C2DCircle.cs プロジェクト: kasznare/DIP1
        /// <summary>
        /// Distance to a line, returns the closest point on the circle and the line.
        /// </summary>
        /// <param name="Line">Line to calculate the distance to.</param>
        /// <param name="ptOnThis">Closest point on the circle to recieve the result.</param>
        /// <param name="ptOnOther">Closest point on the line to recieve the result.</param>
        public double Distance(C2DLine Line, C2DPoint ptOnThis, C2DPoint ptOnOther)
        {
            CInterval ProjInt = new CInterval();

            Project(Line, ProjInt);

            if (ProjInt.dMax < 0)
            {
                // This means that the circle projects entirely "below" the line so the nearest point
                // To this is the first point on the line and there are no interections.
                ptOnOther.Set(Line.point);

                return(Distance(Line.point, ptOnThis));
            }

            double dLength = Line.GetLength();

            if (ProjInt.dMin > dLength)
            {
                // This means that the circle projects entirely "above" the line so the nearest point
                // To this is the second point on the line and there are no interections.
                C2DPoint ptClosest = new C2DPoint(Line.GetPointTo());
                ptOnOther.Set(ptClosest);
                return(Distance(ptClosest, ptOnThis));
            }

            // Now find out if there's an intersection.
            List <C2DPoint> IntPts = new List <C2DPoint>();

            if (Crosses(Line, IntPts))
            {
                ptOnThis.Set(IntPts[0]);
                ptOnOther.Set(IntPts[0]);

                return(0);
            }

            // Now find out if the line is entirely inside
            if (ProjInt.dMin > 0 && ProjInt.dMax < dLength && this.Contains(Line.point))
            {
                double   d1         = Distance(Line.point, ptOnThis);
                C2DPoint ptThisTemp = new C2DPoint();
                double   d2         = Distance(Line.GetPointTo(), ptThisTemp);
                Debug.Assert(d1 < 0 && d2 < 0);
                if (d2 > d1) // NOTE USE OF > AS d2 and d1 are -ve.
                {
                    ptOnThis.Set(ptThisTemp);
                    ptOnOther.Set(Line.GetPointTo());
                    return(d2);
                }
                else
                {
                    ptOnOther.Set(Line.point);
                    return(d1);
                }
            }

            // We now know the line is entirely outside.
            // Now find out if this is closest to a point on the line.
            double dCenOnLine = (ProjInt.dMax + ProjInt.dMin) / 2.0;

            if (dCenOnLine > 0)
            {
                if (dCenOnLine < dLength)
                {
                    // The centre is projected on the line
                    double dFactor = dCenOnLine / dLength;

                    C2DVector vProj = new C2DVector(Line.vector);
                    vProj.Multiply(dFactor);
                    C2DPoint ptOnLine = new C2DPoint(Line.point.GetPointTo(vProj));

                    ptOnOther.Set(ptOnLine);

                    return(Distance(ptOnLine, ptOnThis));
                }
                else
                {
                    // The centre is projected above the line.
                    C2DPoint ptClosest = new C2DPoint(Line.GetPointTo());
                    ptOnOther.Set(ptClosest);
                    return(Distance(ptClosest, ptOnThis));
                }
            }
            else
            {
                // This means that the circle projects entirely "below" the line.
                ptOnOther.Set(Line.point);
                return(Distance(Line.point, ptOnThis));
            }
        }
コード例 #16
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 );
        }
コード例 #17
0
 /// <summary>
 /// Projection onto the vector.
 /// </summary>
 /// <param name="Vector">Vector to project this on.</param> 
 /// <param name="Interval">Interval to recieve the result.</param> 
 public void Project(C2DVector Vector, CInterval Interval) 
 {
     _Rim.Project(Vector, Interval);
 }
コード例 #18
0
 /// <summary>
 /// Projects the point on the vector given returning a distance along the vector.
 /// </summary>
 /// <param name="Line">The vector to project this on.</param>
 /// <param name="Interval">The interval to recieve the result. 
 /// Both the min and max of the interval will be set to the result.</param>
 public override void Project(C2DLine Line,  CInterval Interval)
 {
     Interval.dMax = Project(Line);
     Interval.dMin = Interval.dMax;
 }
コード例 #19
0
ファイル: C2DBase.cs プロジェクト: micrak/rakomeister-attic
 /// <summary>
 /// Projects this onto the line provided with the interval on the line returned.
 /// </summary>
 public abstract  void Project( C2DLine Line,  CInterval Interval);
コード例 #20
0
 /// <summary>
 /// Projects this onto the vector given.
 /// </summary>
 /// <param name="Vector">The Vector.</param>
 /// <param name="Interval">The projection.</param>
 public override void Project(C2DVector Vector,  CInterval Interval)
 {
     Arc.Project(Vector,  Interval);
     CInterval LineInterval = new CInterval();
     Arc.Line.Project(Vector,  LineInterval);
     Interval.ExpandToInclude( LineInterval );
 }
コード例 #21
0
        /// <summary>
        /// True if part of this line is above the other. Returns the point
        /// on this and on the other.
        /// </summary>
        /// <param name="Other"></param>
        /// <param name="dVerticalDistance"></param>
        /// <param name="ptOnThis"></param>
        /// <param name="ptOnOther"></param>
        /// <returns></returns>
        public bool OverlapsAbove(C2DLine Other, ref double dVerticalDistance,
                                  C2DPoint ptOnThis, C2DPoint ptOnOther)
        {
            // Get the 2 points for both lines
            var OtherTo = new C2DPoint(Other.point.x + Other.vector.i, Other.point.y + Other.vector.j);
            var ThisTo  = new C2DPoint(point.x + vector.i, point.y + vector.j);
            // Make an interval for both in the x plane
            var iThis = new CInterval(point.x, point.x);

            iThis.ExpandToInclude(ThisTo.x);

            var iOther = new CInterval(Other.point.x, Other.point.x);

            iOther.ExpandToInclude(OtherTo.x);
            // This is an interval for the overlap between the 2
            var iOverlap = new CInterval();

            // If there is an overlap...
            if (iThis.Overlaps(iOther, iOverlap))
            {
                double dThisYMin;
                double dThisYMax;

                double dOtherYMin;
                double dOtherYMax;
                // If the line is vertical then y at the x min / max can be set to the ends of the line.
                if (vector.i == 0)
                {
                    dThisYMin = point.y;
                    dThisYMax = ThisTo.y;
                }
                else            // otherwise, caluclate the y values at the interval ends
                {
                    dThisYMin = GetY(iOverlap.dMin);
                    dThisYMax = GetY(iOverlap.dMax);
                }
                // Now do the same for the other line
                if (Other.vector.i == 0)
                {
                    dOtherYMin = Other.point.y;
                    dOtherYMax = OtherTo.y;
                }
                else
                {
                    dOtherYMin = Other.GetY(iOverlap.dMin);
                    dOtherYMax = Other.GetY(iOverlap.dMax);
                }

                // Now find the distance between the 2 at the ends
                var dDistMin = dThisYMin - dOtherYMin;
                var dDistMax = dThisYMax - dOtherYMax;
                // If they are both > 0 then no intersection
                if ((dDistMin > 0) && (dDistMax > 0))
                {
                    dDistMin = Math.Abs(dDistMin);
                    dDistMax = Math.Abs(dDistMax);
                    // find which one is smallest
                    if (dDistMin > dDistMax)
                    {
                        dVerticalDistance = dDistMax;                   // distance at the max is smallest
                        ptOnThis.x        = iOverlap.dMax;
                        ptOnThis.y        = dThisYMax;
                        ptOnOther.x       = iOverlap.dMax;
                        ptOnOther.y       = dOtherYMax;
                    }
                    else
                    {
                        dVerticalDistance = dDistMin;                  // distance at the min is smallest
                        ptOnThis.x        = iOverlap.dMin;
                        ptOnThis.y        = dThisYMin;
                        ptOnOther.x       = iOverlap.dMin;
                        ptOnOther.y       = dOtherYMin;
                    }

                    return(true);
                }
                else if ((dDistMin < 0) && (dDistMax < 0))          // This is below.
                {
                    return(false);
                }
                else
                {
                    // find the intersection.
                    dVerticalDistance = 0;
                    var pts = new C2DPointSet();
                    if (this.Crosses(Other, pts))
                    {
                        ptOnThis  = pts[0];
                        ptOnOther = ptOnThis;
                    }
                    else
                    {
                        Debug.Assert(false);
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #22
0
 /// <summary>
 /// Projects the point on the vector given returning a distance along the vector.
 /// </summary>
 /// <param name="line">The vector to project this on.</param>
 /// <param name="interval">The interval to recieve the result.
 /// Both the min and max of the interval will be set to the result.</param>
 public override void Project(C2DLine line, CInterval interval)
 {
     interval.dMax = Project(line);
     interval.dMin = interval.dMax;
 }
コード例 #23
0
 /// <summary>
 /// Projection onto the vector.
 /// </summary>
 /// <param name="Vector">Vector to project this on.</param>
 /// <param name="Interval">Interval to recieve the result.</param>
 public void Project(C2DVector Vector, CInterval Interval)
 {
     _Rim.Project(Vector, Interval);
 }
コード例 #24
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);


        }
コード例 #25
0
 /// <summary>
 /// Projection onto the line.
 /// </summary>
 /// <param name="Line">Line to project this on.</param>
 /// <param name="Interval">Interval to recieve the result.</param>
 public void Project(C2DLine Line, CInterval Interval)
 {
     _Rim.Project(Line, Interval);
 }
コード例 #26
0
        /// <summary>
        /// Projection onto the vector as distance along the line from the start of the vector.
        /// Result is stored as an CInterval Min and Max,
        /// </summary>
        /// <param name="Vector">Vector to project this onto.</param> 
        /// <param name="Interval">Interval to recieve the result.</param> 
        public override void Project(C2DVector Vector,  CInterval Interval)
        {
            // Create a line that goes through the circle from edge to edge and with the same vector.
            C2DLine Line = new C2DLine (_Centre, Vector);

            Line.vector.SetLength( Radius * 2 );

            C2DVector V2 = new C2DVector(Vector);
            V2.Multiply(-0.5);
            Line.Move(V2);

            // Now just project the line onto the interval.
            Line.Project(Vector,  Interval);
        }
コード例 #27
0
        /// <summary>
        /// Distance to a line, returns the closest point on the circle and the line.
        /// </summary>
        /// <param name="Line">Line to calculate the distance to.</param> 
        /// <param name="ptOnThis">Closest point on the circle to recieve the result.</param> 
        /// <param name="ptOnOther">Closest point on the line to recieve the result.</param> 
        public double Distance(C2DLine Line,  C2DPoint ptOnThis,  C2DPoint ptOnOther)
        {
            CInterval ProjInt = new CInterval();
            Project(Line,  ProjInt);

            if (ProjInt.dMax < 0)
            {
                // This means that the circle projects entirely "below" the line so the nearest point
                // To this is the first point on the line and there are no interections.
                ptOnOther.Set(Line.point);

                return Distance(Line.point,  ptOnThis);
            }

            double dLength = Line.GetLength();

            if (ProjInt.dMin > dLength)
            {
                // This means that the circle projects entirely "above" the line so the nearest point
                // To this is the second point on the line and there are no interections.
                C2DPoint ptClosest = new C2DPoint(Line.GetPointTo());
                ptOnOther.Set( ptClosest );
                return Distance(ptClosest,  ptOnThis);
            }

            // Now find out if there's an intersection.
            List<C2DPoint> IntPts = new List<C2DPoint>();
            if (Crosses(Line,  IntPts))
            {
                ptOnThis.Set( IntPts[0]);
                ptOnOther.Set( IntPts[0]);

                return 0;
            }

            // Now find out if the line is entirely inside
            if (ProjInt.dMin > 0 && ProjInt.dMax < dLength && this.Contains(Line.point))
            {
                double d1 = Distance(Line.point,  ptOnThis);
                C2DPoint ptThisTemp = new C2DPoint();
                double d2 = Distance(Line.GetPointTo(),  ptThisTemp);
                Debug.Assert(d1 < 0 && d2 < 0);
                if (d2 > d1) // NOTE USE OF > AS d2 and d1 are -ve.
                {
                    ptOnThis.Set(ptThisTemp);
                    ptOnOther.Set(Line.GetPointTo());
                    return d2;
                }
                else
                {
                    ptOnOther.Set(Line.point);
                    return d1;
                }
            }

            // We now know the line is entirely outside.
            // Now find out if this is closest to a point on the line.
            double dCenOnLine = (ProjInt.dMax + ProjInt.dMin) / 2.0;

            if (dCenOnLine > 0)
            {
                if (dCenOnLine < dLength)
                {
                    // The centre is projected on the line
                    double dFactor = dCenOnLine / dLength;

                    C2DVector vProj = new C2DVector(Line.vector);
                    vProj.Multiply( dFactor);
                    C2DPoint ptOnLine = new C2DPoint( Line.point.GetPointTo(vProj));

                    ptOnOther.Set( ptOnLine );

                    return Distance(ptOnLine,  ptOnThis);
                }
                else
                {
                    // The centre is projected above the line.
                    C2DPoint ptClosest = new C2DPoint (Line.GetPointTo());
                    ptOnOther.Set(ptClosest);
                    return Distance(ptClosest,  ptOnThis);
                }
            }
            else
            {
                // This means that the circle projects entirely "below" the line.
                ptOnOther.Set( Line.point);
                return Distance(Line.point,  ptOnThis);
            }
        }
コード例 #28
0
 /// <summary>
 /// Projection onto the Vector.
 /// </summary>
 /// <param name="Vector">Vector to project on.</param> 
 /// <param name="Interval">Ouput. Projection.</param> 
 public override void Project(C2DVector Vector, CInterval Interval)
 {
     P1.Project(Vector,  Interval);
     Interval.ExpandToInclude(P2.Project(Vector));
     Interval.ExpandToInclude(P3.Project(Vector));
 }
コード例 #29
0
 /// <summary>
 /// Projects this onto the line given.
 /// </summary>
 /// <param name="Line">Line to project on.</param>
 /// <param name="Interval">Ouput. Projection.</param>
 public override void Project(C2DLine Line, CInterval Interval)
 {
     P1.Project(Line, Interval);
     Interval.ExpandToInclude(P2.Project(Line));
     Interval.ExpandToInclude(P3.Project(Line));
 }
コード例 #30
0
 /// <summary>
 /// True if this contains the other
 /// </summary>
 public bool Contains(CInterval Other)
 {
     return(Contains(Other.dMin) && Contains(Other.dMax));
 }
コード例 #31
0
ファイル: C2DBase.cs プロジェクト: micrak/rakomeister-attic
 /// <summary>
 /// Projects this onto the vector provided with the interval on the line returned.
 /// </summary>
 public abstract  void Project(C2DVector Vector,  CInterval Interval);
コード例 #32
0
 /// <summary>
 /// True if this overlaps the other
 /// </summary>
 public bool Overlaps(CInterval Other)
 {
     return (!IsBelow(Other) && !IsAbove(Other));
 }
コード例 #33
0
 /// <summary>
 /// True if this is entirely above the other
 /// </summary>
 public bool IsAbove(CInterval Other)
 {
     return(dMin > Other.dMax);
 }
コード例 #34
0
ファイル: C2DRect.cs プロジェクト: micrak/rakomeister-attic
        /// <summary>
        /// Projection onto the Vector.
        /// </summary>
        /// <param name="Vector">Vector to project on.</param> 
        /// <param name="Interval">Ouput. Projection.</param> 
        public override void Project(C2DVector Vector,  CInterval Interval)
        {
	        this.TopLeft.Project( Vector,  Interval);
	        Interval.ExpandToInclude( BottomRight.Project( Vector));
	        C2DPoint TR = new C2DPoint( BottomRight.x,   TopLeft.y);
            C2DPoint BL = new C2DPoint(TopLeft.x, BottomRight.y);
	        Interval.ExpandToInclude( TR.Project( Vector));
	        Interval.ExpandToInclude( BL.Project( Vector));

        }
コード例 #35
0
 /// <summary>
 /// True if this is entirely below the other
 /// </summary>
 public bool IsBelow(CInterval Other)
 {
     return(dMax < Other.dMin);
 }
コード例 #36
0
 /// <summary>
 /// Projection onto the Vector.
 /// </summary>
 /// <param name="Vector">Vector to project on.</param>
 /// <param name="Interval">Ouput. Projection.</param>
 public override void Project(C2DVector Vector, CInterval Interval)
 {
     P1.Project(Vector, Interval);
     Interval.ExpandToInclude(P2.Project(Vector));
     Interval.ExpandToInclude(P3.Project(Vector));
 }
コード例 #37
0
 /// <summary>
 /// True if this contains the other
 /// </summary>
 public bool Contains(CInterval Other)
 {
     return (   Contains(Other.dMin) && Contains (Other.dMax)   );
 }
コード例 #38
0
        /// <summary>
        /// Projection onto the vector.
        /// </summary>
        /// <param name="Vector">The vector.</param>
        /// <param name="Interval">Output. The interval.</param>
        public override void Project(C2DVector Vector, CInterval Interval)
        {
	        if(Lines.Count == 0)
		        return;

	        Lines[0].Project(Vector, Interval);

	        for (int i = 1; i < Lines.Count; i++)
	        {
		        CInterval LineInt = new CInterval();
		        Lines[i].Project(Vector, LineInt);
		        Interval.ExpandToInclude( LineInt );
	        }
        }
コード例 #39
0
 /// <summary>
 /// Assignement
 /// </summary>
 public void Set(CInterval Other)
 {
     dMax = Other.dMax;
     dMin = Other.dMin;
 }
コード例 #40
0
 /// <summary>
 /// Projection onto the line.
 /// </summary>
 /// <param name="Line">Line to project this on.</param> 
 /// <param name="Interval">Interval to recieve the result.</param> 
 public void Project(C2DLine Line, CInterval Interval) 
 {
     _Rim.Project(Line, Interval);
 }
コード例 #41
0
 /// <summary>
 /// True if this overlaps the other
 /// </summary>
 public bool Overlaps(CInterval Other)
 {
     return(!IsBelow(Other) && !IsAbove(Other));
 }
コード例 #42
0
 /// <summary>
 /// Projects the point on the vector given returning a distance along the vector.
 /// </summary>
 /// <param name="Vector">The vector to project this on.</param>
 /// <param name="Interval">The interval to recieve the result. 
 /// Both the min and max of the interval will be set to the result.</param>
 public override void Project(C2DVector Vector,  CInterval Interval)
 {
     Interval.dMax = Project(Vector);
     Interval.dMin = Interval.dMax;
 }
コード例 #43
0
ファイル: C2DLine.cs プロジェクト: micrak/rakomeister-attic
        /// <summary>
        /// Projection onto a vector.
        /// </summary>
        /// <param name="Vector">The vector to project this on.</param>
        /// <param name="Interval">Output. The interval.</param>
        public override void Project(C2DVector Vector,  CInterval Interval) 
        {
	        double dP1 = point.Project(Vector);
	        Interval.dMax = dP1;
	        Interval.dMin = dP1;
	        Interval.ExpandToInclude( GetPointTo().Project( Vector) );
        }
コード例 #44
0
 /// <summary>
 /// True if this is entirely below the other
 /// </summary>
 public bool IsBelow(CInterval Other)
 {
     return dMax < Other.dMin;
 }
コード例 #45
0
 /// <summary>
 /// Assignement
 /// </summary>
 public void Set(CInterval Other)
 {
     dMax = Other.dMax;
     dMin = Other.dMin;
 }
コード例 #46
0
 /// <summary>
 /// True if this is entirely above the other
 /// </summary>
 public bool IsAbove(CInterval Other)
 {
     return  dMin > Other.dMax;
 }
コード例 #47
0
ファイル: C2DPoint.cs プロジェクト: kasznare/DIP1
 /// <summary>
 /// Projects the point on the vector given returning a distance along the vector.
 /// </summary>
 /// <param name="Line">The vector to project this on.</param>
 /// <param name="Interval">The interval to recieve the result.
 /// Both the min and max of the interval will be set to the result.</param>
 public override void Project(C2DLine Line, CInterval Interval)
 {
     Interval.dMax = Project(Line);
     Interval.dMin = Interval.dMax;
 }
コード例 #48
0
 /// <summary>
 /// Projects this onto the line given.
 /// </summary>
 /// <param name="Line">Line to project on.</param> 
 /// <param name="Interval">Ouput. Projection.</param> 
 public override void Project(C2DLine Line, CInterval Interval)
 {
     P1.Project(Line,  Interval);
     Interval.ExpandToInclude(P2.Project(Line));
     Interval.ExpandToInclude(P3.Project(Line));
 }
コード例 #49
0
ファイル: C2DBase.cs プロジェクト: kasznare/DIP1
 /// <summary>
 /// Projects this onto the line provided with the interval on the line returned.
 /// </summary>
 public abstract void Project(C2DLine Line, CInterval Interval);
コード例 #50
0
ファイル: C2DBase.cs プロジェクト: kasznare/DIP1
 /// <summary>
 /// Projects this onto the vector provided with the interval on the line returned.
 /// </summary>
 public abstract void Project(C2DVector Vector, CInterval Interval);
コード例 #51
0
 /// <summary>
 /// True is this overlaps the other.
 /// </summary>
 /// <param name="Other"></param>
 /// <param name="Overlap"></param>
 /// <returns></returns>
 public bool Overlaps(CInterval Other, CInterval Overlap)
 {
     if (Other.dMin < dMax &&
         Other.dMax > dMin)
     {
         Overlap.dMin = Math.Max(Other.dMin, dMin);
         Overlap.dMax = Math.Min(Other.dMax, dMax);
         return true;
     }
     else
     {
         return false;
     }
 }
コード例 #52
0
ファイル: C2DLine.cs プロジェクト: micrak/rakomeister-attic
        /// <summary>
        /// Projection onto a line.
        /// </summary>
        /// <param name="TestLine">The line to project this on.</param>
        /// <param name="Interval">Output. The interval.</param>
        public override void Project(C2DLine TestLine,  CInterval Interval)
        {
            double dP1 = point.Project(TestLine);
	        Interval.dMax = dP1;
	        Interval.dMin = dP1;
            Interval.ExpandToInclude(GetPointTo().Project(TestLine));
        }
コード例 #53
0
 /// <summary>
 /// Expands the interval to include the other
 /// </summary>
 public void ExpandToInclude( CInterval Other)
 {
     if (Other.dMax > dMax) dMax = Other.dMax;
     if (Other.dMin < dMin) dMin = Other.dMin;
 }
コード例 #54
0
ファイル: C2DLine.cs プロジェクト: micrak/rakomeister-attic
        /// <summary>
        /// True if part of this line is above the other. Returns the point 
        /// on this and on the other.
        /// </summary>
        /// <param name="Other"></param>
        /// <param name="dVerticalDistance"></param>
        /// <param name="ptOnThis"></param>
        /// <param name="ptOnOther"></param>
        /// <returns></returns>
        public bool OverlapsAbove(C2DLine Other, ref double dVerticalDistance, 
									        C2DPoint ptOnThis, C2DPoint ptOnOther)
        {
	        // Get the 2 points for both lines
	        C2DPoint OtherTo = new C2DPoint(Other.point.x + Other.vector.i, Other.point.y + Other.vector.j);
	        C2DPoint ThisTo = new C2DPoint(point.x + vector.i, point.y + vector.j);
	        // Make an interval for both in the x plane
	        CInterval iThis = new CInterval( point.x, point.x);
	        iThis.ExpandToInclude( ThisTo.x );

	        CInterval iOther = new CInterval( Other.point.x, Other.point.x);
	        iOther.ExpandToInclude( OtherTo.x );
	        // This is an interval for the overlap between the 2
	        CInterval iOverlap = new CInterval();
	        // If there is an overlap...
	        if (iThis.Overlaps(iOther, iOverlap))
	        {
		        double dThisYMin;
		        double dThisYMax;

		        double dOtherYMin;
		        double dOtherYMax;
		        // If the line is vertical then y at the x min / max can be set to the ends of the line.
		        if (vector.i == 0)
		        {
			        dThisYMin = point.y;
			        dThisYMax = ThisTo.y;
		        }
		        else	// otherwise, caluclate the y values at the interval ends
		        {
			        dThisYMin = GetY(iOverlap.dMin);
			        dThisYMax = GetY(iOverlap.dMax);
		        }
		        // Now do the same for the other line
		        if (Other.vector.i == 0)
		        {
			        dOtherYMin = Other.point.y;
			        dOtherYMax = OtherTo.y;
		        }
		        else
		        {
			        dOtherYMin = Other.GetY(iOverlap.dMin);
			        dOtherYMax = Other.GetY(iOverlap.dMax);
		        }
        		
		        // Now find the distance between the 2 at the ends
		        double dDistMin = dThisYMin - dOtherYMin;
		        double dDistMax = dThisYMax - dOtherYMax;
		        // If they are both > 0 then no intersection
		        if ( (dDistMin > 0) && (dDistMax > 0))
		        {
			        dDistMin = Math.Abs( dDistMin);
                    dDistMax = Math.Abs(dDistMax);
			        // find which one is smallest
			        if ( dDistMin > dDistMax)
			        {	
				        dVerticalDistance = dDistMax;	// distance at the max is smallest
				        ptOnThis.x = iOverlap.dMax;
				        ptOnThis.y = dThisYMax;
				        ptOnOther.x = iOverlap.dMax;
				        ptOnOther.y = dOtherYMax;
			        }
			        else
			        {
				        dVerticalDistance = dDistMin;  // distance at the min is smallest
				        ptOnThis.x = iOverlap.dMin;
				        ptOnThis.y = dThisYMin;
				        ptOnOther.x = iOverlap.dMin;
				        ptOnOther.y = dOtherYMin;
			        }

			        return true;
		        }	
		        else if ( (dDistMin < 0) && (dDistMax < 0)) // This is below.
		        {
			        return false;
		        }
		        else
		        {
			        // find the intersection.
			        dVerticalDistance = 0;
			        C2DPointSet pts = new C2DPointSet();
			        if(this.Crosses(Other, pts))
			        {
				        ptOnThis = pts[0];
				        ptOnOther = ptOnThis;
			        }
			        else
			        {
				        Debug.Assert(false);
			        }
		        }
        	
		        return true;
	        }
	        else
	        {
		        return false;
	        }

        }
コード例 #55
0
ファイル: C2DPoint.cs プロジェクト: kasznare/DIP1
 /// <summary>
 /// Projects the point on the vector given returning a distance along the vector.
 /// </summary>
 /// <param name="Vector">The vector to project this on.</param>
 /// <param name="Interval">The interval to recieve the result.
 /// Both the min and max of the interval will be set to the result.</param>
 public override void Project(C2DVector Vector, CInterval Interval)
 {
     Interval.dMax = Project(Vector);
     Interval.dMin = Interval.dMax;
 }