Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Logic help

  1. Feb 2, 2006 #1
    help - this is visual basic code that deals with motion
    can someone with some good math background pleas look it over and
    let me know the logic
    please comment
    thanks




    Private Sub fillRegion(px As Integer, py As Integer, depth As Integer, ByRef minX As Integer, ByRef maxX As Integer, ByRef minY As Integer, ByRef maxY As Integer)
    'fills a region with the given colour


    If (motion(px, py, 0)) And (motion(px, py, 1) = 0) Then

    motion(px, py, 1) = True
    RegionArea = RegionArea + 1

    If (px < minX) Then
    minX = px
    End If
    If (px > maxX) Then
    maxX = px
    End If
    If (py < minY) Then
    minY = py
    End If
    If (py > maxY) Then
    maxY = py
    End If

    If (depth < 100) Then

    If (py > 0) Then
    Call fillRegion(px, py - 1, depth + 1, minX, maxX, minY, maxY)
    End If

    If (px < MotionResolution - 1) And (py > 0) Then
    Call fillRegion(px + 1, py - 1, depth + 1, minX, maxX, minY, maxY)
    End If

    If (px < MotionResolution - 1) Then
    Call fillRegion(px + 1, py, depth + 1, minX, maxX, minY, maxY)
    End If

    If (px < MotionResolution - 1) And (py < MotionResolution - 2) Then
    Call fillRegion(px + 1, py + 1, depth + 1, minX, maxX, minY, maxY)
    End If

    If (py < MotionResolution - 1) Then
    Call fillRegion(px, py + 1, depth + 1, minX, maxX, minY, maxY)
    End If

    If (px > 0) Then
    Call fillRegion(px - 1, py, depth + 1, minX, maxX, minY, maxY)
    End If

    If (px > 0) And (py > 0) Then
    Call fillRegion(px - 1, py - 1, depth + 1, minX, maxX, minY, maxY)
    End If

    If (px > 0) And (py < MotionResolution - 1) Then
    Call fillRegion(px - 1, py + 1, depth + 1, minX, maxX, minY, maxY)
    End If

    If (px < MotionResolution - 1) And (py < MotionResolution - 1) Then
    Call fillRegion(px + 1, py + 1, depth + 1, minX, maxX, minY, maxY)
    End If

    End If
    End If
    End Sub
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you help with the solution or looking for help too?
Draft saved Draft deleted