# Path: airconics/primitives.py
# class Airfoil(object):
#     def __init__(self,
#                  LeadingEdgePoint=[0., 0., 0.],
#                  ChordLength=1,
#                  Rotation=0,
#                  Twist=0,
#                  SeligProfile=None,
#                  Naca4Profile=None,
#                  Naca5Profile=None,
#                  CRMProfile=None,
#                  CRM_Epsilon=0.,
#                  InterpProfile=None,
#                  Epsilon=0, Af1=None, Af2=None, Eps1=0, Eps2=1,
#                  EnforceSharpTE=False):
#     def points(self):
#     def points(self, newpoints):
#     def _make_airfoil(self, SeligProfile, Naca4Profile, Naca5Profile,
#                       CRMProfile, CRM_Epsilon,
#                       InterpProfile, Epsilon, Af1, Af2, Eps1, Eps2):
#     def _fitAirfoiltoPoints(self):
#     def _AirfoilPointsSeligFormat(self, SeligProfile):
#     def _NACA4cambercurve(self, MaxCamberLocTenthChord, MaxCamberPercChord):
#     def _NACA4halfthickness(self, ChordCoord, MaxThicknessPercChord):
#     def _camberplusthickness(self, ChordCoord, zcam, dzcamdx, t):
#     def _mergesurfaces(self, xu, zu, xl, zl):
#     def _NACA4digitPnts(self, MaxCamberPercChord, MaxCamberLocTenthChord,
#                         MaxThicknessPercChord):
#     def _TransformAirfoil(self):
#     def AddAirfoilFromSeligFile(self, SeligProfile, Smoothing=1):
#     def AddNACA4(self, Naca4Profile, Smoothing=1):
#     def AddCRMLinear(self, CRM_Epsilon, Smoothing=1):
#     def AddLinear2(self, Eps, Af1, Af2, Eps1=0, Eps2=1):
#         N = np.shape(self._points)[0]
#         N = len(data)
#         RLE = 1.1019*(MaxThicknessPercChord/100.0)**2.0


import numpy as np
from airconics import primitives
from pkg_resources import resource_string
def myDihedralFunctionFin(Epsilon):
    return 0


def myTwistFunctionFin(Epsilon):
    return 0


def myChordFunctionFin(Epsilon):
    """User-defined function describing the variation of the fin chord as a
    function of the leading edge coordinate"""
    # Data for Chordlengths is included in the airconics distribution:
    #  load using pkg_resources
    rawdata = resource_string(__name__, 'airliner_fin_chords.dat')
    ChordLengths = np.fromstring(rawdata, sep='\n')

    EpsArray = np.linspace(0, 1, np.size(ChordLengths))
    return np.interp(Epsilon, EpsArray, ChordLengths)


def myAirfoilFunctionFin(Epsilon, LEPoint, ChordFunct, ChordFactor,
                         DihedralFunct, TwistFunct):
    """Defines the variation of cross section as a function of Epsilon"""

    AirfoilChordLength = (ChordFactor*ChordFunct(Epsilon) /
                          np.cos(np.radians(TwistFunct(Epsilon))))

    AirfoilSeligName = 'sc20010'

#    TODO : SmoothingPasses = 3

# Path: airconics/primitives.py
# class Airfoil(object):
#     def __init__(self,
#                  LeadingEdgePoint=[0., 0., 0.],
#                  ChordLength=1,
#                  Rotation=0,
#                  Twist=0,
#                  SeligProfile=None,
#                  Naca4Profile=None,
#                  Naca5Profile=None,
#                  CRMProfile=None,
#                  CRM_Epsilon=0.,
#                  InterpProfile=None,
#                  Epsilon=0, Af1=None, Af2=None, Eps1=0, Eps2=1,
#                  EnforceSharpTE=False):
#     def points(self):
#     def points(self, newpoints):
#     def _make_airfoil(self, SeligProfile, Naca4Profile, Naca5Profile,
#                       CRMProfile, CRM_Epsilon,
#                       InterpProfile, Epsilon, Af1, Af2, Eps1, Eps2):
#     def _fitAirfoiltoPoints(self):
#     def _AirfoilPointsSeligFormat(self, SeligProfile):
#     def _NACA4cambercurve(self, MaxCamberLocTenthChord, MaxCamberPercChord):
#     def _NACA4halfthickness(self, ChordCoord, MaxThicknessPercChord):
#     def _camberplusthickness(self, ChordCoord, zcam, dzcamdx, t):
#     def _mergesurfaces(self, xu, zu, xl, zl):
#     def _NACA4digitPnts(self, MaxCamberPercChord, MaxCamberLocTenthChord,
#                         MaxThicknessPercChord):
#     def _TransformAirfoil(self):
#     def AddAirfoilFromSeligFile(self, SeligProfile, Smoothing=1):
#     def AddNACA4(self, Naca4Profile, Smoothing=1):
#     def AddCRMLinear(self, CRM_Epsilon, Smoothing=1):
#     def AddLinear2(self, Eps, Af1, Af2, Eps1=0, Eps2=1):
#         N = np.shape(self._points)[0]
#         N = len(data)
#         RLE = 1.1019*(MaxThicknessPercChord/100.0)**2.0


# Path: airconics/examples/tailplane_example_transonic_airliner.py
import numpy as np
from airconics import primitives
from pkg_resources import resource_string

def myDihedralFunctionFin(Epsilon):
    return 0


def myTwistFunctionFin(Epsilon):
    return 0


def myChordFunctionFin(Epsilon):
    """User-defined function describing the variation of the fin chord as a
    function of the leading edge coordinate"""
    # Data for Chordlengths is included in the airconics distribution:
    #  load using pkg_resources
    rawdata = resource_string(__name__, 'airliner_fin_chords.dat')
    ChordLengths = np.fromstring(rawdata, sep='\n')

    EpsArray = np.linspace(0, 1, np.size(ChordLengths))
    return np.interp(Epsilon, EpsArray, ChordLengths)


def myAirfoilFunctionFin(Epsilon, LEPoint, ChordFunct, ChordFactor,
                         DihedralFunct, TwistFunct):
    """Defines the variation of cross section as a function of Epsilon"""

    AirfoilChordLength = (ChordFactor*ChordFunct(Epsilon) /
                          np.cos(np.radians(TwistFunct(Epsilon))))

    AirfoilSeligName = 'sc20010'

#    TODO : SmoothingPasses = 3

    Af = primitives.Airfoil(LEPoint, ChordLength=AirfoilChordLength,