# Path: sucemfem/Utilities/Geometry.py
# def unit_vector(vec):
#     """Calculate a unit vector of vec"""
#     return vec/vector_length(vec)
# 
# def vector_length(vec):
#     """Calculate the length of a vector"""
#     return np.sqrt(np.sum(vec**2))
# 
# Path: sucemfem/Utilities/Converters.py
# def as_dolfin_vector(a):
#     """Convert array to a dolfin Vector() instance"""
#     assert len(a.shape) == 1            # 1D vectors please
#     v = dolfin.Vector(len(a))
#     v.set_local(np.require(a, requirements=['C',]))
#     return v


import dolfin
import numpy as np
from scipy.integrate import romberg
from sucemfem.Utilities.Geometry import unit_vector, vector_length
from sucemfem.Utilities.Converters import as_dolfin_vector
## Copyright (C) 2011 Stellenbosch University
##
## This file is part of SUCEM.
##
## SUCEM is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## SUCEM is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with SUCEM. If not, see <http://www.gnu.org/licenses/>. 
##
## Contact: cemagga@gmail.com 
from __future__ import division


class VoltageAlongLine(object):
    """Measure voltage along a straight line between two points"""
    def __init__(self, field_function):
        self.field_function = field_function

    def calculate_voltage(self, start_pt, end_pt):
        fn = self.field_function
        delta = end_pt - start_pt

# Path: sucemfem/Utilities/Geometry.py
# def unit_vector(vec):
#     """Calculate a unit vector of vec"""
#     return vec/vector_length(vec)
# 
# def vector_length(vec):
#     """Calculate the length of a vector"""
#     return np.sqrt(np.sum(vec**2))
# 
# Path: sucemfem/Utilities/Converters.py
# def as_dolfin_vector(a):
#     """Convert array to a dolfin Vector() instance"""
#     assert len(a.shape) == 1            # 1D vectors please
#     v = dolfin.Vector(len(a))
#     v.set_local(np.require(a, requirements=['C',]))
#     return v


# Path: sucemfem/Sources/PostProcess.py
import dolfin
import numpy as np
from scipy.integrate import romberg
from sucemfem.Utilities.Geometry import unit_vector, vector_length
from sucemfem.Utilities.Converters import as_dolfin_vector

## Copyright (C) 2011 Stellenbosch University
##
## This file is part of SUCEM.
##
## SUCEM is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## SUCEM is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with SUCEM. If not, see <http://www.gnu.org/licenses/>. 
##
## Contact: cemagga@gmail.com 
from __future__ import division


class VoltageAlongLine(object):
    """Measure voltage along a straight line between two points"""
    def __init__(self, field_function):
        self.field_function = field_function

    def calculate_voltage(self, start_pt, end_pt):
        fn = self.field_function
        delta = end_pt - start_pt

        l_hat = unit_vector(delta)