Results 1 to 37 of 37

Intersect Complex Lines AndyPope more OutuputOptions

Threaded View

  1. #1
    Registered User
    Join Date
    01-17-2012
    Location
    haiti
    MS-Off Ver
    Excel 2003
    Posts
    33

    Intersect Complex Lines AndyPope more OutuputOptions

    Hi, i wnat modify the ComplexIntersect line functions by AndyPope to give more Output Options.
    not only output the x,y coords of PointIntersection how it is, but Outuput other values re-using the Function.

    examples PSEUDOCODE:
    Select Case OutputOption
    OutputOption = 1 then x3,y3 coords
    OutputOption = 2 then x1,y1 coords
    OutputOption = 3 then a, b, values


    thank you very mutch
    Xman -- sample files:


    
    ' Algebra taken from various sources on the WWW
    '
    Option Explicit
    
    Public Function IntersectComplex(x1 As Double, y1 As Double, x2 As Double, y2 As Double, LineCoordinates As Range, Axis As Boolean, ByRef OptionOuput As Double) As Variant
    '
    ' Complex Intersect.
    ' Because the line segments are not uniformly spaced the (xy,y1)(x2,y2) could cross
    ' at any point along the other line
    '
    ' Return
    ' If intersection
    '    requested coordinate
    ' else
    '    nothing
    ' endif
    ' Axis=True returns X value
    ' Axis=False returns Y value
    '
        Dim dblCrossX As Double
        Dim dblCrossY As Double
        Dim dblTestx1 As Double
        Dim dblTesty1 As Double
        Dim dblTestx2 As Double
        Dim dblTesty2 As Double
        Dim intSegment As Integer
        
        With LineCoordinates
            For intSegment = 1 To .Rows.Count - 1
                dblTestx1 = .Cells(intSegment, 1)
                dblTesty1 = .Cells(intSegment, 2)
                dblTestx2 = .Cells(intSegment + 1, 1)
                dblTesty2 = .Cells(intSegment + 1, 2)
                If m_CalculateIntersection(x1, y1, x2, y2, dblTestx1, dblTesty1, dblTestx2, dblTesty2, dblCrossX, dblCrossY) Then
                    If Axis Then
                        IntersectComplex = dblCrossX
                    Else
                        IntersectComplex = dblCrossY
                    End If
                    Exit Function
                End If
            Next
        
            ' Special check for last pairing
            intSegment = .Rows.Count
            dblTestx1 = .Cells(intSegment, 1)
            dblTesty1 = .Cells(intSegment, 2)
            dblTestx2 = .Cells(intSegment, 1)
            dblTesty2 = .Cells(intSegment, 2)
            If m_CalculateIntersection(x1, y1, x2, y2, dblTestx1, dblTesty1, dblTestx2, dblTesty2, dblCrossX, dblCrossY) Then
                
                If OptionOuput = 1 Then
                
                If Axis Then
                    IntersectComplex = dblCrossX
                Else
                    IntersectComplex = dblCrossY
                End If
                
                ElseIf OptionOuput = 2 Then
                            If Axis Then
                    IntersectComplex = CrossX
                Else
                    IntersectComplex = CrossY
                End If
                
                End If ''OptionOuput
                      
                          
                                        
                Exit Function
            End If
            
        End With
        IntersectComplex = CVErr(xlErrNA)    ' Null
        
    End Function
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by doriangrey; 12-21-2017 at 06:36 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 08-25-2017, 03:17 PM
  2. Replies: 14
    Last Post: 08-05-2013, 04:36 AM
  3. 2 X and 2 Y lines that intersect to form a box
    By McElroy in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 05-27-2013, 07:21 AM
  4. Difference between Intersect and Not Intersect is Nothing
    By batman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2009, 05:39 PM
  5. Intersect
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-19-2006, 05:45 PM
  6. Replies: 2
    Last Post: 05-30-2006, 03:35 PM
  7. Replies: 3
    Last Post: 02-18-2005, 11:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1