Commit avent grosse modif pour prÃcision

This commit is contained in:
adriy 2018-01-02 13:04:00 +01:00
parent 06cf062ae7
commit b1837b43da
8 changed files with 191 additions and 90 deletions

View File

@ -48,12 +48,14 @@ namespace Bonhomme01
public void Bouger(int x, int y, Jambe.AngleJambe angleJambe1, Jambe.AngleJambe angleJambe2) public void Bouger(int x, int y, Jambe.AngleJambe angleJambe1, Jambe.AngleJambe angleJambe2)
{ {
if(flag == 0) if(flag == 0)
jambe1.angleJambe = angleJambe1; jambe1.angleJambe = angleJambe1;
flag = 2; flag = 2;
if (jambe1.angleJambe.AngleBassin == 0 && jambe2.angleJambe.AngleBassin == 0 || 1==1) if (jambe1.angleJambe.AngleBassin == 0 && jambe2.angleJambe.AngleBassin == 0 || 1==1)
{ {
//jambe1.Monter(2); //jambe1.Monter(1);
jambe1.Avancer(10); jambe1.Avancer(10);
// jambe1.Avancer(10);
// jambe1.Avancer(10);
} }
else if (jambe1.angleJambe.AngleBassin != 0 && jambe2.angleJambe.AngleBassin == 0 && 1==2) else if (jambe1.angleJambe.AngleBassin != 0 && jambe2.angleJambe.AngleBassin == 0 && 1==2)
{ {

View File

@ -55,7 +55,7 @@
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Jambe.cs" /> <Compile Include="Jambe.cs" />
<Compile Include="PointComplexe.cs" /> <Compile Include="Vecteur.cs" />
<Compile Include="PointOrigine.cs" /> <Compile Include="PointOrigine.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -60,10 +60,10 @@ namespace Bonhomme01
this.origineRotation = origineRotation; this.origineRotation = origineRotation;
} }
#region pointPourRotation #region pointPourRotation
public PointComplexe CSG { get { return (new PointComplexe(Origine.X, Origine.Y, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } public Vecteur CSG { get { return (new Vecteur(Origine.X, Origine.Y, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } }
public PointComplexe CSD { get { return (new PointComplexe(Origine.X + Lhorizontal, 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 PointComplexe CIG { get { return (new PointComplexe(Origine.X, Origine.Y + Lvertical, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } public Vecteur CIG { get { return (new Vecteur(Origine.X, Origine.Y + Lvertical, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } }
public PointComplexe CID { get { return (new PointComplexe(Origine.X + Lhorizontal, 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 #endregion
#region accesseur #region accesseur
@ -115,8 +115,8 @@ namespace Bonhomme01
{ {
decalageX = 0; decalageX = 0;
decalageY = 0; decalageY = 0;
Point millieuParent = PointComplexe.Millieux(rectParent.CIG, rectParent.CID); Point millieuParent = Vecteur.Millieux(rectParent.CIG, rectParent.CID);
Point millieuxenfant = PointComplexe.Millieux(this.CSG, this.CSD); Point millieuxenfant = Vecteur.Millieux(this.CSG, this.CSD);
decalageX = millieuParent.X - millieuxenfant.X; decalageX = millieuParent.X - millieuxenfant.X;
decalageY = millieuParent.Y - millieuxenfant.Y; decalageY = millieuParent.Y - millieuxenfant.Y;
setToCenterFlag = false; setToCenterFlag = false;
@ -125,7 +125,7 @@ namespace Bonhomme01
{ {
float old = angleRotation; float old = angleRotation;
angleRotation = 0; angleRotation = 0;
OrigineRotation = PointComplexe.Millieux(this.CSG, this.CSD); OrigineRotation = Vecteur.Millieux(this.CSG, this.CSD);
setToCenterFlag = true; setToCenterFlag = true;
angleRotation = old; angleRotation = old;
} }

View File

@ -47,7 +47,7 @@
// //
// timerImage // timerImage
// //
this.timerImage.Interval = 40; this.timerImage.Interval = 500;
this.timerImage.Tick += new System.EventHandler(this.timerImage_Tick); this.timerImage.Tick += new System.EventHandler(this.timerImage_Tick);
// //
// btnEffacer // btnEffacer

View File

@ -37,7 +37,7 @@ namespace Bonhomme01
} }
else else
{ {
this.bonhomme.Cacher(this.TV.Handle); //this.bonhomme.Cacher(this.TV.Handle);
//angleJ1.AngleBassin += 1; //angleJ1.AngleBassin += 1;
//angleJ1.AngleCheville = angleJ1.AngleGenou += 2; //angleJ1.AngleCheville = angleJ1.AngleGenou += 2;
//angleJ2.AngleBassin -= 1; //angleJ2.AngleBassin -= 1;

View File

@ -32,33 +32,33 @@ namespace Bonhomme01
public AngleJambe(float angleBassin, float angleGenou, float angleCheville) public AngleJambe(float angleBassin, float angleGenou, float angleCheville)
{ {
this.AngleBassin = angleBassin; this.AngleBassin = angleBassin;
this.AngleGenou= angleGenou; this.AngleGenou = angleGenou;
this.AngleCheville = angleCheville; this.AngleCheville = angleCheville;
} }
} }
public AngleJambe angleJambe; public AngleJambe angleJambe;
public Jambe(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical) : base(hebergeur, origine, Lhorizontal, Lvertical/2) public Jambe(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical) : base(hebergeur, origine, Lhorizontal, Lvertical / 2)
{ {
Rectangle me = this; Rectangle me = this;
angleJambe = new AngleJambe(0, 0, 0); angleJambe = new AngleJambe(0, 0, 0);
base.angleRotation = angleJambe.AngleBassin; base.angleRotation = angleJambe.AngleBassin;
jambeBas = new Rectangle(hebergeur, Lhorizontal, Lvertical/2, ref me, angleJambe.AngleGenou); jambeBas = new Rectangle(hebergeur, Lhorizontal, Lvertical / 2, ref me, angleJambe.AngleGenou);
pied = new Rectangle(hebergeur, Lhorizontal*2, Lvertical/10, ref jambeBas, angleJambe.AngleCheville); 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) public Jambe(PictureBox hebergeur, Point origine, int Lhorizontal, int Lvertical, AngleJambe angle) : base(hebergeur, origine, Lhorizontal, Lvertical / 2, angle.AngleBassin)
{ {
Rectangle me = this; Rectangle me = this;
angleJambe = angle; angleJambe = angle;
jambeBas = new Rectangle(hebergeur, Lhorizontal, Lvertical/2, ref me, angleJambe.AngleGenou); jambeBas = new Rectangle(hebergeur, Lhorizontal, Lvertical / 2, ref me, angleJambe.AngleGenou);
pied = new Rectangle(hebergeur, Lhorizontal * 2, Lvertical/10, ref jambeBas, angleJambe.AngleCheville); 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) 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; Rectangle me = this;
angleJambe = angle; angleJambe = angle;
jambeBas = new Rectangle(hebergeur, origine, Lhorizontal, Lvertical/2, angleJambe.AngleGenou, origineRotation); jambeBas = new Rectangle(hebergeur, origine, Lhorizontal, Lvertical / 2, angleJambe.AngleGenou, origineRotation);
pied = new Rectangle(hebergeur, jambeBas.CIG, Lhorizontal * 2, Lvertical/10, angleJambe.AngleCheville, origineRotation); pied = new Rectangle(hebergeur, jambeBas.CIG, Lhorizontal * 2, Lvertical / 10, angleJambe.AngleCheville, origineRotation);
} }
public new void Afficher(IntPtr handle) public new void Afficher(IntPtr handle)
{ {
@ -85,27 +85,28 @@ namespace Bonhomme01
public float Genou public float Genou
{ {
get { return jambeBas.angleRotation; } get { return jambeBas.angleRotation; }
set { jambeBas.angleRotation = angleJambe.AngleGenou = value%360; } set { jambeBas.angleRotation = angleJambe.AngleGenou = value % 360; }
} }
public float Cheville public float Cheville
{ {
get { return pied.angleRotation; } get { return pied.angleRotation; }
set { pied.angleRotation = angleJambe.AngleCheville =value%360; } set { pied.angleRotation = angleJambe.AngleCheville = value % 360; }
} }
public void Bouger(int x, int y) public void Bouger(int x, int y)
{ {
//Origine = new Point(Origine.X + x, Origine.Y + y); //Origine = new Point(Origine.X + x, Origine.Y + y);
// jambeBas.Origine = new Point(jambeBas.Origine.X + x, jambeBas.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); // pied.Origine = new Point(pied.Origine.X + x, pied.Origine.Y + y);
} }
public void Monter(int x) public void Monter(int x)
{ {
PointComplexe l = new PointComplexe(new PointComplexe(base.CSG, base.CSD).Millieux(), new PointComplexe(jambeBas.CIG, jambeBas.CID).Millieux());//Vecteur entre le haut et le bas du pied MajAngle();
PointComplexe m = new PointComplexe(new PointComplexe(base.CSG, base.CSD).Millieux(), new PointComplexe(base.CIG, base.CID).Millieux());//Vecteur entre le haut et le bas du pied 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
// var a = ((l.ABS - x) * (l.ABS - x)); 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); int lvertical = (int)m.ABS; //var b = (2 * (l.ABS - x) * Lvertical);
Console.WriteLine("L:{0} vert:{1} x:{2}", l.ABS,lvertical, x); Console.WriteLine("L:{0} vert:{1} x:{2}", l.ABS, lvertical, x);
var bla = (Math.Pow((l.ABS - x), 2)) / (2 * (l.ABS)* (lvertical)); double bla = (Math.Pow((l.ABS - x), 2)) / (2 * (l.ABS) * (lvertical));
Console.WriteLine("bla:{0}", bla); Console.WriteLine("bla:{0}", bla);
double angle = Math.Acos(bla); double angle = Math.Acos(bla);
angle *= 180; angle *= 180;
@ -116,25 +117,91 @@ namespace Bonhomme01
} }
public void Avancer(int x) public void Avancer(int x)
{ {
x=10 x = 10;
PointComplexe m = new PointComplexe(new PointComplexe(base.CSG, base.CSD).Millieux(), new PointComplexe(pied.CIG, pied.CID).Millieux());//Vecteur entre le haut et le bas du pied MajAngle();
// var a = ((l.ABS - x) * (l.ABS - x)); 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
int lvertical = (int)m.ABS; 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*/
Complex origine = new Complex(base.CSG.X, base.CSG.Y); //try
Complex Pointpied = new Complex(this.pied.CSG.X+x, this.pied.CSG.Y); //{
Pointpied = Pointpied - origine;
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 Pointgenou;
Complex Pointpied = new Complex(this.pied.CSG.X + x, this.pied.CSG.Y);
Pointpied = Pointpied - haut;
double genouxX, genouY; double genouxX, genouY;
double a = Math.Pow(Pointpied.Real, 2) + Math.Pow(Pointpied.Imaginary, 2); double a = Math.Pow(Pointpied.Real, 2) + Math.Pow(Pointpied.Imaginary, 2);
a /= 2 * Pointpied.Imaginary; Console.WriteLine("a=" + a + "+++++" + Pointpied.ToString());
genouxX = 2 * a - 2 * Math.Sqrt(Math.Pow(a, 2)-lvertical); a /= (2 * Pointpied.Imaginary);
genouxX /= 4;
genouY = a - genouxX;
//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); Pointgenou = new Complex(genouxX, genouY);
angleJambe.AngleBassin += (float)Pointgenou.Phase; angleJambe.AngleBassin = (float)(Pointgenou.Phase);
Pointpied = Pointpied - Pointgenou; angleJambe.AngleBassin *= (float)(180 / Math.PI);
angleJambe.AngleGenou += (float)Pointpied.Phase; //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;
} }
} }
} }

View File

@ -18,8 +18,10 @@ namespace Bonhomme01
public bool remplir = true; public bool remplir = true;
public bool visible = true; public bool visible = true;
private Point origine, origineRotation; private Point origine, origineRotation;
private Rectangle rectParent; private Rectangle rectParent;
public bool parentFlag = false; public bool parentFlag = false;
bool setToCenterFlag = false; bool setToCenterFlag = false;
public bool memeOrigineOrigineRotation_flag = true; public bool memeOrigineOrigineRotation_flag = true;
public int Lhorizontal, Lvertical; public int Lhorizontal, Lvertical;
@ -57,10 +59,10 @@ namespace Bonhomme01
this.origineRotation = origineRotation; this.origineRotation = origineRotation;
} }
#region pointPourRotation #region pointPourRotation
public PointComplexe CSG { get { return (new PointComplexe(Origine.X, Origine.Y, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } public Vecteur CSG { get { return (new Vecteur(Origine.X, Origine.Y, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } }
public PointComplexe CSD { get { return (new PointComplexe(Origine.X + Lhorizontal, 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 PointComplexe CIG { get { return (new PointComplexe(Origine.X, Origine.Y + Lvertical, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } } public Vecteur CIG { get { return (new Vecteur(Origine.X, Origine.Y + Lvertical, OrigineRotation.X, OrigineRotation.Y, angleRotation)); } }
public PointComplexe CID { get { return (new PointComplexe(Origine.X + Lhorizontal, 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 #endregion
#region accesseur #region accesseur
@ -114,14 +116,28 @@ namespace Bonhomme01
{ {
if (visible) if (visible)
{ {
Graphics gr = Graphics.FromHwnd(handle); try
Point[] l = new Point[4] { CSG, CSD, CID, CIG };
if (remplir)
{ {
gr.FillClosedCurve(new SolidBrush(fond), l); 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
{
} }
gr.DrawClosedCurve(new Pen(contour, eppaisseurContour), l);
} }
} }
public void Afficher(IntPtr handle, float angle) public void Afficher(IntPtr handle, float angle)
@ -140,15 +156,22 @@ namespace Bonhomme01
} }
public void Cacher(IntPtr handle) public void Cacher(IntPtr handle)
{ {
if (visible && 1 == 1) try
{ {
Graphics gr = Graphics.FromHwnd(handle); if (visible && 1 == 1)
Point[] l = new Point[4] { CSG, CSD, CID, CIG };
if (remplir)
{ {
gr.FillClosedCurve(new SolidBrush(this.backgroud), l); 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);
} }
gr.DrawClosedCurve(new Pen(this.backgroud, eppaisseurContour), l); }
catch
{
} }
} }
@ -160,11 +183,11 @@ namespace Bonhomme01
angleRotation = 0; angleRotation = 0;
decalageX = 0; decalageX = 0;
decalageY = 0; decalageY = 0;
Point millieuParent = PointComplexe.Millieux(rectParent.CIG, rectParent.CID); Point millieuParent = Vecteur.Millieux(rectParent.CIG, rectParent.CID);
Point millieuxenfant = PointComplexe.Millieux(this.CSG, this.CSD); Point millieuxenfant = Vecteur.Millieux(this.CSG, this.CSD);
decalageX = millieuParent.X - millieuxenfant.X; decalageX = millieuParent.X - millieuxenfant.X;
decalageY = millieuParent.Y - millieuxenfant.Y; decalageY = millieuParent.Y - millieuxenfant.Y;
OrigineRotation = PointComplexe.Millieux(this.CSG, this.CSD); OrigineRotation = Vecteur.Millieux(this.CSG, this.CSD);
setToCenterFlag = true; setToCenterFlag = true;
angleRotation = old; angleRotation = old;
} }
@ -172,7 +195,7 @@ namespace Bonhomme01
{ {
float old = angleRotation; float old = angleRotation;
angleRotation = 0; angleRotation = 0;
OrigineRotation = PointComplexe.Millieux(this.CSG, this.CSD); OrigineRotation = Vecteur.Millieux(this.CSG, this.CSD);
setToCenterFlag = true; setToCenterFlag = true;
angleRotation = old; angleRotation = old;
} }

View File

@ -8,10 +8,11 @@ using System.Drawing;
namespace Bonhomme01 namespace Bonhomme01
{ {
class PointComplexe class Vecteur
{ {
Complex point; public Complex point;
Complex origine; Complex origine;
Boolean flagDeplacerOrigine;
public int X public int X
{ {
get { return (int)point.Real; } get { return (int)point.Real; }
@ -24,42 +25,45 @@ namespace Bonhomme01
{ {
get get
{ {
DeplacerSurOrigine(); if (!flagDeplacerOrigine)
double abs = point.Magnitude; {
RetoursPosition(); DeplacerSurOrigine();
return abs; double abs = point.Magnitude;
RetoursPosition();
return abs;
}
else
return point.Magnitude;
} }
set set
{ {
} }
} }
public PointComplexe(int x, int y, int xo, int yo) public Vecteur(int x, int y, int xo, int yo)
{ {
point = new Complex(x, y); point = new Complex(x, y);
origine = new Complex(xo, yo); origine = new Complex(xo, yo);
flagDeplacerOrigine = false;
} }
public PointComplexe(PointComplexe a, PointComplexe b) public Vecteur(Vecteur a, Vecteur b)
{ {
point = new Complex(b.X, b.Y); point = new Complex(b.X, b.Y);
origine = new Complex(a.X, a.Y); origine = new Complex(a.X, a.Y);
flagDeplacerOrigine = false;
} }
public PointComplexe(Point a, Point b) public Vecteur(Point a, Point b)
{ {
point = new Complex(b.X, b.Y); point = new Complex(b.X, b.Y);
origine = new Complex(a.X, a.Y); origine = new Complex(a.X, a.Y);
flagDeplacerOrigine = false;
} }
public PointComplexe(int x, int y, int xo, int yo, double degre) public Vecteur(int x, int y, int xo, int yo, double degre)
{ {
point = new Complex(x, y); point = new Complex(x, y);
origine = new Complex(xo, yo); origine = new Complex(xo, yo);
//Console.WriteLine("Avent rotation {0}", point.ToString()); flagDeplacerOrigine = false;
//Console.WriteLine("Avent rotation {0}", point.ToString());
RotateDegre(degre); RotateDegre(degre);
//Console.WriteLine("Après rotation {0}", point.ToString());
//Console.WriteLine("Après rotation {0}", point.ToString());
} }
public void RotateDegre(double angle) public void RotateDegre(double angle)
{ {
@ -74,9 +78,9 @@ namespace Bonhomme01
point = Complex.Add(point, Complex.FromPolarCoordinates(point.Magnitude, point.Phase + radian)); point = Complex.Add(point, Complex.FromPolarCoordinates(point.Magnitude, point.Phase + radian));
point = Complex.Add(point, origine); point = Complex.Add(point, origine);
} }
public static Point Millieux(PointComplexe a, PointComplexe b) public static Point Millieux(Vecteur a, Vecteur b)
{ {
PointComplexe pt = new PointComplexe(a, b); Vecteur pt = new Vecteur(a, b);
pt.DeplacerSurOrigine(); pt.DeplacerSurOrigine();
pt.point = Complex.FromPolarCoordinates(pt.point.Magnitude / 2, pt.point.Phase); pt.point = Complex.FromPolarCoordinates(pt.point.Magnitude / 2, pt.point.Phase);
pt.RetoursPosition(); pt.RetoursPosition();
@ -89,19 +93,24 @@ namespace Bonhomme01
point = Complex.FromPolarCoordinates(point.Magnitude / 2, point.Phase); point = Complex.FromPolarCoordinates(point.Magnitude / 2, point.Phase);
RetoursPosition(); RetoursPosition();
return new Point(X, Y); return new Point((int)point.Real, (int)point.Imaginary);
} }
public void DeplacerSurOrigine() public void DeplacerSurOrigine()
{ { if (!flagDeplacerOrigine)
point = Complex.Subtract(point, origine); {
flagDeplacerOrigine = true;
point = Complex.Subtract(point, origine);
}
} }
public void RetoursPosition() public void RetoursPosition()
{ {
point = Complex.Add(point, origine); if (flagDeplacerOrigine)
{
flagDeplacerOrigine = false;
point = Complex.Add(point, origine);
}
} }
public static implicit operator Point(Vecteur point)
public static implicit operator Point(PointComplexe point)
{ {
return new Point(point.X, point.Y); return new Point(point.X, point.Y);
} }