Ejemplo n.º 1
0
    private bool ParseArc3(string atom, ArrayList arrayList)
    {
      atom = atom.Remove(0, 4);
      string[] atoms = atom.Split(charSplitArray, StringSplitOptions.RemoveEmptyEntries);

      if (atoms.Length != 6)
      {
        toolStripStatusLabel1.Text = "Incorrect number of parameters (x1, y1, x2, y2, x3, y3): " + atom;
        toolStripStatusLabel1.BackColor = Color.Yellow;
        return false;
      }

      try
      {
        float x1 = float.Parse(atoms[0]);
        float y1 = float.Parse(atoms[1]);
        float x2 = float.Parse(atoms[2]);
        float y2 = float.Parse(atoms[3]);
        float x3 = float.Parse(atoms[4]);
        float y3 = float.Parse(atoms[5]);

        //a = 2*det([1,1,1;x1,x2,x3;y1,y2,y3]);
        double a = 2.0 * det(1.0, 1.0, 1.0, x1, x2, x3, y1, y2, y3);

        //r = sqrt( ((x2-x3)^2+(y2-y3)^2) ...
        float r = (float)(Math.Sqrt((Math.Pow(x2 - x3, 2) + Math.Pow(y2 - y3, 2))
          // * ((x3-x1)^2+(y3-y1)^2)
                             * (Math.Pow(x3 - x1, 2) + Math.Pow(y3 - y1, 2))
          // * ((x1-x2)^2+(y1-y2)^2) )
                             * (Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2)))
          // / abs(a);
                   / Math.Abs(a));

        //xc = - det([1,1,1;y1,y2,y3;x1^2+y1^2,x2^2+y2^2,x3^2+y3^2]) / a;
        float xc = (float)(-det(1.0, 1.0, 1.0,
                                y1, y2, y3,
                                x1 * x1 + y1 * y1, x2 * x2 + y2 * y2, x3 * x3 + y3 * y3) / a);

        //yc =   det([1,1,1;x1,x2,x3;x1^2+y1^2,x2^2+y2^2,x3^2+y3^2]) / a;
        float yc = (float)(det(1.0, 1.0, 1.0,
                                x1, x2, x3,
                                x1 * x1 + y1 * y1, x2 * x2 + y2 * y2, x3 * x3 + y3 * y3) / a);

        float a3 = (float)(Math.Atan2(yc - y3, xc - x3) * 180 / Math.PI) + 180.0F;
        float a1 = (float)(Math.Atan2(yc - y1, xc - x1) * 180 / Math.PI) + 180.0F;


        Arc arc = new Arc(xc - r, yc - r, 2.0F * r, 2.0F * r, a1, a3 - a1);

        arrayList.Add(arc);
      }
      catch
      {
        toolStripStatusLabel1.Text = "Error parsing parameters (x1, y1, x2, y2, x3, y3): " + atom;
        toolStripStatusLabel1.BackColor = Color.Yellow;
        return false;
      }

      return true;
    }
Ejemplo n.º 2
0
    private bool ParseArc(string atom, ArrayList arrayList)
    {
      atom = atom.Remove(0, 3);
      string[] atoms = atom.Split(charSplitArray, StringSplitOptions.RemoveEmptyEntries);

      if (atoms.Length != 3)
      {
        toolStripStatusLabel1.Text = "Incorrect number of parameters (x, y, r): " + atom;
        toolStripStatusLabel1.BackColor = Color.Yellow;
        return false;
      }

      try
      {
        float x = float.Parse(atoms[0]);
        float y = float.Parse(atoms[1]);
        float r = Math.Abs(float.Parse(atoms[2]));

        Arc arc = new Arc(x - r, y - r, 2.0F * r, 2.0F * r, 0.0F, 360.0F);

        arrayList.Add(arc);
      }
      catch
      {
        toolStripStatusLabel1.Text = "Error parsing parameters (x, y, r): " + atom;
        toolStripStatusLabel1.BackColor = Color.Yellow;
        return false;
      }

      return true;
    }
Ejemplo n.º 3
0
    private bool ParseArc2(string atom, ArrayList arrayList)
    {
      atom = atom.Remove(0, 4);
      string[] atoms = atom.Split(charSplitArray, StringSplitOptions.RemoveEmptyEntries);

      if (atoms.Length != 6)
      {
        toolStripStatusLabel1.Text = "Incorrect number of parameters (x, y, w, h, a, s): " + atom;
        toolStripStatusLabel1.BackColor = Color.Yellow;
        return false;
      }

      try
      {
        float x = float.Parse(atoms[0]);
        float y = float.Parse(atoms[1]);
        float w = float.Parse(atoms[2]);
        float h = float.Parse(atoms[3]);
        float a = float.Parse(atoms[4]);
        while (a < 0.0F) a += 360.0F;
        while (a > 360.0F) a -= 360.0F;
        float s = float.Parse(atoms[5]);

        Arc arc = new Arc(x, y, w, h, a, s);

        arrayList.Add(arc);
      }
      catch
      {
        toolStripStatusLabel1.Text = "Error parsing parameters (x, y, w, h, a, s): " + atom;
        toolStripStatusLabel1.BackColor = Color.Yellow;
        return false;
      }

      return true;
    }
Ejemplo n.º 4
0
 private void GenerateArc2(Arc arc, SysCAD.Protocol.Size defaultSize)
 {
   tempText += "MDrw_Arc2 " +
               (arc.x / 100.0F * defaultSize.Width).ToString() + ", " + (arc.y / 100.0F * defaultSize.Height).ToString() + ", " +
               (arc.w / 100.0F * defaultSize.Width).ToString() + ", " + (arc.h / 100.0F * defaultSize.Height).ToString() + ", " +
               arc.a.ToString() + ", " + arc.s.ToString() + "\r\n";
 }