Click here to Skip to main content
14,240,435 members
Rate this:
Please Sign up or sign in to vote.
See more:
I cant able to get intersection point coordinates automatically in text box, but when i move cursor near to intersection point it shows the coordinates.

What I have tried:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ZedGraph;

namespace ZedGraphSample
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void Form1_Load( object sender, EventArgs e )
		{
			CreateGraph( zg1 );
			SetSize();
		}

		private void CreateGraph( ZedGraphControl zgc )
		{
			GraphPane myPane = zgc.GraphPane;

			// Set the titles and axis labels
			myPane.Title.Text = "My Test Graph";
			myPane.XAxis.Title.Text = "X Value";
			myPane.YAxis.Title.Text = "My Y Axis";

			// Make up some data points from the Sine function
			PointPairList list = new PointPairList();
			for ( double x = 0; x < 36; x++ )
			{
				double y = Math.Sin( x * Math.PI / 15.0 );

				list.Add( x, y );
			}
            PointPairList list1 = new PointPairList();
            for (double x1 = 0; x1 < 36; x1++)
            {
                double y1 = Math.Sin(x1 * Math.PI / 15.0);

                list1.Add(x1+1, y1);
            }

			// Generate a blue curve with circle symbols, and "My Curve 2" in the legend
			LineItem myCurve = myPane.AddCurve( "My Curve", list, Color.Green,
									SymbolType.Circle );
            LineItem myCurve1 = myPane.AddCurve("My Curve1", list1, Color.Black,
                                    SymbolType.Circle);
            //// Fill the area under the curve with a white-red gradient at 45 degrees
            //myCurve.Line.Fill = new Fill( Color.White, Color.Red, 45F );
            //// Make the symbols opaque by filling them with white
            //myCurve.Symbol.Fill = new Fill( Color.White );

            //// Fill the axis background with a color gradient
            //myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45F );

            //// Fill the pane background with a color gradient
            //myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45F );

            // Calculate the Axis Scale Ranges
            zgc.AxisChange();
        }

		private void Form1_Resize( object sender, EventArgs e )
		{
			SetSize();
		}

		private void SetSize()
		{
			zg1.Location = new Point( 10, 10 );
			// Leave a small margin around the outside of the control
			zg1.Size = new Size( this.ClientRectangle.Width - 20, this.ClientRectangle.Height - 20 );
		}

        private void zg1_Load(object sender, EventArgs e)
        {

        }
	}
}
Posted
Updated 15-May-19 21:15pm
v4
Comments
Stefan_Lang 16-May-19 3:30am
   
What do you mean by 'intersection', 'line', and 'coordinates'?...
Ok, I get now what you mean. You still should fix the wording of your topic title into something like
"How to get the coordinates of a line intersection from a graphic pane?", because that is what you appear to be trying, judging by your code and description.
Richard Deeming 16-May-19 9:33am
   
This is a maths problem, not a programming one.

You need to solve:
Sin(x * π / 15) == Sin((x - 1) * π / 15)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100