3 Replies - 1354 Views - Last Post: 24 November 2013 - 11:04 AM Rate Topic: ***** 1 Votes

#1 vher_way  Icon User is offline

  • New D.I.C Head

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

Get The Intersection Point In Two Lines

Posted 17 November 2013 - 01:32 PM

Hello Bro.. :helpsmilie:/>

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

graphChenHuang.Series.Add(FuzzyMax)
With graphChenHuang.Series(0).Points
            .AddXY(0, 0)
            .AddXY(1, 1)
End With

graphChenHuang.Series.Add(IPK)
With graphChenHuang.Series(1).Points
            .AddXY(2, 0)
            .AddXY(4, 1)
            .AddXY(6, 0)
End With





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

Is This A Good Question/Topic? 0
  • +

Replies To: Get The Intersection Point In Two Lines

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4425
  • View blog
  • Posts: 12,293
  • 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.

:)
Was This Post Helpful? 0
  • +
  • -

#3 vher_way  Icon User is offline

  • New D.I.C Head

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

Re: Get The Intersection Point In Two Lines

Posted 17 November 2013 - 03:44 PM

View PostMartyr2, 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'm sorry about the Code..
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
graphChenHuang.Series.Add(FuzzyMax)
With graphChenHuang.Series(0).Points
.AddXY(0, 0)
.AddXY(1, 1)
End With

graphChenHuang.Series.Add(IPK)
With graphChenHuang.Series(1).Points
            .AddXY(0.2, 0)
            .AddXY(0.4, 1)
            .AddXY(0.6, 0)
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:


Attached Image

But if this is how, when we change the coordinates of the GPA this way maybe will not work? Am i right? :rockon:
Was This Post Helpful? 0
  • +
  • -

#4 vher_way  Icon User is offline

  • New D.I.C Head

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

Re: Get The Intersection Point In Two Lines

Posted 24 November 2013 - 11:04 AM

[RESOLVED]


Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        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
        Chart1.Series.Add(Line1)
        With Chart1.Series(0).Points
            .AddXY(0.0, 1.0)
            .AddXY(1.0, 0.0)
        End With

        'Add Line 2 To the Chart
        Chart1.Series.Add(Line2)
        With Chart1.Series(1).Points
            .AddXY(0.0, 0.0)
            .AddXY(0.2, 1.0)
        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

        Chart1.Series.Add(Intersection)
        Intersection.Points.AddXY(IntersectionX, IntersectionY)





:scooter: :scooter: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana: :gun_bandana:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1