Calculation method of UV direction of polygon material

When I draw a polygon, the texture map direction is sometimes wrong, how can I confirm the UV coordinate direction so that I can calculate the correct material repeat value.
I drew two polygons with the same parameters, but their texture direction is different: