(body, position_factor, size_factor)
Recursively rescales an entire subtree of an MJCF model.
Recursively rescales an entire subtree of an MJCF model.
Recursively rescales an entire subtree of an MJCF model .
def rescale_subtree(body, position_factor, size_factor):
  """Recursively rescales an entire subtree of an MJCF model."""
  for child in body.all_children():
    if getattr(child, 'fromto', None) is not None:
      new_pos = position_factor * 0.5 * (child.fromto[3:] + child.fromto[:3])
      new_size = size_factor * 0.5 * (child.fromto[3:] - child.fromto[:3])
      child.fromto[:3] = new_pos - new_size
      child.fromto[3:] = new_pos + new_size
    if getattr(child, 'pos', None) is not None:
      child.pos *= position_factor
    if getattr(child, 'size', None) is not None:
      child.size *= size_factor
    if child.tag == 'body' or child.tag == 'worldbody':
      rescale_subtree(child, position_factor, size_factor)
def rescale_subtree ( body , position_factor , size_factor ) : for child in body . all_children ( ) : if getattr ( child , 'fromto' , None ) is not None : new_pos = position_factor * 0.5 * ( child . fromto [ 3 : ] + child . fromto [ : 3 ] ) new_size = size_factor * 0.5 * ( child . fromto [ 3 : ] - child . fromto [ : 3 ] ) child . fromto [ : 3 ] = new_pos - new_size child . fromto [ 3 : ] = new_pos + new_size if getattr ( child , 'pos' , None ) is not None : child . pos *= position_factor if getattr ( child , 'size' , None ) is not None : child . size *= size_factor if child . tag == 'body' or child . tag == 'worldbody' : rescale_subtree ( child , position_factor , size_factor )