Commit avent grosse modif pour prÃcision
This commit is contained in:
parent
06cf062ae7
commit
b1837b43da
|
@ -48,12 +48,14 @@ namespace Bonhomme01
|
|||
public void Bouger(int x, int y, Jambe.AngleJambe angleJambe1, Jambe.AngleJambe angleJambe2)
|
||||
{
|
||||
if(flag == 0)
|
||||
jambe1.angleJambe = angleJambe1;
|
||||
jambe1.angleJambe = angleJambe1;
|
||||
flag = 2;
|
||||
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);
|
||||
}
|
||||
else if (jambe1.angleJambe.AngleBassin != 0 && jambe2.angleJambe.AngleBassin == 0 && 1==2)
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Jambe.cs" />
|
||||
<Compile Include="PointComplexe.cs" />
|
||||
<Compile Include="Vecteur.cs" />
|
||||
<Compile Include="PointOrigine.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
|
@ -60,10 +60,10 @@ namespace Bonhomme01
|
|||
this.origineRotation = origineRotation;
|
||||
}
|
||||
#region pointPourRotation
|
||||
public PointComplexe CSG { get { return (new PointComplexe(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 PointComplexe CIG { get { return (new PointComplexe(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 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
|
||||
|
@ -115,8 +115,8 @@ namespace Bonhomme01
|
|||
{
|
||||
decalageX = 0;
|
||||
decalageY = 0;
|
||||
Point millieuParent = PointComplexe.Millieux(rectParent.CIG, rectParent.CID);
|
||||
Point millieuxenfant = PointComplexe.Millieux(this.CSG, this.CSD);
|
||||
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;
|
||||
|
@ -125,7 +125,7 @@ namespace Bonhomme01
|
|||
{
|
||||
float old = angleRotation;
|
||||
angleRotation = 0;
|
||||
OrigineRotation = PointComplexe.Millieux(this.CSG, this.CSD);
|
||||
OrigineRotation = Vecteur.Millieux(this.CSG, this.CSD);
|
||||
setToCenterFlag = true;
|
||||
angleRotation = old;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
//
|
||||
// timerImage
|
||||
//
|
||||
this.timerImage.Interval = 40;
|
||||
this.timerImage.Interval = 500;
|
||||
this.timerImage.Tick += new System.EventHandler(this.timerImage_Tick);
|
||||
//
|
||||
// btnEffacer
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Bonhomme01
|
|||
}
|
||||
else
|
||||
{
|
||||
this.bonhomme.Cacher(this.TV.Handle);
|
||||
//this.bonhomme.Cacher(this.TV.Handle);
|
||||
//angleJ1.AngleBassin += 1;
|
||||
//angleJ1.AngleCheville = angleJ1.AngleGenou += 2;
|
||||
//angleJ2.AngleBassin -= 1;
|
||||
|
|
|
@ -32,33 +32,33 @@ namespace Bonhomme01
|
|||
public AngleJambe(float angleBassin, float angleGenou, float angleCheville)
|
||||
{
|
||||
this.AngleBassin = angleBassin;
|
||||
this.AngleGenou= angleGenou;
|
||||
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)
|
||||
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);
|
||||
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)
|
||||
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);
|
||||
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)
|
||||
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);
|
||||
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)
|
||||
{
|
||||
|
@ -85,27 +85,28 @@ namespace Bonhomme01
|
|||
public float Genou
|
||||
{
|
||||
get { return jambeBas.angleRotation; }
|
||||
set { jambeBas.angleRotation = angleJambe.AngleGenou = value%360; }
|
||||
set { jambeBas.angleRotation = angleJambe.AngleGenou = value % 360; }
|
||||
}
|
||||
public float Cheville
|
||||
{
|
||||
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)
|
||||
{
|
||||
//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);
|
||||
// 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)
|
||||
{
|
||||
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
|
||||
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
|
||||
// var a = ((l.ABS - x) * (l.ABS - 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);
|
||||
var bla = (Math.Pow((l.ABS - x), 2)) / (2 * (l.ABS)* (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;
|
||||
|
@ -116,25 +117,91 @@ namespace Bonhomme01
|
|||
}
|
||||
public void Avancer(int x)
|
||||
{
|
||||
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
|
||||
// var a = ((l.ABS - x) * (l.ABS - x));
|
||||
int lvertical = (int)m.ABS;
|
||||
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*/
|
||||
|
||||
Complex origine = new Complex(base.CSG.X, base.CSG.Y);
|
||||
Complex Pointpied = new Complex(this.pied.CSG.X+x, this.pied.CSG.Y);
|
||||
Pointpied = Pointpied - origine;
|
||||
//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);
|
||||
a /= 2 * Pointpied.Imaginary;
|
||||
genouxX = 2 * a - 2 * Math.Sqrt(Math.Pow(a, 2)-lvertical);
|
||||
genouxX /= 4;
|
||||
genouY = a - genouxX;
|
||||
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;
|
||||
Pointpied = Pointpied - Pointgenou;
|
||||
angleJambe.AngleGenou += (float)Pointpied.Phase;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,10 @@ namespace Bonhomme01
|
|||
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;
|
||||
|
@ -57,10 +59,10 @@ namespace Bonhomme01
|
|||
this.origineRotation = origineRotation;
|
||||
}
|
||||
#region pointPourRotation
|
||||
public PointComplexe CSG { get { return (new PointComplexe(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 PointComplexe CIG { get { return (new PointComplexe(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 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
|
||||
|
@ -114,14 +116,28 @@ namespace Bonhomme01
|
|||
{
|
||||
if (visible)
|
||||
{
|
||||
Graphics gr = Graphics.FromHwnd(handle);
|
||||
Point[] l = new Point[4] { CSG, CSD, CID, CIG };
|
||||
if (remplir)
|
||||
try
|
||||
{
|
||||
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)
|
||||
|
@ -140,15 +156,22 @@ namespace Bonhomme01
|
|||
}
|
||||
public void Cacher(IntPtr handle)
|
||||
{
|
||||
if (visible && 1 == 1)
|
||||
try
|
||||
{
|
||||
Graphics gr = Graphics.FromHwnd(handle);
|
||||
Point[] l = new Point[4] { CSG, CSD, CID, CIG };
|
||||
if (remplir)
|
||||
if (visible && 1 == 1)
|
||||
{
|
||||
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;
|
||||
decalageX = 0;
|
||||
decalageY = 0;
|
||||
Point millieuParent = PointComplexe.Millieux(rectParent.CIG, rectParent.CID);
|
||||
Point millieuxenfant = PointComplexe.Millieux(this.CSG, this.CSD);
|
||||
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 = PointComplexe.Millieux(this.CSG, this.CSD);
|
||||
OrigineRotation = Vecteur.Millieux(this.CSG, this.CSD);
|
||||
setToCenterFlag = true;
|
||||
angleRotation = old;
|
||||
}
|
||||
|
@ -172,7 +195,7 @@ namespace Bonhomme01
|
|||
{
|
||||
float old = angleRotation;
|
||||
angleRotation = 0;
|
||||
OrigineRotation = PointComplexe.Millieux(this.CSG, this.CSD);
|
||||
OrigineRotation = Vecteur.Millieux(this.CSG, this.CSD);
|
||||
setToCenterFlag = true;
|
||||
angleRotation = old;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,11 @@ using System.Drawing;
|
|||
|
||||
namespace Bonhomme01
|
||||
{
|
||||
class PointComplexe
|
||||
class Vecteur
|
||||
{
|
||||
Complex point;
|
||||
public Complex point;
|
||||
Complex origine;
|
||||
Boolean flagDeplacerOrigine;
|
||||
public int X
|
||||
{
|
||||
get { return (int)point.Real; }
|
||||
|
@ -24,42 +25,45 @@ namespace Bonhomme01
|
|||
{
|
||||
get
|
||||
{
|
||||
DeplacerSurOrigine();
|
||||
double abs = point.Magnitude;
|
||||
RetoursPosition();
|
||||
return abs;
|
||||
if (!flagDeplacerOrigine)
|
||||
{
|
||||
DeplacerSurOrigine();
|
||||
double abs = point.Magnitude;
|
||||
RetoursPosition();
|
||||
return abs;
|
||||
}
|
||||
else
|
||||
return point.Magnitude;
|
||||
}
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
origine = new Complex(xo, yo);
|
||||
//Console.WriteLine("Avent rotation {0}", point.ToString());
|
||||
|
||||
//Console.WriteLine("Avent rotation {0}", point.ToString());
|
||||
flagDeplacerOrigine = false;
|
||||
RotateDegre(degre);
|
||||
//Console.WriteLine("Après rotation {0}", point.ToString());
|
||||
|
||||
//Console.WriteLine("Après rotation {0}", point.ToString());
|
||||
}
|
||||
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, 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.point = Complex.FromPolarCoordinates(pt.point.Magnitude / 2, pt.point.Phase);
|
||||
pt.RetoursPosition();
|
||||
|
@ -89,19 +93,24 @@ namespace Bonhomme01
|
|||
point = Complex.FromPolarCoordinates(point.Magnitude / 2, point.Phase);
|
||||
RetoursPosition();
|
||||
|
||||
return new Point(X, Y);
|
||||
return new Point((int)point.Real, (int)point.Imaginary);
|
||||
}
|
||||
public void DeplacerSurOrigine()
|
||||
{
|
||||
point = Complex.Subtract(point, origine);
|
||||
{ if (!flagDeplacerOrigine)
|
||||
{
|
||||
flagDeplacerOrigine = true;
|
||||
point = Complex.Subtract(point, origine);
|
||||
}
|
||||
}
|
||||
public void RetoursPosition()
|
||||
{
|
||||
point = Complex.Add(point, origine);
|
||||
if (flagDeplacerOrigine)
|
||||
{
|
||||
flagDeplacerOrigine = false;
|
||||
point = Complex.Add(point, origine);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static implicit operator Point(PointComplexe point)
|
||||
public static implicit operator Point(Vecteur point)
|
||||
{
|
||||
return new Point(point.X, point.Y);
|
||||
}
|
Loading…
Reference in New Issue