Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:46

0001 #!/usr/bin/env python
0002 
0003 import numpy as np
0004 
0005 X,Y,Z = 0,1,2 
0006 
0007 
0008 class XZ(object):
0009     """
0010 
0011             +------+
0012             |      |  nz     ->  ( X, Z )    nx_over_nz > 1 
0013             +------+
0014                nx
0015 
0016                Z  Y                    
0017                | /
0018                |/
0019                +----- X
0020               .
0021             -Y
0022 
0023     """
0024     up = np.array(  [0,0,1], dtype=np.float32 )
0025     off = np.array( [0,-1,0], dtype=np.float32 )
0026 
0027 
0028 class ZX(object):
0029     """
0030 
0031             +------+
0032             |      |  nx     ->  ( Z, X )    nx_over_nz < 1 
0033             +------+
0034                nz
0035 
0036                X  -Y                    
0037                | .
0038                |.
0039                +----- Z
0040               /
0041              Y
0042 
0043     HMM: X4IntersectSolidTest.py was using up (-1,0,0) ?
0044     """
0045     up = np.array(  [1,0,0], dtype=np.float32 )
0046     off = np.array( [0,1,0], dtype=np.float32 )
0047 
0048 
0049 class YZ(object):
0050     """
0051 
0052             +------+
0053             |      |  nz     ->  ( Y, Z )    ny_over_nz > 1 
0054             +------+
0055                ny
0056 
0057                Z                     
0058                |
0059                |
0060                +----- Y
0061               /
0062             X
0063 
0064     """
0065     up = np.array( [0,0,1], dtype=np.float32 )
0066     off = np.array( [1,0,0], dtype=np.float32 )
0067 
0068 
0069 class ZY(object):
0070     """
0071 
0072             +------+
0073             |      |  ny     ->  ( Z, Y )    ny_over_nz > 1 
0074             +------+
0075                nz
0076 
0077                Y  X                    
0078                | /
0079                |/
0080                +----- Z
0081               .
0082            - X
0083 
0084     """
0085     up = np.array( [0,1,0], dtype=np.float32 )
0086     off = np.array( [-1,0,0], dtype=np.float32 ) 
0087 
0088 
0089 
0090 class XY(object):
0091     """
0092 
0093             +------+
0094             |      |  ny     ->  ( X, Y )    nx_over_ny > 1 
0095             +------+
0096                nx
0097 
0098                Y  -Z                     
0099                | .
0100                |.
0101                +----- X
0102               /
0103              Z
0104 
0105     """
0106     up = np.array( [0,1,0], dtype=np.float32 )
0107     off = np.array( [0,0,1], dtype=np.float32 ) 
0108 
0109 
0110 class YX(object):
0111     """
0112 
0113             +------+
0114             |      |  nx     ->  ( Y, X )    nx_over_ny < 1 
0115             +------+
0116                ny
0117 
0118                X  -Z                     
0119                | .
0120                |.
0121          Y ----+. . .  -Y
0122               /
0123              Z
0124 
0125     """
0126     up = np.array( [1,0,0], dtype=np.float32 )
0127     off = np.array( [0,0,1], dtype=np.float32 ) 
0128 
0129 
0130 class XYZ(object):
0131     """
0132 
0133             Z  
0134             | 
0135             |
0136             +------ Y
0137            /
0138           /
0139          X
0140 
0141     """ 
0142     up = np.array( [0,0,1], dtype=np.float32 )
0143     off = np.array( [1,0,0], dtype=np.float32 )
0144 
0145 
0146 class Axes(object):
0147     ups = {}
0148     ups["XZ"] = XZ.up
0149     ups["ZX"] = ZX.up
0150 
0151     ups["YZ"] = YZ.up
0152     ups["ZY"] = ZY.up
0153 
0154     ups["XY"] = XY.up
0155     ups["YX"] = YX.up
0156 
0157     ups["XYZ"] = XYZ.up
0158 
0159     offs = {}
0160     offs["XZ"] = XZ.off
0161     offs["ZX"] = ZX.off
0162 
0163     offs["YZ"] = YZ.off
0164     offs["ZY"] = ZY.off
0165 
0166     offs["XY"] = XY.off
0167     offs["YX"] = YX.off
0168 
0169     offs["XYZ"] = XYZ.off
0170 
0171     @classmethod
0172     def OtherAxis(cls, axes):
0173         #assert len(axes) == 2
0174         if not X in axes: return X 
0175         if not Y in axes: return Y 
0176         if not Z in axes: return Z
0177         return -1 
0178 
0179     @classmethod
0180     def UnitVector(cls, axis, dtype=np.float32):
0181         if axis == X:
0182             v = np.array((1,0,0), dtype=dtype)
0183         elif axis == Y:
0184             v = np.array((0,1,0), dtype=dtype)
0185         elif axis == Z:
0186             v =  np.array((0,0,1), dtype=dtype)
0187         else:
0188             v = np.array( (0,0,0), dtype=dtype)
0189         return v
0190 
0191 
0192     @classmethod
0193     def HV_(cls, H, V, axes="XYZ"):
0194         return "%s%s" % (axes[H], axes[V] ) 
0195  
0196     @classmethod
0197     def Up(cls, H, V):
0198         HV = cls.HV_(H,V) 
0199         up = cls.ups.get(HV, None)
0200         return up 
0201 
0202     @classmethod
0203     def Off(cls, H, V):
0204         HV = cls.HV_(H,V) 
0205         off = cls.offs.get(HV, None)
0206         return off 
0207 
0208 
0209 
0210 if __name__ == '__main__':
0211     up = Axes.Up(0, 1)
0212 
0213 
0214 
0215