Page 1 of 1

XYZ position mouse click within 3D chart

Posted: Mon Jul 10, 2006 9:31 am
by 9641771
I need to determine XYZ coordinates of a clicked point when someone clickes bottom plane (plane between X and Z axes). How could I do it (maybe I need to draw a surface on this plane and use some functions?)?

Posted: Tue Jul 11, 2006 11:45 am
by narcis
Hi bairog,

GDI+ doesn't have 3D coordinates. However you can obtain them doing something like this:

Code: Select all

    private void tChart1_MouseClick(object sender, MouseEventArgs e)
    {
      int ZstartP = tChart1.Axes.Depth.IStartPos;
      int ZendP = tChart1.Axes.Depth.IEndPos;
      int XPos = tChart1.Axes.Bottom.Position;

      if ((e.Y <= XPos) && (e.Y >= XPos - ZendP))
      {
        double ZPos = XPos - e.Y;
        double ZVal = (tChart1.Axes.Depth.Maximum * ZPos) / ZendP;        
        double XVal = tChart1.Axes.Bottom.CalcPosPoint(e.X);
        double YVal = tChart1.Axes.Bottom.CalcPosPoint(e.X);

        tChart1.Header.Text = XVal.ToString() + ", " + YVal.ToString() + ", " + ZVal.ToString();
      }
      else
      {
        tChart1.Header.Text = "";
      }
    }

Posted: Thu Jul 13, 2006 1:29 pm
by 9641771
Thank you, but you code does not work correctly in my chart.
Image
As you can see values that are shown in header are not right (more than that in you code X and Y coordinates are always the same).Moreover while rotating and elevating the chart I have the same XYZ coordinates if I click at the same XY screen position. That's why I have some questions:
1)Are you sure that the code you gave is correct?
2)What shoul I add to code to make XYZ coordinates rotation-,elevation- and zoom-dependent?
3)From what border do Position, IEndPos and IStartPos values are calculate (screen XY xoordinates as far as I know are calculated from form border) and how could I obtain this border coordinates?
Thank you.