# Get The Intersection Point In Two Lines

Page 1 of 1

## 3 Replies - 3141 Views - Last Post: 24 November 2013 - 11:04 AMRate Topic: 1 Votes //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=334262&amp;s=aee1bd1cd6a6978d6acd5748c47b9bd2&md5check=' + ipb.vars['secure_hash'], cur_rating: 5, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 vher_way

Reputation: 1
• Posts: 31
• Joined: 08-November 13

# Get The Intersection Point In Two Lines

Posted 17 November 2013 - 01:32 PM

Hello Bro.. />

I want to make intersection point in my graphic, I have two line.
++ FuzzyMax
++ IPK

My Chart Name's Is graphChenHuang

```Dim FuzzyMax As New Series("Garis Fuzzy Max")
Dim IPK As New Series("IPK")

FuzzyMax.ChartType = SeriesChartType.Line
IPK.ChartType = SeriesChartType.Line

With graphChenHuang.Series(0).Points
End With

With graphChenHuang.Series(1).Points
End With

```

Now.. Please teach me how to make Intersection Point and Get The Value of each intersection Of FuzzyMax and IPK. /> />

Is This A Good Question/Topic? 0

## Replies To: Get The Intersection Point In Two Lines

### #2 Martyr2

• Programming Theoretician

Reputation: 4925
• Posts: 13,317
• Joined: 18-April 07

## Re: Get The Intersection Point In Two Lines

Posted 17 November 2013 - 01:47 PM

How about you just look up the math? http://en.wikipedia....ne_intersection

Remember for two lines you can have no intersection (lines are parallel), one intersection or infinite intersections (the two lines are the same line).

So just do the math. My suggestion would be to create a little method that takes in the four points (x1, y1, x2, y2) and either returns a point, empty point or some point that represents infinity.

### #3 vher_way

Reputation: 1
• Posts: 31
• Joined: 08-November 13

## Re: Get The Intersection Point In Two Lines

Posted 17 November 2013 - 03:44 PM

Martyr2, on 17 November 2013 - 08:47 PM, said:

How about you just look up the math? http://en.wikipedia....ne_intersection

Remember for two lines you can have no intersection (lines are parallel), one intersection or infinite intersections (the two lines are the same line).

So just do the math. My suggestion would be to create a little method that takes in the four points (x1, y1, x2, y2) and either returns a point, empty point or some point that represents infinity.

/>/>/>

I mean the point of IPK 0.xx

```Dim FuzzyMax As New Series("Garis Fuzzy Max")
Dim IPK As New Series("IPK")
FuzzyMax.ChartType = SeriesChartType.Line
IPK.ChartType = SeriesChartType.Line
With graphChenHuang.Series(0).Points
End With

With graphChenHuang.Series(1).Points
End With

```

I just learned it,
from 2 series above, I just need intersections FuzzyMax line with the GPA line. (0.4, 1) - (0.6, 0).
So here we have two straight lines:
- FuzzyMax: (0, 0) (1, 1)
- The Split IPK : (0.4, 1) (0.6, 0)

Up here I have to get the line equation:
- FuzzyMax: x - y = 0
- The split GPA: 0.2y = -x + 0.6

Furthermore, I want to find the point of intersection:
X - Y = 0
X + 0.2Y = 0.6

y + 0.2y = 0.6
1.2Y = 0.6
Y = 0.6/1.2
Y = 0.5

X - Y = 0
X - 0.5 = 0
X = 0.5

So the point of intersection between the lines FuzzyMax, with Divisions GPA is (0.5, 0.5). the following picture:

But if this is how, when we change the coordinates of the GPA this way maybe will not work? Am i right?

### #4 vher_way

Reputation: 1
• Posts: 31
• Joined: 08-November 13

## Re: Get The Intersection Point In Two Lines

Posted 24 November 2013 - 11:04 AM

[RESOLVED]

```
Dim Line1 As New Series("L1") 'Add Series To Chart
Dim Line2 As New Series("L2") 'Add Series To Chart
Dim Intersection As New Series("Intersection Point")

Chart1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top
Chart1.ChartAreas(0).AxisX.LineWidth = 1
Chart1.ChartAreas(0).AxisX.MajorGrid.LineColor = Color.LightGreen
Chart1.ChartAreas(0).AxisX.Crossing = 0
Chart1.ChartAreas(0).AxisX.Minimum = 0
Chart1.ChartAreas(0).AxisX.Maximum = 1
Chart1.ChartAreas(0).AxisX.Interval = 0.1
Chart1.ChartAreas(0).AxisY.LineWidth = 2
Chart1.ChartAreas(0).AxisY.MajorGrid.LineColor = Color.YellowGreen
Chart1.ChartAreas(0).AxisY.Crossing = 0
Chart1.ChartAreas(0).AxisY.Minimum = 0
Chart1.ChartAreas(0).AxisY.Maximum = 1
Chart1.ChartAreas(0).AxisY.Interval = 0.1

'Properties For Line 1
Line1.ChartType = SeriesChartType.Line
Line1.Color = Color.Red
Line1.BorderWidth = 1

'Properties For Line 1
Line2.ChartType = SeriesChartType.Line
Line2.Color = Color.Green
Line2.BorderWidth = 1

'Properties For Intersection Point
Intersection.ChartType = SeriesChartType.Line
Intersection.XValueType = ChartValueType.Double
Intersection.YValueType = ChartValueType.Double
Intersection.MarkerStyle = MarkerStyle.Diamond
Intersection.MarkerSize = 15
Intersection.Label = "#VALY" 'To Show Y Coordinate Point

'Line 1 Points
Dim L1x1 As Double = 0.0 'X1 Line 1 Point 1
Dim L1y1 As Double = 1.0 'Y1 Line 1 Point 1
Dim L1x2 As Double = 1.0 'X2 Line 1 Point 2
Dim L1y2 As Double = 0.0 'Y2 Line 1 Point 2

'Line 2 Points
Dim L2x1 As Double = 0.0 'X1 Line 2 Point 1
Dim L2y1 As Double = 0.0 'Y1 Line 2 Point 1
Dim L2x2 As Double = 0.2 'X2 Line 2 Point 2
Dim L2y2 As Double = 1.0 'Y2 Line 2 Point 2

'Add Line 1 To The Chart
With Chart1.Series(0).Points
End With

'Add Line 2 To the Chart
With Chart1.Series(1).Points
End With

'Find Intersection
Dim L1, L2, c1, c2 As Double
L1 = (L1y2 - L1y1) / (L1x2 - L1x1)
L2 = (L2y2 - L2y1) / (L2x2 - L2x1)

c1 = L1y1 - (L1 * L1x1)
c2 = L2y1 - (L2 * L2x1)

Dim IntersectionX, IntersectionY As Double
IntersectionX = (c2 - c1) / (L1 - L2)
IntersectionY = L1 * IntersectionX + c1