Bouger BaseBJ OK
This commit is contained in:
		@@ -4,7 +4,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Drawing;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Numerics;
 | 
				
			||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
using System.Threading.Tasks;
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
using System.Windows.Forms;
 | 
					using System.Windows.Forms;
 | 
				
			||||||
@@ -13,8 +15,9 @@ namespace Bonhomme02
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    class BaseBJ
 | 
					    class BaseBJ
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Peau Haut, Millieux, Bas, parent;
 | 
					        enum Articulation {  Epaule, Coude, Poignet, Bassin = Epaule, Genou = Coude, Cheville = Poignet };
 | 
				
			||||||
        double angleHaut, angleMillieux, angleBas, longueur;
 | 
					        public Peau Haut, Millieux, Bas, parent;
 | 
				
			||||||
 | 
					        double longueur;
 | 
				
			||||||
        public BaseBJ()
 | 
					        public BaseBJ()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -22,7 +25,7 @@ namespace Bonhomme02
 | 
				
			|||||||
        public BaseBJ(PictureBox Hebergeur, ref Peau parent, Peau bas, double longueur, double epaisseur, double angle)
 | 
					        public BaseBJ(PictureBox Hebergeur, ref Peau parent, Peau bas, double longueur, double epaisseur, double angle)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            this.parent = parent;
 | 
					            this.parent = parent;
 | 
				
			||||||
            angleHaut = angleMillieux = angleBas = 0;
 | 
					            this.longueur = longueur;
 | 
				
			||||||
            this.Haut = new Peau(Hebergeur, ref parent, longueur/2, epaisseur, angle);
 | 
					            this.Haut = new Peau(Hebergeur, ref parent, longueur/2, epaisseur, angle);
 | 
				
			||||||
            this.Millieux = new Peau(Hebergeur, ref this.Haut, longueur/2, epaisseur, angle);
 | 
					            this.Millieux = new Peau(Hebergeur, ref this.Haut, longueur/2, epaisseur, angle);
 | 
				
			||||||
            this.Bas = bas;
 | 
					            this.Bas = bas;
 | 
				
			||||||
@@ -34,6 +37,62 @@ namespace Bonhomme02
 | 
				
			|||||||
            Millieux.Afficher(handle);
 | 
					            Millieux.Afficher(handle);
 | 
				
			||||||
            Bas.Afficher(handle);
 | 
					            Bas.Afficher(handle);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        public void Cacher(IntPtr handle)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Haut.Cacher(handle);
 | 
				
			||||||
 | 
					            Millieux.Cacher(handle);
 | 
				
			||||||
 | 
					            Bas.Cacher(handle);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public double TrouverAngleHaut(Point pt)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Point ptOrigine = parent.Coordonnee + parent.longueur;
 | 
				
			||||||
 | 
					            Complex vecteur = new Complex(pt.X- ptOrigine.X, pt.Y- ptOrigine.Y);
 | 
				
			||||||
 | 
					            return vecteur.Phase;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public double TrouverAngleMillieux(Point pt)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Point ptOrigine = Millieux.Coordonnee;
 | 
				
			||||||
 | 
					            Complex vecteur = new Complex(pt.X - ptOrigine.X, pt.Y - ptOrigine.Y);
 | 
				
			||||||
 | 
					            return vecteur.Phase;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public Point TouverPointMillieux(Point bas)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Point H = Haut.Coordonnee;
 | 
				
			||||||
 | 
					            //Point M = new Point() ;    //Inconnue
 | 
				
			||||||
 | 
					            Point B = new Point(bas.X-H.X, bas.Y-H.Y); //On part du principe que H est 0;0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Complex tt = new Complex(B.X, B.Y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            double a = Math.Sqrt(4 * Math.Pow(Haut.longueur.ABS, 2) - Math.Pow(B.X, 2) - Math.Pow(B.Y, 2));
 | 
				
			||||||
 | 
					            double b = Math.Sqrt(Math.Pow(B.X, 2) + Math.Pow(B.Y, 2));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            double cooMX = (B.Y * a + B.X * b);
 | 
				
			||||||
 | 
					                cooMX /= 2*b;
 | 
				
			||||||
 | 
					            double cooMY = -(B.X * a - B.Y * b);
 | 
				
			||||||
 | 
					            cooMY /= 2 * b;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Complex t = new Complex(cooMX, cooMY);
 | 
				
			||||||
 | 
					            cooMX += H.X;
 | 
				
			||||||
 | 
					            cooMY += H.Y;
 | 
				
			||||||
 | 
					            int xx = (int)Math.Round(cooMX);
 | 
				
			||||||
 | 
					            int yy = (int)Math.Round(cooMY);
 | 
				
			||||||
 | 
					            return new Point(xx, yy);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        public void Bouger(int X, int Y)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Point nouveauPtBas = new Point(Bas.X + X, Bas.Y + Y);
 | 
				
			||||||
 | 
					            Point nouveauPtMillieux = TouverPointMillieux(nouveauPtBas);
 | 
				
			||||||
 | 
					            if(nouveauPtMillieux.X == 0 && nouveauPtMillieux.Y == 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Haut.Angle = TrouverAngleHaut(nouveauPtMillieux);
 | 
				
			||||||
 | 
					                Millieux.Angle = TrouverAngleMillieux(nouveauPtBas);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,9 +58,17 @@ namespace Bonhomme02
 | 
				
			|||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region Accesseurs
 | 
					        #region Accesseurs
 | 
				
			||||||
 | 
					        public virtual Point Coordonnee
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return coordonnee;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public int X
 | 
					        public int X
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get { return coordonnee.X; }
 | 
					            get { return Coordonnee.X; }
 | 
				
			||||||
            set
 | 
					            set
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (value < 0) { coordonnee.X = 0; }
 | 
					                if (value < 0) { coordonnee.X = 0; }
 | 
				
			||||||
@@ -71,7 +79,7 @@ namespace Bonhomme02
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public int Y
 | 
					        public int Y
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get { return coordonnee.Y; }
 | 
					            get { return Coordonnee.Y; }
 | 
				
			||||||
            set
 | 
					            set
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (value < 0) { coordonnee.Y = 0; }
 | 
					                if (value < 0) { coordonnee.Y = 0; }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,13 +29,16 @@ namespace Bonhomme02
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void timerImage_Tick(object sender, EventArgs e)
 | 
					        private void timerImage_Tick(object sender, EventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (/*this.bonhomme.Origine.X + this.bonhomme.Lhorizontal >= this.TV.Width*/1==1)
 | 
					            if (/*this.bonhomme.Origine.X + this.bonhomme.Lhorizontal >= this.TV.Width*/1==2)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                this.timerImage.Stop();
 | 
					                this.timerImage.Stop();
 | 
				
			||||||
                this.btnStopDeplacerCTick.Enabled = false;
 | 
					                this.btnStopDeplacerCTick.Enabled = false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					                jambe.Cacher(this.TV.Handle);
 | 
				
			||||||
 | 
					                jambe.Bouger(+3, -3);
 | 
				
			||||||
 | 
					                jambe.Afficher(this.TV.Handle);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -57,8 +60,13 @@ namespace Bonhomme02
 | 
				
			|||||||
            corp = new Peau(this.TV, 80, 80, 100, 40, Math.PI / 2);
 | 
					            corp = new Peau(this.TV, 80, 80, 100, 40, Math.PI / 2);
 | 
				
			||||||
            pied = new Pied(this.TV, 25, 10, 0);
 | 
					            pied = new Pied(this.TV, 25, 10, 0);
 | 
				
			||||||
            jambe = new BaseBJ(this.TV, ref corp, pied, 80, 10, Math.PI / 2);
 | 
					            jambe = new BaseBJ(this.TV, ref corp, pied, 80, 10, Math.PI / 2);
 | 
				
			||||||
 | 
					            jambe.Haut.Angle = Math.PI/4;
 | 
				
			||||||
 | 
					            jambe.Millieux.Angle = Math.PI/2 + Math.PI/8 ;
 | 
				
			||||||
            jambe.Afficher(this.TV.Handle);
 | 
					            jambe.Afficher(this.TV.Handle);
 | 
				
			||||||
            corp.Afficher(this.TV.Handle);
 | 
					            corp.Afficher(this.TV.Handle);
 | 
				
			||||||
 | 
					            this.btnStopDeplacerCTick.Enabled = true;
 | 
				
			||||||
 | 
					            this.timerImage.Start();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } 
 | 
					    } 
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,7 +72,7 @@ namespace Bonhomme02
 | 
				
			|||||||
         */
 | 
					         */
 | 
				
			||||||
        #region accesseur
 | 
					        #region accesseur
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Point Coordonnee
 | 
					        public override Point Coordonnee
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get
 | 
					            get
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@@ -84,7 +84,18 @@ namespace Bonhomme02
 | 
				
			|||||||
                    return base.coordonnee;
 | 
					                    return base.coordonnee;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        public double Angle
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return longueur.Angle;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            set
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                epaisseur.Angle = value; //Pour que le parent de eppaiseur soit mis a jour
 | 
				
			||||||
 | 
					                                         //Si on met longueur epaisseur ne sera pas mis a jour
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public virtual Point CIG{ get{ return Coordonnee - epaisseur; }}
 | 
					        public virtual Point CIG{ get{ return Coordonnee - epaisseur; }}
 | 
				
			||||||
        public virtual Point CID{ get{ return Coordonnee + epaisseur; }}
 | 
					        public virtual Point CID{ get{ return Coordonnee + epaisseur; }}
 | 
				
			||||||
@@ -146,7 +157,7 @@ namespace Bonhomme02
 | 
				
			|||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        gr.FillClosedCurve(new SolidBrush(base.Fond), l);
 | 
					                        gr.FillClosedCurve(new SolidBrush(base.Fond), l);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    gr.DrawClosedCurve(new Pen(Brushes.Black), l);
 | 
					                    gr.DrawClosedCurve(new Pen(base.Fond), l);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            catch
 | 
					            catch
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,10 @@ namespace Bonhomme02
 | 
				
			|||||||
            set
 | 
					            set
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (parent != null)
 | 
					                if (parent != null)
 | 
				
			||||||
                    Console.WriteLine("Erreur : La définition de l'angle d'un enfant ne peut-être fait !");
 | 
					                {
 | 
				
			||||||
 | 
					                    parent.vecteur = Complex.FromPolarCoordinates(parent.vecteur.Magnitude, value);
 | 
				
			||||||
 | 
					                    vecteur = Complex.FromPolarCoordinates(vecteur.Magnitude, parent.Angle - Math.PI / 2);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                    vecteur = Complex.FromPolarCoordinates(vecteur.Magnitude, value);
 | 
					                    vecteur = Complex.FromPolarCoordinates(vecteur.Magnitude, value);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -37,14 +40,22 @@ namespace Bonhomme02
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            get
 | 
					            get
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return (int)vecteur.Real;
 | 
					                return (int)Math.Round(vecteur.Real);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public int Y
 | 
					        public int Y
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get
 | 
					            get
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return (int)vecteur.Imaginary;
 | 
					                return (int)Math.Round(vecteur.Imaginary);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public double ABS
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return vecteur.Magnitude;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user