@@ -282,9 +282,7 @@ def matrix_to_euler_angles(matrix, convention: str):
282
282
return torch .stack (o , - 1 )
283
283
284
284
285
- def random_quaternions (
286
- n : int , dtype : Optional [torch .dtype ] = None , device = None , requires_grad = False
287
- ):
285
+ def random_quaternions (n : int , dtype : Optional [torch .dtype ] = None , device = None ):
288
286
"""
289
287
Generate random quaternions representing rotations,
290
288
i.e. versors with nonnegative real part.
@@ -294,21 +292,17 @@ def random_quaternions(
294
292
dtype: Type to return.
295
293
device: Desired device of returned tensor. Default:
296
294
uses the current device for the default tensor type.
297
- requires_grad: Whether the resulting tensor should have the gradient
298
- flag set.
299
295
300
296
Returns:
301
297
Quaternions as tensor of shape (N, 4).
302
298
"""
303
- o = torch .randn ((n , 4 ), dtype = dtype , device = device , requires_grad = requires_grad )
299
+ o = torch .randn ((n , 4 ), dtype = dtype , device = device )
304
300
s = (o * o ).sum (1 )
305
301
o = o / _copysign (torch .sqrt (s ), o [:, 0 ])[:, None ]
306
302
return o
307
303
308
304
309
- def random_rotations (
310
- n : int , dtype : Optional [torch .dtype ] = None , device = None , requires_grad = False
311
- ):
305
+ def random_rotations (n : int , dtype : Optional [torch .dtype ] = None , device = None ):
312
306
"""
313
307
Generate random rotations as 3x3 rotation matrices.
314
308
@@ -317,35 +311,27 @@ def random_rotations(
317
311
dtype: Type to return.
318
312
device: Device of returned tensor. Default: if None,
319
313
uses the current device for the default tensor type.
320
- requires_grad: Whether the resulting tensor should have the gradient
321
- flag set.
322
314
323
315
Returns:
324
316
Rotation matrices as tensor of shape (n, 3, 3).
325
317
"""
326
- quaternions = random_quaternions (
327
- n , dtype = dtype , device = device , requires_grad = requires_grad
328
- )
318
+ quaternions = random_quaternions (n , dtype = dtype , device = device )
329
319
return quaternion_to_matrix (quaternions )
330
320
331
321
332
- def random_rotation (
333
- dtype : Optional [torch .dtype ] = None , device = None , requires_grad = False
334
- ):
322
+ def random_rotation (dtype : Optional [torch .dtype ] = None , device = None ):
335
323
"""
336
324
Generate a single random 3x3 rotation matrix.
337
325
338
326
Args:
339
327
dtype: Type to return
340
328
device: Device of returned tensor. Default: if None,
341
329
uses the current device for the default tensor type
342
- requires_grad: Whether the resulting tensor should have the gradient
343
- flag set
344
330
345
331
Returns:
346
332
Rotation matrix as tensor of shape (3, 3).
347
333
"""
348
- return random_rotations (1 , dtype , device , requires_grad )[0 ]
334
+ return random_rotations (1 , dtype , device )[0 ]
349
335
350
336
351
337
def standardize_quaternion (quaternions ):
0 commit comments