Exemple #1
0
        public void ComputeIntersection()
        {
            DmxVector AC = new DmxVector(mPointA, mPointC);
            DmxVector BD = new DmxVector(mPointB, mPointD);

            mInterectionPoint = BD.GetIntersection(AC);
        }
Exemple #2
0
        public static DmxVector operator *(DmxVector pVector, float Rapport)
        {
            DmxPoint point1 = pVector.Point1;
            DmxPoint point2 = new DmxPoint();

            point2.fX = point1.fX + Rapport * (pVector.Point2.fX - pVector.Point1.fX);
            point2.fY = point1.fY + Rapport * (pVector.Point2.fY - pVector.Point1.fY);

            return(new DmxVector(point1, point2));
        }
Exemple #3
0
 public Poursuit()
 {
     mPointA           = new DmxPoint(40, 40);
     mPointB           = new DmxPoint(200, 40);
     mPointC           = new DmxPoint(200, 200);
     mPointD           = new DmxPoint(40, 200);
     mInterectionPoint = new DmxPoint();
     mCurrentPoint     = new DmxPoint();
     mIsActive         = false;
 }
Exemple #4
0
        public int SetTilt(int pValue)
        {
            if (!mIsActive)
            {
                return(pValue);
            }
            mCurrentPoint.fY = pValue;
            DmxPoint pt = GetRelativePosition();

            return(pt.iY);
        }
Exemple #5
0
        public DmxPoint GetIntersection(DmxVector pVector)
        {
            DmxPoint InterectionPoint = new DmxPoint();

            this.ComputeEquation();
            pVector.ComputeEquation();

            if (!mIsInversed)
            {
                InterectionPoint.fX = (this.B - pVector.B) / (pVector.A - this.A);
                InterectionPoint.fY = this.A * InterectionPoint.fX + this.B;
            }
            else
            {
                InterectionPoint.fY = (this.B - pVector.B) / (pVector.A - this.A);
                InterectionPoint.fX = this.A * InterectionPoint.fY + this.B;
            }
            return(InterectionPoint);
        }
Exemple #6
0
        public DmxPoint GetProjectionPoint(DmxPoint pCommun, DmxVector pProjection)
        {
            DmxPoint pt = new DmxPoint();

            if (pProjection.Point1.fY == pProjection.Point2.fY)
            {
                pt.fY = pProjection.Point1.fY;

                if (this.Point2.fY == this.Point1.fY)
                {
                    pt.fX = this.Point2.fY;
                }
                else
                {
                    pt.fX = (pt.fY - pCommun.fY) * (this.Point2.fX - this.Point1.fX) / (this.Point2.fY - this.Point1.fY) + pCommun.fX;
                }
            }
            else if (pProjection.Point1.fX == pProjection.Point2.fX)
            {
                pt.fX = pProjection.Point1.fX;

                if (this.Point2.fX - this.Point1.fX == 0)
                {
                    pt.fY = this.Point2.fX;
                }
                else
                {
                    pt.fY = (pt.fX - pCommun.fX) * (this.Point2.fY - this.Point1.fY) / (this.Point2.fX - this.Point1.fX) + pCommun.fY;
                }
            }
            else
            {
                throw new Exception("Unexpected");
            }

            return(pt);
        }
Exemple #7
0
 public DmxVector(DmxPoint pPoint1, DmxPoint pPoint2)
 {
     mPoint1     = pPoint1;
     mPoint2     = pPoint2;
     mIsInversed = false;
 }
Exemple #8
0
 public DmxVector()
 {
     mPoint1     = null;
     mPoint2     = null;
     mIsInversed = false;
 }
Exemple #9
0
        public static float operator /(DmxVector Vector1, DmxVector Vector2)
        {
            DmxPoint Rapport = new DmxPoint();

            return(Vector1.GetLongueur() / Vector2.GetLongueur());
        }
Exemple #10
0
        public DmxPoint GetRelativePosition()
        {
            DmxPoint pt_O = new DmxPoint(128, 128);
            DmxPoint pt_P = mCurrentPoint;
            DmxPoint pt_R; //RESULT POINT;

            DmxPoint pt_I = mInterectionPoint;

            DmxPoint pt_A;
            DmxPoint pt_B;

            DmxPoint pt_C;
            DmxPoint pt_D;

            DmxPoint pt_F;
            DmxPoint pt_G;



            DmxVector v_OP;
            DmxVector v_AB;
            DmxVector v_CD;
            DmxVector v_AF;
            DmxVector v_OF;
            DmxVector v_CG;
            DmxVector v_IG;
            DmxVector v_IR;

            if (mCurrentPoint.fY == 128 && mCurrentPoint.fX == 128)
            {
                return(mInterectionPoint);
            }
            else if (mCurrentPoint.fX >= mCurrentPoint.fY && mCurrentPoint.fY < (255 - mCurrentPoint.fX))
            {
                pt_A = new DmxPoint(0, 0);
                pt_B = new DmxPoint(255, 0);

                pt_C = mPointA;
                pt_D = mPointB;


                Console.WriteLine("haut");
            }
            else if (mCurrentPoint.fX >= mCurrentPoint.fY && mCurrentPoint.fY >= (255 - mCurrentPoint.fX))
            {
                pt_A = new DmxPoint(255, 0);
                pt_B = new DmxPoint(255, 255);

                pt_C = mPointB;
                pt_D = mPointC;

                Console.WriteLine("droite");
            }
            else if (mCurrentPoint.fX < mCurrentPoint.fY && mCurrentPoint.fY >= (255 - mCurrentPoint.fX))
            {
                pt_A = new DmxPoint(255, 255);
                pt_B = new DmxPoint(0, 255);

                pt_C = mPointC;
                pt_D = mPointD;
                Console.WriteLine("bas");
            }
            else
            {
                pt_A = new DmxPoint(0, 255);
                pt_B = new DmxPoint(0, 0);

                pt_C = mPointD;
                pt_D = mPointA;
                Console.WriteLine("gauche");
            }


            v_OP = new DmxVector(pt_O, pt_P);
            v_AB = new DmxVector(pt_A, pt_B);
            v_CD = new DmxVector(pt_C, pt_D);


            pt_F = v_OP.GetProjectionPoint(pt_O, v_AB);
            v_AF = new DmxVector(pt_A, pt_F);
            v_OF = new DmxVector(pt_O, pt_F);

            float Rapport = v_AF / v_AB;

            v_CG = v_CD * Rapport;
            pt_G = v_CG.Point2;

            v_IG = new DmxVector(pt_I, pt_G);

            Rapport = v_OP / v_OF;

            v_IR = v_IG * Rapport;

            pt_R = v_IR.Point2;

            return(pt_R);
        }