See the final folder for explanation as to why the following variables are locked for now.
7
8
9
axes & floor
10
polygons
23
.obj to desmos converter
11126
def parse_obj_file(filename): vertices = [] faces = [] try: with open(filename, 'r') as file: for line in file: if line.startswith('v '): # Line contains vertex data parts = line.strip().split() x = float(parts[1]) y = float(parts[2]) z = float(parts[3]) # Swap Z and Y vertices.append((x, z, y)) elif line.startswith('f '): # Line contains face data parts = line.strip().split() face = [int(p.split('/')[0]) - 1 for p in parts[1:]] faces.append(face) except FileNotFoundError: print(f"Error: File '{filename}' not found.") return None, None except Exception as e: print(f"Error: {e}") return None, None return vertices, faces def format_faces(vertices, faces): output = [] for face in faces: formatted_vertices = ', '.join( f"P({vertices[i][0]},{vertices[i][1]},{vertices[i][2]})" for i in face ) formatted_face = f"\\operatorname{{polygon}}\\left({formatted_vertices}\\right)" output.append(formatted_face) return "\n".join(output) # Join all faces with newline characters def main(): input_filename = r"C:\Users\Marv\Desktop\hause.obj" # Use raw string literal to handle backslashes vertices, faces = parse_obj_file(input_filename) if vertices is None or faces is None: return formatted_faces = format_faces(vertices, faces) print(formatted_faces) # Print all formatted faces at once, each on a new line if __name__ == "__main__": main()
11127
11128
powered by
powered by
New Blank Graph
Examples