MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / _get_3rd_point

Function _get_3rd_point

PATH/core/data/transforms/post_transforms.py:265–284  ·  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): poin

(a, b)

Source from the content-addressed store, hash-verified

263
264
265def _get_3rd_point(a, b):
266 """To calculate the affine matrix, three pairs of points are required. This
267 function is used to get the 3rd point, given 2D points a & b.
268
269 The 3rd point is defined by rotating vector `a - b` by 90 degrees
270 anticlockwise, using b as the rotation center.
271
272 Args:
273 a (np.ndarray): point(x,y)
274 b (np.ndarray): point(x,y)
275
276 Returns:
277 np.ndarray: The 3rd point.
278 """
279 assert len(a) == 2
280 assert len(b) == 2
281 direction = a - b
282 third_pt = b + np.array([-direction[1], direction[0]], dtype=np.float32)
283
284 return third_pt
285
286
287def rotate_point(pt, angle_rad):

Callers 1

get_affine_transformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected