python raycast hits wrong face.

Im trying to cast a ray in python.
The ray works, but it seems to hit the last face instead of the first face.
Picture:http://www.pasteall.org/pic/show.php?id=73253

Code, executes from Always sensor with frequency 0:

import bge

def main():
    
    cont = bge.logic.getCurrentController()
    own = cont.owner
    
    px = own.worldPosition.x
    py = own.worldPosition.y
    pz = own.worldPosition.z
    
    xx = own.rayCast([px-1.0,py,pz], [px-1.0,py+10.0,pz], 10.0, "")
    if xx[1]:
        print('test: '+str(xx[1]))
        bge.render.drawLine([px-1.0,py,pz], xx[1], [0,255,0])

main()

Blend: http://www.pasteall.org/blend/30088

Move object with arrows to test.

Im not sure how to solve this. Thanks for any help.



#http://www.blender.org/documentation/blender_python_api_2_71_0/bge.types.KX_GameObject.html?highlight=ray%20cast#bge.types.KX_GameObject.rayCast


import bge


def main():
    
    cont = bge.logic.getCurrentController()
    own = cont.owner
    
    px = own.worldPosition.x
    py = own.worldPosition.y
    pz = own.worldPosition.z
    

    # changed the coordinate order, you were raycasting from the outside to the inside,

    xx = own.rayCast([px-1.0,py+10.0,pz],[px-1.0,py,pz], 10.0, "")
    bge.render.drawLine([px-1.0,py,pz], [px-1.0,py+10.0,pz], [255,255,0])
    if xx[1]:
        print('test: '+str(xx[1]))
        bge.render.drawLine([px-1.0,py,pz], xx[1], [0,255,0])


main()

That solved it. Thanks.