I'm making a pattern matching program with key as the object, then I overlay the resulting rectangle coordinate, the angle is right but the width is wrong, how can I fix this? I think it has something to do with the left top and bottom right coordinate but I don't know where is the problem.
this is the normal position

this is the right width

this is the wrong width

thanks in advance