Пример #1
0
        public static List<MathVecteur> ListVecteursMatrice(Double Diametre, Double Pas, TypeReseau_e TypeReseau)
        {
            List<MathPoint> pListePoints = new List<MathPoint>();

            int pNbH;
            int pNbV;
            Double pDimH = Diametre;
            Double pDimV = Diametre;
            Double pDecalH;
            Double pDecalV;

            pNbH = (int)Math.Truncate(pDimH / Pas);
            pNbV = (int)Math.Truncate(pDimV / Pas);
            pDecalH = (pDimH - (pNbH * Pas)) * 0.5;
            pDecalV = (pDimV - (pNbV * Pas)) * 0.5;

            MathPoint PtCentre = new MathPoint(pDimH * 0.5, pDimV * 0.5);

            switch (TypeReseau)
            {
                case TypeReseau_e.Carre:
                    for (int y = 0; y <= pNbV; y++) for (int x = 0; x <= pNbH; x++)
                        {
                            MathPoint pPt;
                            pPt.X = pDecalH + (x * Pas);
                            pPt.Y = pDecalV + (y * Pas);
                            pListePoints.Add(pPt);
                        }
                    break;

                case TypeReseau_e.Hexagonal:
                    Double pCoteV = (pDimV / Math.Cos(Math.PI / 6.0));
                    MathPoint Pt1 = new MathPoint(0.0, pCoteV / 4.0);
                    MathPoint Pt2 = new MathPoint(pDimH * 0.5, 0.0);
                    MathPoint Pt3 = new MathPoint(pDimH, pCoteV / 4.0);
                    MathPoint Pt4 = new MathPoint(pDimH, pCoteV * 3.0 / 4.0);
                    MathPoint Pt5 = new MathPoint(pDimH * 0.5, pCoteV);
                    MathPoint Pt6 = new MathPoint(0.0, pCoteV * 3.0 / 4.0);
                    PtCentre.Y = pCoteV * 0.5;

                    for (int y = 0; y <= pNbV; y++) for (int x = 0; x <= pNbH; x++)
                        {
                            MathPoint pPt;
                            pPt.X = pDecalH + (x * Pas);
                            pPt.Y = pDecalV + (y * Pas);

                            Boolean T = true;
                            MathPoint PtTest = pPt;

                            T = T & SensHoraire(Pt1, Pt2, PtTest);
                            T = T & SensHoraire(Pt2, Pt3, PtTest);
                            T = T & SensHoraire(Pt4, Pt5, PtTest);
                            T = T & SensHoraire(Pt5, Pt6, PtTest);

                            if (T)
                                pListePoints.Add(pPt);
                        }
                    break;
            }

            List<MathVecteur> pListeVecteurs = new List<MathVecteur>();

            foreach (MathPoint Pt in pListePoints)
            {
                MathVecteur pV = new MathVecteur(PtCentre, Pt);
                pListeVecteurs.Add(pV);
            }

            return pListeVecteurs;
        }
Пример #2
0
 public void Deplacer(MathVecteur Vec)
 {
     X += Vec.X; Y += Vec.Y;
 }