/ 104intersection
104intersection
1 #!/usr/bin/env python3 2 3 from sys import argv, exit 4 5 from src.error_arg import check_error 6 from src.usage import display_usage 7 from src.intersection import ( 8 intersection_sphere, 9 intersection_cone, 10 intersection_cylinder, 11 ) 12 13 14 def check_option(av: list[str]) -> int: 15 if int(av[1]) == 1: 16 print(f"Sphere of radius {av[8]}") 17 print( 18 f"Line passing through the point ({av[2]}, {av[3]}, {av[4]}) and parallel to the vector ({av[5]}, {av[6]}, {av[7]})" 19 ) 20 intersection_sphere(av) 21 elif int(av[1]) == 2: 22 print(f"Cylinder of radius {av[8]}") 23 print( 24 f"Line passing through the point ({av[2]}, {av[3]}, {av[4]}) and parallel to the vector ({av[5]}, {av[6]}, {av[7]})" 25 ) 26 intersection_cylinder(av) 27 elif int(av[1]) == 3: 28 print(f"Cone with a {av[8]} degree angle") 29 print( 30 f"Line passing through the point ({av[2]}, {av[3]}, {av[4]}) and parallel to the vector ({av[5]}, {av[6]}, {av[7]})" 31 ) 32 intersection_cone(av) 33 else: 34 print("Error : option is unknown: retry with -h") 35 return 84 36 return 0 37 38 39 def main() -> int: 40 if "-h" in argv: 41 display_usage() 42 return 0 43 if check_error(argv) == 84: 44 return 84 45 return check_option(argv) 46 47 48 if __name__ == "__main__": 49 exit(main())