# Path: megaman/plotter/utils.py
# def _check_backend(backend):
#     def decorator(func):
#         def wrapper(*args,**kwargs):
#             import warnings
#             warnings.warn(
#                 'Be careful in using megaman.plotter modules'
#                 ' API will change in the next release.',
#                 FutureWarning
#             )
#             import pkgutil
#             package = pkgutil.find_loader(backend)
#             if package is not None:
#                 return func(*args,**kwargs)
#             else:
#                 raise ImportError('plotting backend {} not installed'.format(backend))
#         return wrapper
#     return decorator


import numpy as np
    import plotly.graph_objs as go
from .utils import _check_backend
    from matplotlib.patches import Ellipse
    from mpl_toolkits.mplot3d import art3d, Axes3D
    skew = np.array([[    0,  d[2],  -d[1]],
                     [-d[2],     0,   d[0]],
                     [ d[1], -d[0],     0]], dtype=np.float64)

    M = ddt + np.sqrt(1 - sin_angle**2) * (eye - ddt) + sin_angle * skew
    return M

def create_ellipse(width,height,angle):
    """Create parametric ellipse from 200 points."""
    angle = angle / 180.0 * np.pi
    thetas = np.linspace(0,2*np.pi,200)
    a = width / 2.0
    b = height / 2.0

    x = a*np.cos(thetas)*np.cos(angle) - b*np.sin(thetas)*np.sin(angle)
    y = a*np.cos(thetas)*np.sin(angle) + b*np.sin(thetas)*np.cos(angle)
    z = np.zeros(thetas.shape)
    return np.vstack((x,y,z)).T

def transform_to_3d(points,normal,z=0):
    """Project points into 3d from 2d points."""
    d = np.cross(normal, (0, 0, 1))
    M = rotation_matrix(d)
    transformed_points = M.dot(points.T).T + z
    return transformed_points

def translate_in_3d(points,delta):
    """Translate the points in 2d by amount of delta"""
    return points + delta


# Path: megaman/plotter/utils.py
# def _check_backend(backend):
#     def decorator(func):
#         def wrapper(*args,**kwargs):
#             import warnings
#             warnings.warn(
#                 'Be careful in using megaman.plotter modules'
#                 ' API will change in the next release.',
#                 FutureWarning
#             )
#             import pkgutil
#             package = pkgutil.find_loader(backend)
#             if package is not None:
#                 return func(*args,**kwargs)
#             else:
#                 raise ImportError('plotting backend {} not installed'.format(backend))
#         return wrapper
#     return decorator


# Path: megaman/plotter/covar_plotter3.py
import numpy as np
    import plotly.graph_objs as go
from .utils import _check_backend
    from matplotlib.patches import Ellipse
    from mpl_toolkits.mplot3d import art3d, Axes3D

    skew = np.array([[    0,  d[2],  -d[1]],
                     [-d[2],     0,   d[0]],
                     [ d[1], -d[0],     0]], dtype=np.float64)

    M = ddt + np.sqrt(1 - sin_angle**2) * (eye - ddt) + sin_angle * skew
    return M

def create_ellipse(width,height,angle):
    """Create parametric ellipse from 200 points."""
    angle = angle / 180.0 * np.pi
    thetas = np.linspace(0,2*np.pi,200)
    a = width / 2.0
    b = height / 2.0

    x = a*np.cos(thetas)*np.cos(angle) - b*np.sin(thetas)*np.sin(angle)
    y = a*np.cos(thetas)*np.sin(angle) + b*np.sin(thetas)*np.cos(angle)
    z = np.zeros(thetas.shape)
    return np.vstack((x,y,z)).T

def transform_to_3d(points,normal,z=0):
    """Project points into 3d from 2d points."""
    d = np.cross(normal, (0, 0, 1))
    M = rotation_matrix(d)
    transformed_points = M.dot(points.T).T + z
    return transformed_points

def translate_in_3d(points,delta):
    """Translate the points in 2d by amount of delta"""
    return points + delta


@_check_backend('plotly')