samples/04_physics_and_collisions/10_collision_with_object_removal/app/linear_collider.rb
def isCollision? (point)
    #INFINITY slop breaks down when trying to determin collision, ergo it requires a special test
    if slope(@pointA, @pointB) ==  INFINITY &&
      point.x >= [@pointA.x,@pointB.x].min+(@extension == :pos ? -@thickness : 0) &&
      point.x <= [@pointA.x,@pointB.x].max+(@extension == :neg ?  @thickness : 0) &&
      point.y >= [@pointA.y,@pointB.y].min && point.y <= [@pointA.y,@pointB.y].max
        return true
    end

    isNegInLine   = @extension == :neg &&
                    point.y <= slope(@pointA, @pointB)*point.x+intercept(@pointA,@pointB) &&
                    point.y >= point.x*slope(@pointAExtended, @pointBExtended)+intercept(@pointAExtended,@pointBExtended)
    isPosInLine   = @extension == :pos &&
                    point.y >= slope(@pointA, @pointB)*point.x+intercept(@pointA,@pointB) &&
                    point.y <= point.x*slope(@pointAExtended, @pointBExtended)+intercept(@pointAExtended,@pointBExtended)
    isInBoxBounds = point.x >= [@pointA.x,@pointB.x].min &&
                    point.x <= [@pointA.x,@pointB.x].max &&
                    point.y >= [@pointA.y,@pointB.y].min+(@extension == :neg ? -@thickness : 0) &&
                    point.y <= [@pointA.y,@pointB.y].max+(@extension == :pos ? @thickness : 0)

    return isInBoxBounds && (isNegInLine || isPosInLine)

  end
#test if a collision has occurred
test if a collision has occurred
test if a collision has occurred
def isCollision? (point)
    if slope(@pointA, @pointB) ==  INFINITY &&
      point.x >= [@pointA.x,@pointB.x].min+(@extension == :pos ? -@thickness : 0) &&
      point.x <= [@pointA.x,@pointB.x].max+(@extension == :neg ?  @thickness : 0) &&
      point.y >= [@pointA.y,@pointB.y].min && point.y <= [@pointA.y,@pointB.y].max
        return true
    end
    isNegInLine   = @extension == :neg &&
                    point.y <= slope(@pointA, @pointB)*point.x+intercept(@pointA,@pointB) &&
                    point.y >= point.x*slope(@pointAExtended, @pointBExtended)+intercept(@pointAExtended,@pointBExtended)
    isPosInLine   = @extension == :pos &&
                    point.y >= slope(@pointA, @pointB)*point.x+intercept(@pointA,@pointB) &&
                    point.y <= point.x*slope(@pointAExtended, @pointBExtended)+intercept(@pointAExtended,@pointBExtended)
    isInBoxBounds = point.x >= [@pointA.x,@pointB.x].min &&
                    point.x <= [@pointA.x,@pointB.x].max &&
                    point.y >= [@pointA.y,@pointB.y].min+(@extension == :neg ? -@thickness : 0) &&
                    point.y <= [@pointA.y,@pointB.y].max+(@extension == :pos ? @thickness : 0)
    return isInBoxBounds && (isNegInLine || isPosInLine)
  end
def isCollision? ( point ) if slope ( @pointA , @pointB ) == INFINITY && point . x >= [ @pointA . x , @pointB . x ] . min + ( @extension == :pos ? - @thickness : 0 ) && point . x <= [ @pointA . x , @pointB . x ] . max + ( @extension == :neg ? @thickness : 0 ) && point . y >= [ @pointA . y , @pointB . y ] . min && point . y <= [ @pointA . y , @pointB . y ] . max return true end isNegInLine = @extension == :neg && point . y <= slope ( @pointA , @pointB ) * point . x + intercept ( @pointA , @pointB ) && point . y >= point . x * slope ( @pointAExtended , @pointBExtended ) + intercept ( @pointAExtended , @pointBExtended ) isPosInLine = @extension == :pos && point . y >= slope ( @pointA , @pointB ) * point . x + intercept ( @pointA , @pointB ) && point . y <= point . x * slope ( @pointAExtended , @pointBExtended ) + intercept ( @pointAExtended , @pointBExtended ) isInBoxBounds = point . x >= [ @pointA . x , @pointB . x ] . min && point . x <= [ @pointA . x , @pointB . x ] . max && point . y >= [ @pointA . y , @pointB . y ] . min + ( @extension == :neg ? - @thickness : 0 ) && point . y <= [ @pointA . y , @pointB . y ] . max + ( @extension == :pos ? @thickness : 0 ) return isInBoxBounds && ( isNegInLine || isPosInLine ) end
test if a collision has occurred
test if a collision has occurred
#INFINITY slop breaks down when trying to determin collision, ergo it requires a special test
point