Add testdrive test-3drot.py
This commit is contained in:
		
							parent
							
								
									f598670da8
								
							
						
					
					
						commit
						996839a490
					
				
					 2 changed files with 79 additions and 4 deletions
				
			
		
							
								
								
									
										72
									
								
								test/test-3drot.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										72
									
								
								test/test-3drot.py
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,72 @@ | |||
| #!/usr/bin/env python3 | ||||
| 
 | ||||
| import logging | ||||
| import math | ||||
| import sys | ||||
| 
 | ||||
| try: | ||||
|     import importlib.machinery | ||||
|     danmaku2ass = importlib.machinery.SourceFileLoader('danmaku2ass', '../danmaku2ass.py').load_module('danmaku2ass') | ||||
| except (AttributeError, ImportError): | ||||
|     import imp | ||||
|     danmaku2ass = imp.load_source('danmaku2ass', '../danmaku2ass..py') | ||||
| 
 | ||||
| extcode = 0 | ||||
| 
 | ||||
| def main(): | ||||
|     logging.basicConfig(level=logging.INFO) | ||||
|     for rotY in range(0, 361): | ||||
|         for rotZ in range(0, 361): | ||||
|             outX, outY, outZ, shearX, shearY = danmaku2ass.ConvertFlashRotation(rotY, rotZ, X=0, Y=0, FOV=None) | ||||
|             logging.info('%4d, %4d => %4d, %4d, %4d' % (rotY, rotZ, outX, outY, outZ)) | ||||
|             CompareMatrix(rotY, rotZ, outX, outY, outZ) | ||||
| 
 | ||||
| def CompareMatrix(rotY, rotZ, outX, outY, outZ): | ||||
|     def ApproxEqual(a, b, e=0.01): | ||||
|         assert e >= 0 | ||||
|         a_b = a-b | ||||
|         if -e < a_b < e: | ||||
|             return 0 | ||||
|         else: | ||||
|             return a_b | ||||
|     def FormatError(i, j, l, r): | ||||
|         global extcode | ||||
|         if ApproxEqual(l, r) != 0: | ||||
|             extcode = 1 | ||||
|             logging.error('l[%s][%s]=%9.6f      r[%s][%s]=%9.6f' % (i, j, l, i, j, r)) | ||||
|     def sind(x): | ||||
|         return math.sin(x*math.pi/180.0) | ||||
|     def cosd(x): | ||||
|         return math.cos(x*math.pi/180.0) | ||||
| 
 | ||||
|     l = cosd(rotY)*cosd(rotZ) | ||||
|     r = -sind(outX)*sind(outY)*sind(outZ)+cosd(outY)*cosd(outZ) | ||||
|     FormatError(0, 0, l, r) | ||||
|     l = cosd(rotY)*sind(rotZ) | ||||
|     r = -cosd(outX)*sind(outZ) | ||||
|     FormatError(0, 1, l, r) | ||||
|     l = sind(rotY) | ||||
|     r = -sind(outX)*cosd(outY)*sind(outZ)-sind(outY)*cosd(outZ) | ||||
|     FormatError(0, 2, l, r) | ||||
|     l = -sind(rotZ) | ||||
|     r = sind(outX)*sind(outY)*cosd(outZ)+cosd(outY)*sind(outZ) | ||||
|     FormatError(1, 0, l, r) | ||||
|     l = cosd(rotZ) | ||||
|     r = cosd(outX)*cosd(outZ) | ||||
|     FormatError(1, 1, l, r) | ||||
|     l = 0 | ||||
|     r = sind(outX)*cosd(outY)*cosd(outZ)-sind(outY)*sind(outZ) | ||||
|     FormatError(1, 2, l, r) | ||||
|     l = -sind(rotY)*cosd(rotZ) | ||||
|     r = cosd(outX)*sind(outY) | ||||
|     FormatError(2, 0, l, r) | ||||
|     l = -sind(rotY)*sind(rotZ) | ||||
|     r = -sind(outX) | ||||
|     FormatError(2, 1, l, r) | ||||
|     l = cosd(rotY) | ||||
|     r = cosd(outX)*cosd(outY) | ||||
|     FormatError(2, 2, l, r) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     main() | ||||
|     sys.exit(extcode) | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Star Brilliant
						Star Brilliant