# Autogenerated with SMOP 
from smop.core import *
# ShearOnPlane.m

    
@function
def ShearOnPlane(stress=None,tX1=None,pX1=None,tX3=None,strike=None,dip=None,*args,**kwargs):
    varargin = ShearOnPlane.varargin
    nargin = ShearOnPlane.nargin

    #ShearOnPlane calculates the direction and magnitudes of the normal
#and shear tractions on an arbitrarily oriented plane
    
    #   USE: [TT,dCTT,R] = ShearOnPlane(stress,tX1,pX1,tX3,strike,dip)
    
    #   stress = 3 x 3 stress tensor
#   tX1 = trend of X1
#   pX1 = plunge of X1
#   tX3 = trend of X3
#   strike = strike of plane
#   dip = dip of plane
#   TT = 3 x 3 matrix with the magnitude (column 1), trend (column 2) and 
#       plunge (column 3) of: normal traction on the plane (row 1), 
#       minimum shear traction (row 2), and maximum shear traction (row 3)
#   dCTT = 3 x 3 matrix with the direction cosines of unit vectors parallel
#         to: normal traction on the plane (row 1), minimum shear traction
#         (row 2), and maximum shear traction (row 3)
#   R = Stress ratio
    
    #   NOTE = Input stress tensor does not need to be along principal stress
#          directions
#          Plane orientation follows the right hand rule 
#          Input/Output angles are in radians
    
    #   ShearOnPlane uses functions PrincipalStress, Cauchy and CartToSph
    
    #MATLAB script written by Nestor Cardozo for the book Structural 
#Geology Algorithms by Allmendinger, Cardozo, & Fisher, 2011. If you use
#this script, please cite this as "Cardozo in Allmendinger et al. (2011)"
    
    #Initialize TT and dCTT
    TT=zeros(3,3)
# ShearOnPlane.m:33
    dCTT=zeros(3,3)
# ShearOnPlane.m:34
    #Compute principal stresses and principal stress directions
    pstress,dCp=PrincipalStress(stress,tX1,pX1,tX3,nargout=2)
# ShearOnPlane.m:37
    #Update stress vector so that it is along principal stress directions
    stress=zeros(3,3)
# ShearOnPlane.m:40
    for i in arange(1,3).reshape(-1):
        stress[i,i]=pstress[i,1]
# ShearOnPlane.m:42
    
    #Compute tractions on plane in principal stress direction (Eqs. 6.24-6.26)
    T,pT=Cauchy(stress,pstress[1,2],pstress[1,3],pstress[3,2],strike,dip,nargout=2)
# ShearOnPlane.m:46
    #Find the B axis by the cross product of T cross pT and convert to
#direction cosines (Eq 6.27)
    B=zeros(1,3)
# ShearOnPlane.m:50
    B[1]=dot(T[2],pT[3]) - dot(T[3],pT[2])
# ShearOnPlane.m:51
    B[2]=dot(T[3],pT[1]) - dot(T[1],pT[3])
# ShearOnPlane.m:52
    B[3]=dot(T[1],pT[2]) - dot(T[2],pT[1])
# ShearOnPlane.m:53
    #Find the shear direction by the cross product of pT cross B. This will
#give S in right handed coordinates (Eq. 6.27)
    S=zeros(1,3)
# ShearOnPlane.m:57
    S[1]=dot(pT[2],B[3]) - dot(pT[3],B[2])
# ShearOnPlane.m:58
    S[2]=dot(pT[3],B[1]) - dot(pT[1],B[3])
# ShearOnPlane.m:59
    S[3]=dot(pT[1],B[2]) - dot(pT[2],B[1])
# ShearOnPlane.m:60
    #Convert T, B and S to unit vectors
    rT=sqrt(dot(T[1],T[1]) + dot(T[2],T[2]) + dot(T[3],T[3]))
# ShearOnPlane.m:63
    rB=sqrt(dot(B[1],B[1]) + dot(B[2],B[2]) + dot(B[3],B[3]))
# ShearOnPlane.m:64
    rS=sqrt(dot(S[1],S[1]) + dot(S[2],S[2]) + dot(S[3],S[3]))
# ShearOnPlane.m:65
    for i in arange(1,3).reshape(-1):
        T[i]=T[i] / rT
# ShearOnPlane.m:67
        B[i]=B[i] / rB
# ShearOnPlane.m:68
        S[i]=S[i] / rS
# ShearOnPlane.m:69
    
    #Now we can write the transformation matrix from principal stress
#coordinates to plane coordinates (Eq. 6.28)
    a=zeros(3,3)
# ShearOnPlane.m:74
    a[1,:]=cat(pT[1],pT[2],pT[3])
# ShearOnPlane.m:75
    a[2,:]=cat(B[1],B[2],B[3])
# ShearOnPlane.m:76
    a[3,:]=cat(S[1],S[2],S[3])
# ShearOnPlane.m:77
    #Calculate stress ratio (Eq. 6.32)
    R=(stress[2,2] - stress[1,1]) / (stress[3,3] - stress[1,1])
# ShearOnPlane.m:80
    #Calculate magnitude of normal and shear tractions (Eq. 6.31)
    for i in arange(1,3).reshape(-1):
        TT[i,1]=dot(dot(stress[1,1],a[1,1]),a[i,1]) + dot(dot(stress[2,2],a[1,2]),a[i,2]) + dot(dot(stress[3,3],a[1,3]),a[i,3])
# ShearOnPlane.m:84
    
    #To get the orientation of the tractions in North-East-Down coordinates, we
#need to do a vector transformation between principal stress and
#North-East-Down coordinates. The transformation matrix are just the
#direction cosines of the principal stresses in North-East-Down coordinates
#(Eq. 6.29)
    for i in arange(1,3).reshape(-1):
        for j in arange(1,3).reshape(-1):
            dCTT[1,i]=dot(dCp[j,i],pT[j]) + dCTT[1,i]
# ShearOnPlane.m:95
            dCTT[2,i]=dot(dCp[j,i],B[j]) + dCTT[2,i]
# ShearOnPlane.m:96
            dCTT[3,i]=dot(dCp[j,i],S[j]) + dCTT[3,i]
# ShearOnPlane.m:97
    
    #Trend and plunge of traction on plane
    TT[1,2],TT[1,3]=CartToSph(dCTT[1,1],dCTT[1,2],dCTT[1,3],nargout=2)
# ShearOnPlane.m:102
    #Trend and plunge of minimum shear direction
    TT[2,2],TT[2,3]=CartToSph(dCTT[2,1],dCTT[2,2],dCTT[2,3],nargout=2)
# ShearOnPlane.m:104
    #Trend and plunge of maximum shear direction
    TT[3,2],TT[3,3]=CartToSph(dCTT[3,1],dCTT[3,2],dCTT[3,3],nargout=2)
# ShearOnPlane.m:106
    return TT,dCTT,R
    
if __name__ == '__main__':
    pass
    
2561f271eabb8cafa9b6f8995db9919f0a649c1b
<mask token>

<mask token>


@function
def ShearOnPlane(stress=None, tX1=None, pX1=None, tX3=None, strike=None,
    dip=None, *args, **kwargs):
    varargin = ShearOnPlane.varargin
    nargin = ShearOnPlane.nargin
    TT = zeros(3, 3)
    dCTT = zeros(3, 3)
    pstress, dCp = PrincipalStress(stress, tX1, pX1, tX3, nargout=2)
    stress = zeros(3, 3)
    for i in arange(1, 3).reshape(-1):
        stress[i, i] = pstress[i, 1]
    T, pT = Cauchy(stress, pstress[1, 2], pstress[1, 3], pstress[3, 2],
        strike, dip, nargout=2)
    B = zeros(1, 3)
    B[1] = dot(T[2], pT[3]) - dot(T[3], pT[2])
    B[2] = dot(T[3], pT[1]) - dot(T[1], pT[3])
    B[3] = dot(T[1], pT[2]) - dot(T[2], pT[1])
    S = zeros(1, 3)
    S[1] = dot(pT[2], B[3]) - dot(pT[3], B[2])
    S[2] = dot(pT[3], B[1]) - dot(pT[1], B[3])
    S[3] = dot(pT[1], B[2]) - dot(pT[2], B[1])
    rT = sqrt(dot(T[1], T[1]) + dot(T[2], T[2]) + dot(T[3], T[3]))
    rB = sqrt(dot(B[1], B[1]) + dot(B[2], B[2]) + dot(B[3], B[3]))
    rS = sqrt(dot(S[1], S[1]) + dot(S[2], S[2]) + dot(S[3], S[3]))
    for i in arange(1, 3).reshape(-1):
        T[i] = T[i] / rT
        B[i] = B[i] / rB
        S[i] = S[i] / rS
    a = zeros(3, 3)
    a[1, :] = cat(pT[1], pT[2], pT[3])
    a[2, :] = cat(B[1], B[2], B[3])
    a[3, :] = cat(S[1], S[2], S[3])
    R = (stress[2, 2] - stress[1, 1]) / (stress[3, 3] - stress[1, 1])
    for i in arange(1, 3).reshape(-1):
        TT[i, 1] = dot(dot(stress[1, 1], a[1, 1]), a[i, 1]) + dot(dot(
            stress[2, 2], a[1, 2]), a[i, 2]) + dot(dot(stress[3, 3], a[1, 3
            ]), a[i, 3])
    for i in arange(1, 3).reshape(-1):
        for j in arange(1, 3).reshape(-1):
            dCTT[1, i] = dot(dCp[j, i], pT[j]) + dCTT[1, i]
            dCTT[2, i] = dot(dCp[j, i], B[j]) + dCTT[2, i]
            dCTT[3, i] = dot(dCp[j, i], S[j]) + dCTT[3, i]
    TT[1, 2], TT[1, 3] = CartToSph(dCTT[1, 1], dCTT[1, 2], dCTT[1, 3],
        nargout=2)
    TT[2, 2], TT[2, 3] = CartToSph(dCTT[2, 1], dCTT[2, 2], dCTT[2, 3],
        nargout=2)
    TT[3, 2], TT[3, 3] = CartToSph(dCTT[3, 1], dCTT[3, 2], dCTT[3, 3],
        nargout=2)
    return TT, dCTT, R


<mask token>

<mask token>


@function
def ShearOnPlane(stress=None, tX1=None, pX1=None, tX3=None, strike=None,
    dip=None, *args, **kwargs):
    varargin = ShearOnPlane.varargin
    nargin = ShearOnPlane.nargin
    TT = zeros(3, 3)
    dCTT = zeros(3, 3)
    pstress, dCp = PrincipalStress(stress, tX1, pX1, tX3, nargout=2)
    stress = zeros(3, 3)
    for i in arange(1, 3).reshape(-1):
        stress[i, i] = pstress[i, 1]
    T, pT = Cauchy(stress, pstress[1, 2], pstress[1, 3], pstress[3, 2],
        strike, dip, nargout=2)
    B = zeros(1, 3)
    B[1] = dot(T[2], pT[3]) - dot(T[3], pT[2])
    B[2] = dot(T[3], pT[1]) - dot(T[1], pT[3])
    B[3] = dot(T[1], pT[2]) - dot(T[2], pT[1])
    S = zeros(1, 3)
    S[1] = dot(pT[2], B[3]) - dot(pT[3], B[2])
    S[2] = dot(pT[3], B[1]) - dot(pT[1], B[3])
    S[3] = dot(pT[1], B[2]) - dot(pT[2], B[1])
    rT = sqrt(dot(T[1], T[1]) + dot(T[2], T[2]) + dot(T[3], T[3]))
    rB = sqrt(dot(B[1], B[1]) + dot(B[2], B[2]) + dot(B[3], B[3]))
    rS = sqrt(dot(S[1], S[1]) + dot(S[2], S[2]) + dot(S[3], S[3]))
    for i in arange(1, 3).reshape(-1):
        T[i] = T[i] / rT
        B[i] = B[i] / rB
        S[i] = S[i] / rS
    a = zeros(3, 3)
    a[1, :] = cat(pT[1], pT[2], pT[3])
    a[2, :] = cat(B[1], B[2], B[3])
    a[3, :] = cat(S[1], S[2], S[3])
    R = (stress[2, 2] - stress[1, 1]) / (stress[3, 3] - stress[1, 1])
    for i in arange(1, 3).reshape(-1):
        TT[i, 1] = dot(dot(stress[1, 1], a[1, 1]), a[i, 1]) + dot(dot(
            stress[2, 2], a[1, 2]), a[i, 2]) + dot(dot(stress[3, 3], a[1, 3
            ]), a[i, 3])
    for i in arange(1, 3).reshape(-1):
        for j in arange(1, 3).reshape(-1):
            dCTT[1, i] = dot(dCp[j, i], pT[j]) + dCTT[1, i]
            dCTT[2, i] = dot(dCp[j, i], B[j]) + dCTT[2, i]
            dCTT[3, i] = dot(dCp[j, i], S[j]) + dCTT[3, i]
    TT[1, 2], TT[1, 3] = CartToSph(dCTT[1, 1], dCTT[1, 2], dCTT[1, 3],
        nargout=2)
    TT[2, 2], TT[2, 3] = CartToSph(dCTT[2, 1], dCTT[2, 2], dCTT[2, 3],
        nargout=2)
    TT[3, 2], TT[3, 3] = CartToSph(dCTT[3, 1], dCTT[3, 2], dCTT[3, 3],
        nargout=2)
    return TT, dCTT, R


if __name__ == '__main__':
    pass

from smop.core import *


@function
def ShearOnPlane(stress=None, tX1=None, pX1=None, tX3=None, strike=None,
    dip=None, *args, **kwargs):
    varargin = ShearOnPlane.varargin
    nargin = ShearOnPlane.nargin
    TT = zeros(3, 3)
    dCTT = zeros(3, 3)
    pstress, dCp = PrincipalStress(stress, tX1, pX1, tX3, nargout=2)
    stress = zeros(3, 3)
    for i in arange(1, 3).reshape(-1):
        stress[i, i] = pstress[i, 1]
    T, pT = Cauchy(stress, pstress[1, 2], pstress[1, 3], pstress[3, 2],
        strike, dip, nargout=2)
    B = zeros(1, 3)
    B[1] = dot(T[2], pT[3]) - dot(T[3], pT[2])
    B[2] = dot(T[3], pT[1]) - dot(T[1], pT[3])
    B[3] = dot(T[1], pT[2]) - dot(T[2], pT[1])
    S = zeros(1, 3)
    S[1] = dot(pT[2], B[3]) - dot(pT[3], B[2])
    S[2] = dot(pT[3], B[1]) - dot(pT[1], B[3])
    S[3] = dot(pT[1], B[2]) - dot(pT[2], B[1])
    rT = sqrt(dot(T[1], T[1]) + dot(T[2], T[2]) + dot(T[3], T[3]))
    rB = sqrt(dot(B[1], B[1]) + dot(B[2], B[2]) + dot(B[3], B[3]))
    rS = sqrt(dot(S[1], S[1]) + dot(S[2], S[2]) + dot(S[3], S[3]))
    for i in arange(1, 3).reshape(-1):
        T[i] = T[i] / rT
        B[i] = B[i] / rB
        S[i] = S[i] / rS
    a = zeros(3, 3)
    a[1, :] = cat(pT[1], pT[2], pT[3])
    a[2, :] = cat(B[1], B[2], B[3])
    a[3, :] = cat(S[1], S[2], S[3])
    R = (stress[2, 2] - stress[1, 1]) / (stress[3, 3] - stress[1, 1])
    for i in arange(1, 3).reshape(-1):
        TT[i, 1] = dot(dot(stress[1, 1], a[1, 1]), a[i, 1]) + dot(dot(
            stress[2, 2], a[1, 2]), a[i, 2]) + dot(dot(stress[3, 3], a[1, 3
            ]), a[i, 3])
    for i in arange(1, 3).reshape(-1):
        for j in arange(1, 3).reshape(-1):
            dCTT[1, i] = dot(dCp[j, i], pT[j]) + dCTT[1, i]
            dCTT[2, i] = dot(dCp[j, i], B[j]) + dCTT[2, i]
            dCTT[3, i] = dot(dCp[j, i], S[j]) + dCTT[3, i]
    TT[1, 2], TT[1, 3] = CartToSph(dCTT[1, 1], dCTT[1, 2], dCTT[1, 3],
        nargout=2)
    TT[2, 2], TT[2, 3] = CartToSph(dCTT[2, 1], dCTT[2, 2], dCTT[2, 3],
        nargout=2)
    TT[3, 2], TT[3, 3] = CartToSph(dCTT[3, 1], dCTT[3, 2], dCTT[3, 3],
        nargout=2)
    return TT, dCTT, R


if __name__ == '__main__':
    pass

# Autogenerated with SMOP 
from smop.core import *
# ShearOnPlane.m

    
@function
def ShearOnPlane(stress=None,tX1=None,pX1=None,tX3=None,strike=None,dip=None,*args,**kwargs):
    varargin = ShearOnPlane.varargin
    nargin = ShearOnPlane.nargin

    #ShearOnPlane calculates the direction and magnitudes of the normal
#and shear tractions on an arbitrarily oriented plane
    
    #   USE: [TT,dCTT,R] = ShearOnPlane(stress,tX1,pX1,tX3,strike,dip)
    
    #   stress = 3 x 3 stress tensor
#   tX1 = trend of X1
#   pX1 = plunge of X1
#   tX3 = trend of X3
#   strike = strike of plane
#   dip = dip of plane
#   TT = 3 x 3 matrix with the magnitude (column 1), trend (column 2) and 
#       plunge (column 3) of: normal traction on the plane (row 1), 
#       minimum shear traction (row 2), and maximum shear traction (row 3)
#   dCTT = 3 x 3 matrix with the direction cosines of unit vectors parallel
#         to: normal traction on the plane (row 1), minimum shear traction
#         (row 2), and maximum shear traction (row 3)
#   R = Stress ratio
    
    #   NOTE = Input stress tensor does not need to be along principal stress
#          directions
#          Plane orientation follows the right hand rule 
#          Input/Output angles are in radians
    
    #   ShearOnPlane uses functions PrincipalStress, Cauchy and CartToSph
    
    #MATLAB script written by Nestor Cardozo for the book Structural 
#Geology Algorithms by Allmendinger, Cardozo, & Fisher, 2011. If you use
#this script, please cite this as "Cardozo in Allmendinger et al. (2011)"
    
    #Initialize TT and dCTT
    TT=zeros(3,3)
# ShearOnPlane.m:33
    dCTT=zeros(3,3)
# ShearOnPlane.m:34
    #Compute principal stresses and principal stress directions
    pstress,dCp=PrincipalStress(stress,tX1,pX1,tX3,nargout=2)
# ShearOnPlane.m:37
    #Update stress vector so that it is along principal stress directions
    stress=zeros(3,3)
# ShearOnPlane.m:40
    for i in arange(1,3).reshape(-1):
        stress[i,i]=pstress[i,1]
# ShearOnPlane.m:42
    
    #Compute tractions on plane in principal stress direction (Eqs. 6.24-6.26)
    T,pT=Cauchy(stress,pstress[1,2],pstress[1,3],pstress[3,2],strike,dip,nargout=2)
# ShearOnPlane.m:46
    #Find the B axis by the cross product of T cross pT and convert to
#direction cosines (Eq 6.27)
    B=zeros(1,3)
# ShearOnPlane.m:50
    B[1]=dot(T[2],pT[3]) - dot(T[3],pT[2])
# ShearOnPlane.m:51
    B[2]=dot(T[3],pT[1]) - dot(T[1],pT[3])
# ShearOnPlane.m:52
    B[3]=dot(T[1],pT[2]) - dot(T[2],pT[1])
# ShearOnPlane.m:53
    #Find the shear direction by the cross product of pT cross B. This will
#give S in right handed coordinates (Eq. 6.27)
    S=zeros(1,3)
# ShearOnPlane.m:57
    S[1]=dot(pT[2],B[3]) - dot(pT[3],B[2])
# ShearOnPlane.m:58
    S[2]=dot(pT[3],B[1]) - dot(pT[1],B[3])
# ShearOnPlane.m:59
    S[3]=dot(pT[1],B[2]) - dot(pT[2],B[1])
# ShearOnPlane.m:60
    #Convert T, B and S to unit vectors
    rT=sqrt(dot(T[1],T[1]) + dot(T[2],T[2]) + dot(T[3],T[3]))
# ShearOnPlane.m:63
    rB=sqrt(dot(B[1],B[1]) + dot(B[2],B[2]) + dot(B[3],B[3]))
# ShearOnPlane.m:64
    rS=sqrt(dot(S[1],S[1]) + dot(S[2],S[2]) + dot(S[3],S[3]))
# ShearOnPlane.m:65
    for i in arange(1,3).reshape(-1):
        T[i]=T[i] / rT
# ShearOnPlane.m:67
        B[i]=B[i] / rB
# ShearOnPlane.m:68
        S[i]=S[i] / rS
# ShearOnPlane.m:69
    
    #Now we can write the transformation matrix from principal stress
#coordinates to plane coordinates (Eq. 6.28)
    a=zeros(3,3)
# ShearOnPlane.m:74
    a[1,:]=cat(pT[1],pT[2],pT[3])
# ShearOnPlane.m:75
    a[2,:]=cat(B[1],B[2],B[3])
# ShearOnPlane.m:76
    a[3,:]=cat(S[1],S[2],S[3])
# ShearOnPlane.m:77
    #Calculate stress ratio (Eq. 6.32)
    R=(stress[2,2] - stress[1,1]) / (stress[3,3] - stress[1,1])
# ShearOnPlane.m:80
    #Calculate magnitude of normal and shear tractions (Eq. 6.31)
    for i in arange(1,3).reshape(-1):
        TT[i,1]=dot(dot(stress[1,1],a[1,1]),a[i,1]) + dot(dot(stress[2,2],a[1,2]),a[i,2]) + dot(dot(stress[3,3],a[1,3]),a[i,3])
# ShearOnPlane.m:84
    
    #To get the orientation of the tractions in North-East-Down coordinates, we
#need to do a vector transformation between principal stress and
#North-East-Down coordinates. The transformation matrix are just the
#direction cosines of the principal stresses in North-East-Down coordinates
#(Eq. 6.29)
    for i in arange(1,3).reshape(-1):
        for j in arange(1,3).reshape(-1):
            dCTT[1,i]=dot(dCp[j,i],pT[j]) + dCTT[1,i]
# ShearOnPlane.m:95
            dCTT[2,i]=dot(dCp[j,i],B[j]) + dCTT[2,i]
# ShearOnPlane.m:96
            dCTT[3,i]=dot(dCp[j,i],S[j]) + dCTT[3,i]
# ShearOnPlane.m:97
    
    #Trend and plunge of traction on plane
    TT[1,2],TT[1,3]=CartToSph(dCTT[1,1],dCTT[1,2],dCTT[1,3],nargout=2)
# ShearOnPlane.m:102
    #Trend and plunge of minimum shear direction
    TT[2,2],TT[2,3]=CartToSph(dCTT[2,1],dCTT[2,2],dCTT[2,3],nargout=2)
# ShearOnPlane.m:104
    #Trend and plunge of maximum shear direction
    TT[3,2],TT[3,3]=CartToSph(dCTT[3,1],dCTT[3,2],dCTT[3,3],nargout=2)
# ShearOnPlane.m:106
    return TT,dCTT,R
    
if __name__ == '__main__':
    pass
    