original_docstring: Create X and Y grids rotated -45 degreees.
docstring: Create X and Y grids rotated -45 degreees.
docstring_tokens: Create X and Y grids rotated - 45 degreees .
code: def _get_45deg_mesh(mat):
      """Create X and Y grids rotated -45 degreees."""
      # Define rotation matrix
      theta = -np.pi / 4
      R = np.array([[np.cos(theta), -np.sin(theta)],
                    [np.sin(theta), np.cos(theta)]])
  
      # Define unrotated coordinates on
      K = len(mat) + 1
      grid1d = np.arange(0, K) - .5
      X = np.tile(np.reshape(grid1d, [K, 1]), [1, K])
      Y = np.tile(np.reshape(grid1d, [1, K]), [K, 1])
      xy = np.array([X.ravel(), Y.ravel()])
  
      # Rotate coordinates
      xy_rot = R @ xy
      X_rot = xy_rot[0, :].reshape(K, K)
      Y_rot = xy_rot[1, :].reshape(K, K).T
  
      return X_rot, Y_rot
code_tokens: def _get_45deg_mesh ( mat ) : theta = - np . pi / 4 R = np . array ( [ [ np . cos ( theta ) , - np . sin ( theta ) ] , [ np . sin ( theta ) , np . cos ( theta ) ] ] ) K = len ( mat ) + 1 grid1d = np . arange ( 0 , K ) - .5 X = np . tile ( np . reshape ( grid1d , [ K , 1 ] ) , [ 1 , K ] ) Y = np . tile ( np . reshape ( grid1d , [ 1 , K ] ) , [ K , 1 ] ) xy = np . array ( [ X . ravel ( ) , Y . ravel ( ) ] ) xy_rot = R @ xy X_rot = xy_rot [ 0 , : ] . reshape ( K , K ) Y_rot = xy_rot [ 1 , : ] . reshape ( K , K ) . T return X_rot , Y_rot
short_docstring: Create X and Y grids rotated -45 degreees.
short_docstring_tokens: Create X and Y grids rotated - 45 degreees .
comment: """Create X and Y grids rotated -45 degreees."""$SEP$# Define rotation matrix$SEP$# Define unrotated coordinates on$SEP$# Rotate coordinates