Using is_within_safety_limits not giving correct results in some case

Hello everybody,
I am very grateful for your help.
My objective is to find the maximum size reached by the robot according to the x, y, and z dimensions compared to an initial point.
For example, according to an initial point the robot can go 5000 mm according to x, 500 mm to y 500 mm to z.
my goal how to find this limit according to an initial point. Note the limits change according to that initial point. I thought about using the function is_within_safety_limits. Like the example you see and I add a step until I find the limit. in some cases, it gives me an incorrect result. Could you help me? In some cases, i test this function alone it returns me true or it must return false, the point is not safe.

global point1= get_actual_tcp_pose ()

global trans_point2=0.05

global point2= pose_trans (point1,p[0,trans_point2,0,0,0,0])

while ((is_within_safety_limits(point2)==True)):

global point2= pose_trans (point1,p[0,trans_point2,0,0,0,0])

global trans_point2=trans_point2+0.05

end

global largeur_max=trans_point2-0.05