MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / _get_3rd_point

Function _get_3rd_point

detrsmpl/data/datasets/pipelines/transforms.py:94–111  ·  view source on GitHub ↗

To calculate the affine matrix, three pairs of points are required. This function is used to get the 3rd point, given 2D points a & b. The 3rd point is defined by rotating vector `a - b` by 90 degrees anticlockwise, using b as the rotation center. Args: a (np.ndarray): point

(a, b)

Source from the content-addressed store, hash-verified

92
93
94def _get_3rd_point(a, b):
95 """To calculate the affine matrix, three pairs of points are required. This
96 function is used to get the 3rd point, given 2D points a & b.
97
98 The 3rd point is defined by rotating vector `a - b` by 90 degrees
99 anticlockwise, using b as the rotation center.
100 Args:
101 a (np.ndarray): point(x,y)
102 b (np.ndarray): point(x,y)
103 Returns:
104 np.ndarray: The 3rd point.
105 """
106 assert len(a) == 2
107 assert len(b) == 2
108 direction = a - b
109 third_pt = b + np.array([-direction[1], direction[0]], dtype=np.float32)
110
111 return third_pt
112
113
114def rotate_point(pt, angle_rad):

Callers 1

get_affine_transformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected