From 1a34ea5d07dee907b95aa7e570a8a309bb16584c Mon Sep 17 00:00:00 2001 From: adri Date: Wed, 3 Jan 2018 13:22:24 +0100 Subject: [PATCH] Netoyage Bonhomme01 --- Bonhomme01.sln | 25 --- Bonhomme01/App.config | 6 - Bonhomme01/Bonhomme.cs | 88 --------- Bonhomme01/Bonhomme01.csproj | 86 -------- Bonhomme01/Cercle.cs | 179 ----------------- Bonhomme01/Form1.Designer.cs | 111 ----------- Bonhomme01/Form1.cs | 72 ------- Bonhomme01/Jambe.cs | 207 -------------------- Bonhomme01/PointOrigine.cs | 147 -------------- Bonhomme01/Program.cs | 22 --- Bonhomme01/Properties/AssemblyInfo.cs | 36 ---- Bonhomme01/Properties/Resources.Designer.cs | 71 ------- Bonhomme01/Properties/Resources.resx | 117 ----------- Bonhomme01/Properties/Settings.Designer.cs | 30 --- Bonhomme01/Properties/Settings.settings | 7 - Bonhomme01/Rectangle.cs | 206 ------------------- Bonhomme01/Vecteur.cs | 119 ----------- 17 files changed, 1529 deletions(-) delete mode 100644 Bonhomme01.sln delete mode 100644 Bonhomme01/App.config delete mode 100644 Bonhomme01/Bonhomme.cs delete mode 100644 Bonhomme01/Bonhomme01.csproj delete mode 100644 Bonhomme01/Cercle.cs delete mode 100644 Bonhomme01/Form1.Designer.cs delete mode 100644 Bonhomme01/Form1.cs delete mode 100644 Bonhomme01/Jambe.cs delete mode 100644 Bonhomme01/PointOrigine.cs delete mode 100644 Bonhomme01/Program.cs delete mode 100644 Bonhomme01/Properties/AssemblyInfo.cs delete mode 100644 Bonhomme01/Properties/Resources.Designer.cs delete mode 100644 Bonhomme01/Properties/Resources.resx delete mode 100644 Bonhomme01/Properties/Settings.Designer.cs delete mode 100644 Bonhomme01/Properties/Settings.settings delete mode 100644 Bonhomme01/Rectangle.cs delete mode 100644 Bonhomme01/Vecteur.cs diff --git a/Bonhomme01.sln b/Bonhomme01.sln deleted file mode 100644 index e4bccf0..0000000 --- a/Bonhomme01.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27004.2002 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bonhomme01", "Bonhomme01\Bonhomme01.csproj", "{B3C7D374-80DA-45F0-B97F-6320169C1BE7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3C7D374-80DA-45F0-B97F-6320169C1BE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B3C7D374-80DA-45F0-B97F-6320169C1BE7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B3C7D374-80DA-45F0-B97F-6320169C1BE7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B3C7D374-80DA-45F0-B97F-6320169C1BE7}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {C53F0596-CB41-43D0-97DF-706218E42504} - EndGlobalSection -EndGlobal diff --git a/Bonhomme01/App.config b/Bonhomme01/App.config deleted file mode 100644 index 731f6de..0000000 --- a/Bonhomme01/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Bonhomme01/Bonhomme.cs b/Bonhomme01/Bonhomme.cs deleted file mode 100644 index 2541b86..0000000 --- a/Bonhomme01/Bonhomme.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Bonhomme01 -{ - class Bonhomme : Rectangle - { - public Jambe jambe1, jambe2; - Jambe bras1, bras2; - Cercle tete; - int flag = 0; - public Bonhomme(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical) : base(hebergeur, new Point(origine.X, origine.Y+Lhorizontal), Lhorizontal, Lvertical) - { - tete = new Cercle(hebergeur, origine, Lhorizontal, Lhorizontal); - tete.fond = Color.Pink; - origine = new Point(origine.X, origine.Y + Lhorizontal); - jambe1 = new Jambe(hebergeur, new Point(origine.X + 4*(Lhorizontal / 10), origine.Y + Lvertical), (Lhorizontal / 5), Lvertical); - jambe2 = new Jambe(hebergeur, new Point(origine.X + 4*(Lhorizontal / 10), origine.Y + Lvertical), (Lhorizontal / 5), Lvertical); - bras1 = new Jambe(hebergeur, new Point(origine.X + 4 * (Lhorizontal / 10), origine.Y + Lvertical/5), (Lhorizontal / 5), Lvertical); - bras2 = new Jambe(hebergeur, new Point(origine.X + 4 * (Lhorizontal / 10), origine.Y + Lvertical/5), (Lhorizontal / 5), Lvertical); - bras1.Fond = Color.Blue; - bras2.Fond = Color.Blue; - } - - public new void Afficher(IntPtr handle) - { - base.Afficher(handle); - jambe1.Afficher(handle); - jambe2.Afficher(handle); - bras1.Afficher(handle); - bras2.Afficher(handle); - tete.Afficher(handle); - } - public new void Cacher(IntPtr handle) - { - base.Cacher(handle); - jambe1.Cacher(handle); - jambe2.Cacher(handle); - bras1.Cacher(handle); - bras2.Cacher(handle); - tete.Cacher(handle); - } - public void Bouger(int x, int y, Jambe.AngleJambe angleJambe1, Jambe.AngleJambe angleJambe2) - { - if(flag == 0) - jambe1.angleJambe = angleJambe1; - flag = 2; - if (jambe1.angleJambe.AngleBassin == 0 && jambe2.angleJambe.AngleBassin == 0 || 1==1) - { - //jambe1.Monter(1); - jambe1.Avancer(10); - // jambe1.Avancer(10); - // jambe1.Avancer(10); - } - else if (jambe1.angleJambe.AngleBassin != 0 && jambe2.angleJambe.AngleBassin == 0 && 1==2) - { - jambe1.angleJambe.AngleBassin -= 25; - jambe1.angleJambe.AngleCheville -= 25; - jambe1.angleJambe.AngleGenou -= 25; - jambe2.angleJambe.AngleBassin = 1; - } - else - { - - } - /*base.Origine = new Point(base.Origine.X+x, base.Origine.Y+y); - jambe1.Origine = new Point(jambe1.Origine.X + x, jambe1.Origine.Y + y); - jambe1.CentrerPointOrigine(); - jambe1.angleJambe = angleJambe1; - - jambe2.Origine = new Point(jambe2.Origine.X + x, jambe2.Origine.Y + y); - jambe2.CentrerPointOrigine(); - jambe2.angleJambe = angleJambe2; - bras1.Origine = new Point(bras1.Origine.X + x, bras1.Origine.Y + y); - bras2.Origine = new Point(bras2.Origine.X + x, bras2.Origine.Y + y); - bras1.angleJambe = angleJambe1; - bras2.angleJambe = angleJambe2; - bras1.CentrerPointOrigine(); - bras2.CentrerPointOrigine(); - tete.Origine = new Point(tete.Origine.X + x, tete.Origine.Y + y);*/ - } - } -} diff --git a/Bonhomme01/Bonhomme01.csproj b/Bonhomme01/Bonhomme01.csproj deleted file mode 100644 index fd19958..0000000 --- a/Bonhomme01/Bonhomme01.csproj +++ /dev/null @@ -1,86 +0,0 @@ - - - - - Debug - AnyCPU - {B3C7D374-80DA-45F0-B97F-6320169C1BE7} - WinExe - Bonhomme01 - Bonhomme01 - v4.6.1 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - Form - - - Form1.cs - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - \ No newline at end of file diff --git a/Bonhomme01/Cercle.cs b/Bonhomme01/Cercle.cs deleted file mode 100644 index f32e250..0000000 --- a/Bonhomme01/Cercle.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Bonhomme01 -{ - class Cercle - { - private PictureBox hebergeur; - public Color fond = Color.Red; - public Color contour = Color.Black; - public int eppaisseurContour = 1; - public Color backgroud; - public bool remplir = true; - public bool visible = true; - private Point origine, origineRotation; - private Cercle rectParent; - public bool parentFlag = false; - bool setToCenterFlag = false; - public bool memeOrigineOrigineRotation_flag = true; - public int Lhorizontal, Lvertical; - public float angleRotation; - private int decalageY = 0, decalageX = 0; - private int diam; - - - public Cercle(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical) - { - this.hebergeur = hebergeur; - origineRotation = this.origine = origine; - this.Lhorizontal = Lhorizontal; - this.Lvertical = Lvertical; - this.parentFlag = false; - angleRotation = 0; - backgroud = hebergeur.BackColor; - diam = Lhorizontal; - } - public Cercle(PictureBox hebergeur, int Lhorizontal, int Lvertical, ref Cercle rectParent, float angle) - { - this.hebergeur = hebergeur; - this.parentFlag = true; - this.Origine = rectParent.CIG; - this.rectParent = rectParent; - this.Lhorizontal = Lhorizontal; - this.Lvertical = Lvertical; - this.angleRotation = angle; - backgroud = hebergeur.BackColor; - diam = Lhorizontal; - } - public Cercle(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical, float angleRotation) : this(hebergeur, origine, Lhorizontal, Lvertical) - { - this.angleRotation = angleRotation; - } - public Cercle(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical, float angleRotation, Point origineRotation) : this(hebergeur, origine, Lhorizontal, Lvertical, angleRotation) - { - this.origineRotation = origineRotation; - } - #region pointPourRotation - public Vecteur CSG { get { return (new Vecteur(Origine.X, Origine.Y, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } - public Vecteur CSD { get { return (new Vecteur(Origine.X + Lhorizontal, Origine.Y, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } - public Vecteur CIG { get { return (new Vecteur(Origine.X, Origine.Y + Lvertical, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } - public Vecteur CID { get { return (new Vecteur(Origine.X + Lhorizontal, Origine.Y + Lvertical, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } - #endregion - - #region accesseur - public Point Origine - { - get - { - if (parentFlag) - { - return new Point(rectParent.CIG.X + decalageX, rectParent.CIG.Y + decalageY); - } - return new Point(origine.X - decalageX, origine.Y - decalageY); - } - set - { - if (memeOrigineOrigineRotation_flag && !parentFlag) - { - origineRotation = origine = value; - } - else if (parentFlag) - { - origine = value; - } - else if (!parentFlag) - { - origineRotation = origine = value; - } - } - } - public Point OrigineRotation - { - get - { - if (memeOrigineOrigineRotation_flag) - return Origine; - else - return origineRotation; - } - set - { - origineRotation = value; - memeOrigineOrigineRotation_flag = false; - } - } - - public void CentrerPointOrigine() - { - if (parentFlag) - { - decalageX = 0; - decalageY = 0; - Point millieuParent = Vecteur.Millieux(rectParent.CIG, rectParent.CID); - Point millieuxenfant = Vecteur.Millieux(this.CSG, this.CSD); - decalageX = millieuParent.X - millieuxenfant.X; - decalageY = millieuParent.Y - millieuxenfant.Y; - setToCenterFlag = false; - } - else if (!setToCenterFlag || 1 == 1) - { - float old = angleRotation; - angleRotation = 0; - OrigineRotation = Vecteur.Millieux(this.CSG, this.CSD); - setToCenterFlag = true; - angleRotation = old; - } - } - #endregion - - #region methode - public void Afficher(IntPtr handle) - { - if (visible) - { - Graphics gr = Graphics.FromHwnd(handle); - Point[] l = new Point[4] { CSG, CSD, CID, CIG }; - if (remplir) - { - gr.FillEllipse(new SolidBrush(fond), origine.X, origine.Y, diam, diam); - } - gr.DrawEllipse(new Pen(contour, eppaisseurContour), origine.X, origine.Y, diam, diam); - } - } - public void Afficher(IntPtr handle, float angle) - { - this.angleRotation = angle; - if (visible) - { - Graphics gr = Graphics.FromHwnd(handle); - Point[] l = new Point[4] { CSG, CSD, CID, CIG }; - if (remplir) - { - gr.FillEllipse(new SolidBrush(fond), origine.X, origine.Y, diam, diam); - } - gr.DrawEllipse(new Pen(contour, eppaisseurContour), origine.X, origine.Y, diam, diam); - } - } - public void Cacher(IntPtr handle) - { - - if (visible) - { - Graphics gr = Graphics.FromHwnd(handle); - Point[] l = new Point[4] { CSG, CSD, CID, CIG }; - if (remplir) - { - gr.FillEllipse(new SolidBrush(backgroud), origine.X, origine.Y, diam, diam); - } - gr.DrawEllipse(new Pen(backgroud, eppaisseurContour), origine.X, origine.Y, diam, diam); - } - } - #endregion - } -} diff --git a/Bonhomme01/Form1.Designer.cs b/Bonhomme01/Form1.Designer.cs deleted file mode 100644 index ed87e8b..0000000 --- a/Bonhomme01/Form1.Designer.cs +++ /dev/null @@ -1,111 +0,0 @@ -namespace Bonhomme01 -{ - partial class Form1 - { - /// - /// Variable nécessaire au concepteur. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Nettoyage des ressources utilisées. - /// - /// true si les ressources managées doivent être supprimées ; sinon, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Code généré par le Concepteur Windows Form - - /// - /// Méthode requise pour la prise en charge du concepteur - ne modifiez pas - /// le contenu de cette méthode avec l'éditeur de code. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.TV = new System.Windows.Forms.PictureBox(); - this.timerImage = new System.Windows.Forms.Timer(this.components); - this.btnEffacer = new System.Windows.Forms.Button(); - this.btnStopDeplacerCTick = new System.Windows.Forms.Button(); - this.btnCreationCarrosse = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.TV)).BeginInit(); - this.SuspendLayout(); - // - // TV - // - this.TV.Location = new System.Drawing.Point(13, 13); - this.TV.Name = "TV"; - this.TV.Size = new System.Drawing.Size(782, 241); - this.TV.TabIndex = 0; - this.TV.TabStop = false; - // - // timerImage - // - this.timerImage.Interval = 500; - this.timerImage.Tick += new System.EventHandler(this.timerImage_Tick); - // - // btnEffacer - // - this.btnEffacer.Location = new System.Drawing.Point(13, 305); - this.btnEffacer.Name = "btnEffacer"; - this.btnEffacer.Size = new System.Drawing.Size(389, 23); - this.btnEffacer.TabIndex = 10; - this.btnEffacer.Text = "Effacer Tout"; - this.btnEffacer.UseVisualStyleBackColor = true; - this.btnEffacer.Click += new System.EventHandler(this.btnEffacer_Click); - // - // btnStopDeplacerCTick - // - this.btnStopDeplacerCTick.Enabled = false; - this.btnStopDeplacerCTick.Location = new System.Drawing.Point(408, 305); - this.btnStopDeplacerCTick.Name = "btnStopDeplacerCTick"; - this.btnStopDeplacerCTick.Size = new System.Drawing.Size(387, 23); - this.btnStopDeplacerCTick.TabIndex = 9; - this.btnStopDeplacerCTick.Text = "Stop Tick"; - this.btnStopDeplacerCTick.UseVisualStyleBackColor = true; - this.btnStopDeplacerCTick.Click += new System.EventHandler(this.btnStopDeplacerCTick_Click); - // - // btnCreationCarrosse - // - this.btnCreationCarrosse.Location = new System.Drawing.Point(13, 276); - this.btnCreationCarrosse.Name = "btnCreationCarrosse"; - this.btnCreationCarrosse.Size = new System.Drawing.Size(782, 23); - this.btnCreationCarrosse.TabIndex = 11; - this.btnCreationCarrosse.Text = "Creer Carrosse"; - this.btnCreationCarrosse.UseVisualStyleBackColor = true; - this.btnCreationCarrosse.Click += new System.EventHandler(this.btnCreationCarrosse_Click); - // - // EcranAccueil - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(807, 415); - this.Controls.Add(this.btnCreationCarrosse); - this.Controls.Add(this.btnEffacer); - this.Controls.Add(this.btnStopDeplacerCTick); - this.Controls.Add(this.TV); - this.Name = "EcranAccueil"; - this.Text = "Dessins Animés"; - ((System.ComponentModel.ISupportInitialize)(this.TV)).EndInit(); - this.ResumeLayout(false); - - - - } - - #endregion - - private System.Windows.Forms.PictureBox TV; - private System.Windows.Forms.Timer timerImage; - private System.Windows.Forms.Button btnEffacer; - private System.Windows.Forms.Button btnStopDeplacerCTick; - private System.Windows.Forms.Button btnCreationCarrosse; - } -} - diff --git a/Bonhomme01/Form1.cs b/Bonhomme01/Form1.cs deleted file mode 100644 index 92e7b2f..0000000 --- a/Bonhomme01/Form1.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Bonhomme01 -{ - public partial class Form1 : Form - { - private Bonhomme bonhomme; - - private BufferedGraphics bufferG = null; - private Graphics g; - Jambe.AngleJambe angleJ1 = new Jambe.AngleJambe(-45, 45, 0); - Jambe.AngleJambe angleJ2 = new Jambe.AngleJambe(-45, 45, 0); - Jambe.AngleJambe brasJ1 = new Jambe.AngleJambe(-90, -90, -90); - Jambe.AngleJambe brasJ2 = new Jambe.AngleJambe(-90, -90, -90); - public Form1() - { - InitializeComponent(); - // Modification contre le scintillement - Creation d'une mémoire tampon graphique - bufferG = BufferedGraphicsManager.Current.Allocate(TV.CreateGraphics(), TV.DisplayRectangle); - g = bufferG.Graphics; - } - - private void timerImage_Tick(object sender, EventArgs e) - { - if (this.bonhomme.Origine.X + this.bonhomme.Lhorizontal >= this.TV.Width) - { - this.timerImage.Stop(); - this.btnStopDeplacerCTick.Enabled = false; - } - else - { - //this.bonhomme.Cacher(this.TV.Handle); - //angleJ1.AngleBassin += 1; - //angleJ1.AngleCheville = angleJ1.AngleGenou += 2; - //angleJ2.AngleBassin -= 1; - //angleJ2.AngleCheville = angleJ2.AngleGenou -= 2; - this.bonhomme.Cacher(this.TV.Handle); - this.bonhomme.Bouger(1, 0, angleJ1, angleJ2); - this.bonhomme.Afficher(this.TV.Handle); - } - } - - private void btnStopDeplacerCTick_Click(object sender, EventArgs e) - { - this.timerImage.Stop(); - this.btnStopDeplacerCTick.Enabled = false; - } - - private void btnEffacer_Click(object sender, EventArgs e) - { - Graphics gr = Graphics.FromHwnd(this.TV.Handle); - gr.FillRectangle(new SolidBrush(this.TV.BackColor), 0, 0, this.TV.Bounds.Width, this.TV.Bounds.Height); - } - - private void btnCreationCarrosse_Click(object sender, EventArgs e) - { - this.bonhomme = new Bonhomme(TV, TV.Location, 30, 60); - this.bonhomme.Bouger(0, 0, angleJ1, angleJ2); - this.bonhomme.Afficher(this.TV.Handle); - this.btnStopDeplacerCTick.Enabled = true; - this.timerImage.Start(); - } - } -} diff --git a/Bonhomme01/Jambe.cs b/Bonhomme01/Jambe.cs deleted file mode 100644 index b614a9a..0000000 --- a/Bonhomme01/Jambe.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using System.Numerics; - -namespace Bonhomme01 -{ - class Jambe : Rectangle - { - private int etapeMarche = 0; - Rectangle jambeBas, pied; - public Color Fond - { - get - { - return base.fond; - } - set - { - base.fond = jambeBas.fond = pied.fond = value; - } - } - public struct AngleJambe - { - public float AngleBassin; - public float AngleGenou; - public float AngleCheville; - public AngleJambe(float angleBassin, float angleGenou, float angleCheville) - { - this.AngleBassin = angleBassin; - this.AngleGenou = angleGenou; - this.AngleCheville = angleCheville; - } - } - public AngleJambe angleJambe; - public Jambe(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical) : base(hebergeur, origine, Lhorizontal, Lvertical / 2) - { - - Rectangle me = this; - angleJambe = new AngleJambe(0, 0, 0); - base.angleRotation = angleJambe.AngleBassin; - jambeBas = new Rectangle(hebergeur, Lhorizontal, Lvertical / 2, ref me, angleJambe.AngleGenou); - pied = new Rectangle(hebergeur, Lhorizontal * 2, Lvertical / 10, ref jambeBas, angleJambe.AngleCheville); - } - public Jambe(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical, AngleJambe angle) : base(hebergeur, origine, Lhorizontal, Lvertical / 2, angle.AngleBassin) - { - Rectangle me = this; - angleJambe = angle; - jambeBas = new Rectangle(hebergeur, Lhorizontal, Lvertical / 2, ref me, angleJambe.AngleGenou); - pied = new Rectangle(hebergeur, Lhorizontal * 2, Lvertical / 10, ref jambeBas, angleJambe.AngleCheville); - } - public Jambe(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical, AngleJambe angle, Point origineRotation) : base(hebergeur, origine, Lhorizontal, Lvertical / 2, angle.AngleBassin, origineRotation) - { - Rectangle me = this; - angleJambe = angle; - jambeBas = new Rectangle(hebergeur, origine, Lhorizontal, Lvertical / 2, angleJambe.AngleGenou, origineRotation); - pied = new Rectangle(hebergeur, jambeBas.CIG, Lhorizontal * 2, Lvertical / 10, angleJambe.AngleCheville, origineRotation); - } - public new void Afficher(IntPtr handle) - { - base.angleRotation = angleJambe.AngleBassin; - jambeBas.angleRotation = angleJambe.AngleGenou; - pied.angleRotation = angleJambe.AngleCheville; - base.CentrerPointOrigine(); - base.Afficher(handle); - jambeBas.CentrerPointOrigine(); - jambeBas.Afficher(handle); - //pied.CentrerPointOrigine(); - pied.Afficher(handle); - } - public new void Cacher(IntPtr handle) - { - base.angleRotation = angleJambe.AngleBassin; - jambeBas.angleRotation = angleJambe.AngleGenou; - pied.angleRotation = angleJambe.AngleCheville; - - base.Cacher(handle); - jambeBas.Cacher(handle); - pied.Cacher(handle); - } - public float Genou - { - get { return jambeBas.angleRotation; } - set { jambeBas.angleRotation = angleJambe.AngleGenou = value % 360; } - } - public float Cheville - { - get { return pied.angleRotation; } - set { pied.angleRotation = angleJambe.AngleCheville = value % 360; } - } - public void Bouger(int x, int y) - { - //Origine = new Point(Origine.X + x, Origine.Y + y); - // jambeBas.Origine = new Point(jambeBas.Origine.X + x, jambeBas.Origine.Y + y); - // pied.Origine = new Point(pied.Origine.X + x, pied.Origine.Y + y); - } - public void Monter(int x) - { - MajAngle(); - Vecteur l = new Vecteur(new Vecteur(base.CSG, base.CSD).Millieux(), new Vecteur(jambeBas.CIG, jambeBas.CID).Millieux());//Vecteur entre le haut et le bas du pied - Vecteur m = new Vecteur(new Vecteur(base.CSG, base.CSD).Millieux(), new Vecteur(base.CIG, base.CID).Millieux());//Vecteur entre le haut et le genou - // var a = ((l.ABS - x) * (l.ABS - x)); - int lvertical = (int)m.ABS; //var b = (2 * (l.ABS - x) * Lvertical); - Console.WriteLine("L:{0} vert:{1} x:{2}", l.ABS, lvertical, x); - double bla = (Math.Pow((l.ABS - x), 2)) / (2 * (l.ABS) * (lvertical)); - Console.WriteLine("bla:{0}", bla); - double angle = Math.Acos(bla); - angle *= 180; - angle /= Math.PI; - Console.WriteLine(angle); - angleJambe.AngleBassin = (float)-angle; - angleJambe.AngleGenou = (float)angle; - } - public void Avancer(int x) - { - x = 10; - MajAngle(); - Vecteur l = new Vecteur(new Vecteur(base.CSG, base.CSD).Millieux(), new Vecteur(jambeBas.CIG, jambeBas.CID).Millieux());//Vecteur entre le haut et le bas de la jambe - Vecteur m = new Vecteur(new Vecteur(base.CSG, base.CSD).Millieux(), new Vecteur(base.CIG, base.CID).Millieux());//Vecteur entre le haut et le genou - /* Vecteur m = new Vecteur(new Vecteur(base.CSG, base.CSD), new Vecteur(pied.CIG, pied.CID));//Vecteur entre le haut et le bas du pied - // var a = ((l.ABS - x) * (l.ABS - x)); - double lvertical = (new Vecteur(base.CSG, base.CIG)).ABS/* m.ABS*/ - - //try - //{ - - Vecteur vecteurPied = new Vecteur(jambeBas.CIG.X+x, jambeBas.CIG.Y, base.CSG.X, base.CSG.Y);//Vecteur entre le haut et le bas de la jambe - vecteurPied.DeplacerSurOrigine(); - double rayon = m.ABS; - Console.WriteLine("Rayon : " + rayon); - double paramA = Math.Pow(vecteurPied.X, 2) + Math.Pow(vecteurPied.Y, 2); - paramA /= vecteurPied.Y * 2; - Console.WriteLine("pied X : " + vecteurPied.X + " ;; pied Y : " + vecteurPied.Y + " ;; a : " + paramA); - double paramRacineDelta = Math.Pow(paramA, 2) * Math.Pow(vecteurPied.Y, 2); - paramRacineDelta = (Math.Pow(rayon, 2) * (Math.Pow(vecteurPied.X, 2) + Math.Pow(vecteurPied.Y, 2))) - paramRacineDelta; - paramRacineDelta = 2 * Math.Sqrt(paramRacineDelta); - paramRacineDelta /= Math.Abs(vecteurPied.Y); - double pxSurPy = vecteurPied.X / vecteurPied.Y; - double cooGenouX = -2 * paramA * pxSurPy + paramRacineDelta; - cooGenouX /= 2 + 2 * Math.Pow(pxSurPy, 2); - double cooGenouY = paramA - pxSurPy * cooGenouX; - Complex genouComplex = new Complex(cooGenouX, cooGenouY); - - - angleJambe.AngleBassin = -(float)(genouComplex.Phase * 57.2958)%90; - - - Vecteur vecteurGenouPied = new Vecteur(vecteurPied.X, vecteurPied.Y, (int)cooGenouX, (int)cooGenouY); - vecteurGenouPied.DeplacerSurOrigine(); - angleJambe.AngleGenou = (float)(vecteurGenouPied.point.Phase * 57.2958)%90; - - //} - //catch - // { - - // } - - - - - - - - /* - - int lvertical = (int)m.ABS; - Console.WriteLine("DBG1 : m.abs :" + lvertical + " ; angle genou : " + angleJambe.AngleGenou); - - Complex haut = new Complex(base.CSG.X, base.CSG.Y); - Complex Pointgenou; - Complex Pointpied = new Complex(this.pied.CSG.X + x, this.pied.CSG.Y); - Pointpied = Pointpied - haut; - double genouxX, genouY; - double a = Math.Pow(Pointpied.Real, 2) + Math.Pow(Pointpied.Imaginary, 2); - Console.WriteLine("a=" + a + "+++++" + Pointpied.ToString()); - a /= (2 * Pointpied.Imaginary); - - - //ax²+bx+c=0 - double eqa = 1; - double eqb = -Pointpied.Real / (Math.Pow(Pointpied.Imaginary, 2)); - double eqc = (a * Pointpied.Imaginary); eqc /= Math.Pow(Pointpied.Imaginary, 2); eqc -= Math.Pow(lvertical, 2); - double delta = Math.Pow(eqb, 2) - 4 * eqa * eqc; - genouxX = (-eqb) - Math.Sqrt(delta); genouxX /= 2 * eqa; - genouY = a - genouxX * (-Pointpied.Real / Pointpied.Imaginary); - Console.WriteLine("Genou X : {0} ;; Genou Y : {1} ;; COUPUTE ;; Genou X : {2} ;; Genou Y : {3}",Pointpied.ToString(), genouxX, genouxX, genouY); - Pointgenou = new Complex(genouxX, genouY); - angleJambe.AngleBassin = (float)(Pointgenou.Phase); - angleJambe.AngleBassin *= (float)(180 / Math.PI); - //Pointpied = Pointpied - Pointgenou; - angleJambe.AngleGenou = (float)(Pointpied.Phase * 57.2958); - angleJambe.AngleGenou *= (float)(180 / Math.PI); - Console.WriteLine("DBG2 : m.abs :" + lvertical + " ; angle genou : " + angleJambe.AngleGenou);*/ - MajAngle(); - } - private void MajAngle() - { - base.angleRotation = angleJambe.AngleBassin; - jambeBas.angleRotation = angleJambe.AngleGenou; - pied.angleRotation = angleJambe.AngleCheville; - } - } -} diff --git a/Bonhomme01/PointOrigine.cs b/Bonhomme01/PointOrigine.cs deleted file mode 100644 index 7a6ffaf..0000000 --- a/Bonhomme01/PointOrigine.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Windows.Forms; - - -namespace Bonhomme01 -{ - class PointOrigine - { - #region Données membres - private int _X = 0; - private int _Y = 0; - private bool _Visible = true; - private PictureBox _Hebergeur; - private Color _Fond = Color.Silver; - private Color _Crayon = Color.Black; - #endregion - - #region Constructeurs - public PointOrigine() - { - this._Hebergeur = null; - } - - public PointOrigine(PictureBox hebergeur) - { - this._Hebergeur = hebergeur; - this._Fond = hebergeur.BackColor; - } - - public PointOrigine(PictureBox hebergeur, int xy) : this (hebergeur) - { - X = Y = xy; - } - - public PointOrigine(PictureBox hebergeur, int x, int y) : this(hebergeur) - { - X = x; - Y = y; - } - public PointOrigine(int x, int y) - { - X = x; - Y = y; - } - public PointOrigine(PictureBox hebergeur, int xy, Color crayon) : this(hebergeur, xy) - { - Crayon = crayon; - } - - public PointOrigine(PictureBox hebergeur, int x, int y, Color crayon) : this(hebergeur, x, y) - { - Crayon = crayon; - } - #endregion - - #region Accesseurs - public int X - { - get { return _X; } - set - { - if (value < 0) { this._X = 0; } - else if (value > this._Hebergeur.Bounds.Size.Width) { this._X = this._Hebergeur.Bounds.Size.Width; } - else { this._X = value; } - } - } - - public int Y - { - get { return _Y; } - set - { - if (value < 0) { this._Y = 0; } - else if (value > this._Hebergeur.Bounds.Size.Height) { this._Y = this._Hebergeur.Bounds.Size.Height; } - else { this._Y = value; } - } - } - - public bool Visible - { - get { return _Visible; } - set { _Visible = value; } - } - - public Color Fond - { - get { return _Fond; } - set - { - try { _Fond = value; } - catch (Exception) { } - } - } - - public Color Crayon - { - get { return _Crayon; } - set - { - try { _Crayon = value; } - catch (Exception) { } - } - } - - public PictureBox Hebergeur - { - get { return _Hebergeur; } - set { _Hebergeur = value; } - } - - #endregion - - #region Méthodes - public void Bouger(int deplX, int deplY) - { - X += deplX; - Y += deplY; - } - - public virtual void Afficher(IntPtr handle) - { - if (this.Visible) - { - Graphics gr = Graphics.FromHwnd(handle); - gr.FillEllipse(new SolidBrush(Color.Yellow), this.X, this.Y, 6, 6); - gr.DrawEllipse(new Pen(this._Crayon, 2), this.X, this.Y, 6, 6); - } - } - - public virtual void Cacher(IntPtr handle) - { - if (this.Visible) - { - Graphics gr = Graphics.FromHwnd(handle); - gr.FillEllipse(new SolidBrush(this.Fond), this.X, this.Y, 6, 6); - gr.DrawEllipse(new Pen(this.Fond, 2), this.X, this.Y, 6, 6); - } - } - #endregion - } -} diff --git a/Bonhomme01/Program.cs b/Bonhomme01/Program.cs deleted file mode 100644 index d1fed2d..0000000 --- a/Bonhomme01/Program.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Bonhomme01 -{ - static class Program - { - /// - /// Point d'entrée principal de l'application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } - } -} diff --git a/Bonhomme01/Properties/AssemblyInfo.cs b/Bonhomme01/Properties/AssemblyInfo.cs deleted file mode 100644 index eaf05e7..0000000 --- a/Bonhomme01/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// Les informations générales relatives à un assembly dépendent de -// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations -// associées à un assembly. -[assembly: AssemblyTitle("Bonhomme01")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Bonhomme01")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly -// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de -// COM, affectez la valeur true à l'attribut ComVisible sur ce type. -[assembly: ComVisible(false)] - -// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM -[assembly: Guid("b3c7d374-80da-45f0-b97f-6320169c1be7")] - -// Les informations de version pour un assembly se composent des quatre valeurs suivantes : -// -// Version principale -// Version secondaire -// Numéro de build -// Révision -// -// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut -// en utilisant '*', comme indiqué ci-dessous : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Bonhomme01/Properties/Resources.Designer.cs b/Bonhomme01/Properties/Resources.Designer.cs deleted file mode 100644 index 355df07..0000000 --- a/Bonhomme01/Properties/Resources.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Ce code a été généré par un outil. -// Version du runtime :4.0.30319.42000 -// -// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si -// le code est régénéré. -// -//------------------------------------------------------------------------------ - -namespace Bonhomme01.Properties -{ - - - /// - /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. - /// - // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder - // à l'aide d'un outil, tel que ResGen ou Visual Studio. - // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen - // avec l'option /str ou régénérez votre projet VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Bonhomme01.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Remplace la propriété CurrentUICulture du thread actuel pour toutes - /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/Bonhomme01/Properties/Resources.resx b/Bonhomme01/Properties/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/Bonhomme01/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Bonhomme01/Properties/Settings.Designer.cs b/Bonhomme01/Properties/Settings.Designer.cs deleted file mode 100644 index f41253a..0000000 --- a/Bonhomme01/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Bonhomme01.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/Bonhomme01/Properties/Settings.settings b/Bonhomme01/Properties/Settings.settings deleted file mode 100644 index 3964565..0000000 --- a/Bonhomme01/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Bonhomme01/Rectangle.cs b/Bonhomme01/Rectangle.cs deleted file mode 100644 index e026a8e..0000000 --- a/Bonhomme01/Rectangle.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Bonhomme01 -{ - class Rectangle - { - private PictureBox hebergeur; - public Color fond = Color.Red; - public Color contour = Color.Black; - public int eppaisseurContour = 1; - public Color backgroud; - public bool remplir = true; - public bool visible = true; - private Point origine, origineRotation; - - private Rectangle rectParent; - public bool parentFlag = false; - - bool setToCenterFlag = false; - public bool memeOrigineOrigineRotation_flag = true; - public int Lhorizontal, Lvertical; - public float angleRotation; - private int decalageY = 0, decalageX = 0; - - - public Rectangle(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical) - { - this.hebergeur = hebergeur; - origineRotation = this.origine = origine; - this.Lhorizontal = Lhorizontal; - this.Lvertical = Lvertical; - this.parentFlag = false; - angleRotation = 0; - backgroud = hebergeur.BackColor; - } - public Rectangle(PictureBox hebergeur, int Lhorizontal, int Lvertical, ref Rectangle rectParent, float angle) - { - this.hebergeur = hebergeur; - this.parentFlag = true; - this.Origine = rectParent.CIG; - this.rectParent = rectParent; - this.Lhorizontal = Lhorizontal; - this.Lvertical = Lvertical; - this.angleRotation = angle; - backgroud = hebergeur.BackColor; - } - public Rectangle(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical, float angleRotation) : this(hebergeur, origine, Lhorizontal, Lvertical) - { - this.angleRotation = angleRotation; - } - public Rectangle(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical, float angleRotation, Point origineRotation) : this(hebergeur, origine, Lhorizontal, Lvertical, angleRotation) - { - this.origineRotation = origineRotation; - } - #region pointPourRotation - public Vecteur CSG { get { return (new Vecteur(Origine.X, Origine.Y, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } - public Vecteur CSD { get { return (new Vecteur(Origine.X + Lhorizontal, Origine.Y, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } - public Vecteur CIG { get { return (new Vecteur(Origine.X, Origine.Y + Lvertical, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } - public Vecteur CID { get { return (new Vecteur(Origine.X + Lhorizontal, Origine.Y + Lvertical, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } - #endregion - - #region accesseur - public Point Origine - { - get - { - if (parentFlag) - { - return new Point(rectParent.CIG.X+decalageX, rectParent.CIG.Y+decalageY); - } - return new Point(origine.X - decalageX, origine.Y - decalageY); - } - set - { - if(memeOrigineOrigineRotation_flag && !parentFlag) - { - origineRotation = origine = value; - } - else if(parentFlag) - { - origine = value; - } - else if(!parentFlag) - { - origineRotation = origine = value; - } - } - } - public Point OrigineRotation - { - get - { - if (memeOrigineOrigineRotation_flag) - return Origine; - else - return origineRotation; - } - set - { - origineRotation = value; - memeOrigineOrigineRotation_flag = false; - } - } - - - #endregion - - #region methode - public void Afficher(IntPtr handle) - { - if (visible) - { - try - { - Graphics gr = Graphics.FromHwnd(handle); - Point[] l = new Point[4] { CSG, CSD, CID, CIG }; - if (remplir) - { - try - { - gr.FillClosedCurve(new SolidBrush(fond), l); - } - catch - { - - } - - } - gr.DrawClosedCurve(new Pen(contour, eppaisseurContour), l); - } - catch - { - - } - } - } - public void Afficher(IntPtr handle, float angle) - { - this.angleRotation = angle; - if (visible) - { - Graphics gr = Graphics.FromHwnd(handle); - Point[] l = new Point[4] { CSG, CSD, CID, CIG }; - if (remplir) - { - gr.FillClosedCurve(new SolidBrush(fond), l); - } - gr.DrawClosedCurve(new Pen(contour, eppaisseurContour), l); - } - } - public void Cacher(IntPtr handle) - { - try - { - if (visible && 1 == 1) - { - Graphics gr = Graphics.FromHwnd(handle); - Point[] l = new Point[4] { CSG, CSD, CID, CIG }; - if (remplir) - { - gr.FillClosedCurve(new SolidBrush(this.backgroud), l); - } - gr.DrawClosedCurve(new Pen(this.backgroud, eppaisseurContour), l); - } - } - catch - { - - } - } - - public void CentrerPointOrigine() - { - if (parentFlag) - { - float old = angleRotation; - angleRotation = 0; - decalageX = 0; - decalageY = 0; - Point millieuParent = Vecteur.Millieux(rectParent.CIG, rectParent.CID); - Point millieuxenfant = Vecteur.Millieux(this.CSG, this.CSD); - decalageX = millieuParent.X - millieuxenfant.X; - decalageY = millieuParent.Y - millieuxenfant.Y; - OrigineRotation = Vecteur.Millieux(this.CSG, this.CSD); - setToCenterFlag = true; - angleRotation = old; - } - else if (!setToCenterFlag) - { - float old = angleRotation; - angleRotation = 0; - OrigineRotation = Vecteur.Millieux(this.CSG, this.CSD); - setToCenterFlag = true; - angleRotation = old; - } - } - #endregion - - } -} diff --git a/Bonhomme01/Vecteur.cs b/Bonhomme01/Vecteur.cs deleted file mode 100644 index 81401ed..0000000 --- a/Bonhomme01/Vecteur.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Numerics; -using System.Drawing; - -namespace Bonhomme01 -{ - class Vecteur - { - public Complex point; - Complex origine; - Boolean flagDeplacerOrigine; - public int X - { - get { return (int)point.Real; } - } - public int Y - { - get { return (int)point.Imaginary; } - } - public double ABS - { - get - { - if (!flagDeplacerOrigine) - { - DeplacerSurOrigine(); - double abs = point.Magnitude; - RetoursPosition(); - return abs; - } - else - return point.Magnitude; - } - set - { - - } - } - public Vecteur(int x, int y, int xo, int yo) - { - point = new Complex(x, y); - origine = new Complex(xo, yo); - flagDeplacerOrigine = false; - } - public Vecteur(Vecteur a, Vecteur b) - { - point = new Complex(b.X, b.Y); - origine = new Complex(a.X, a.Y); - flagDeplacerOrigine = false; - } - public Vecteur(Point a, Point b) - { - point = new Complex(b.X, b.Y); - origine = new Complex(a.X, a.Y); - flagDeplacerOrigine = false; - } - public Vecteur(int x, int y, int xo, int yo, double degre) - { - point = new Complex(x, y); - origine = new Complex(xo, yo); - flagDeplacerOrigine = false; - RotateDegre(degre); - } - public void RotateDegre(double angle) - { - double radian = (angle%360) * (Math.PI / 180); - point = Complex.Subtract(point, origine); - point = Complex.FromPolarCoordinates(point.Magnitude, point.Phase + radian); - point = Complex.Add(point, origine); - } - public void RotateRadian(float radian) - { - point = Complex.Subtract(point, origine); - point = Complex.Add(point, Complex.FromPolarCoordinates(point.Magnitude, point.Phase + radian)); - point = Complex.Add(point, origine); - } - public static Point Millieux(Vecteur a, Vecteur b) - { - Vecteur pt = new Vecteur(a, b); - pt.DeplacerSurOrigine(); - pt.point = Complex.FromPolarCoordinates(pt.point.Magnitude / 2, pt.point.Phase); - pt.RetoursPosition(); - - return new Point(pt.X, pt.Y); - } - public Point Millieux() - { - DeplacerSurOrigine(); - point = Complex.FromPolarCoordinates(point.Magnitude / 2, point.Phase); - RetoursPosition(); - - return new Point((int)point.Real, (int)point.Imaginary); - } - public void DeplacerSurOrigine() - { if (!flagDeplacerOrigine) - { - flagDeplacerOrigine = true; - point = Complex.Subtract(point, origine); - } - } - public void RetoursPosition() - { - if (flagDeplacerOrigine) - { - flagDeplacerOrigine = false; - point = Complex.Add(point, origine); - } - } - public static implicit operator Point(Vecteur point) - { - return new Point(point.X, point.Y); - } - - } -}