import gradio as gr def process_points(x1, y1, z1, x2, y2, z2, x3, y3, z3): # Extract coordinates from input points # Format output string output = f"""A({x1}, {y1}, {z1})\nB({x2}, {y2}, {z2})\nC({x3}, {y3}, {z3})\n""" output += f""" |x-{x1} y-{y1} z-{z1}| |{x2}-{x1} {y2}-{y1} {z2}-{z1}| |{x3}-{x1} {y3}-{y1} {z3}-{z1}|\n """ output += f""" |x-{x1} y-{y1} z-{z1}| |{x2-x1} {y2-y1} {z2-z1}| |{x3-x1} {y3-y1} {z3-z1}|\n """ output += f"""(x - {x1})[({y2-y1}, {z2-z1}),({y3-y1}, {z3-z1})] - - (y - {y1})[({x2 - x1}, {z2-z1}),({x3-x1}, {z3 - z1})] + + (z - {z1})[({x2 - x1}, {y3 - y1}),({y2 - y1}, {x3 - x1})]\n""" output += f"""(x - {x1})({(y2 -y1)*(z3-z1) - (z2 - z1)*(y3 - y1)}) - (y - {y1})({(x2 - x1)*(z3 - z1) - (z2 - z1)*(x3 - x1)}) + (z - {z1})({(x2 - x1)*(y3 - y1) - (x3 - x1)*(y2 - y1)}) """ return output # Define Gradio interface demo = gr.Interface( fn=process_points, inputs=[ gr.Number(label="Point 1 (x, y, z)"), gr.Number(label="Point 1 (x, y, z)"), gr.Number(label="Point 1 (x, y, z)"), gr.Number(label="Point 2 (x, y, z)"), gr.Number(label="Point 2 (x, y, z)"), gr.Number(label="Point 2 (x, y, z)"), gr.Number(label="Point 3 (x, y, z)"), gr.Number(label="Point 3 (x, y, z)"), gr.Number(label="Point 3 (x, y, z)"), ], outputs=gr.Textbox(label="Output"), title="3D Point Formatter", description="Enter three points with three coordinates each (x, y, z).", ) # Launch Gradio app if __name__ == "__main__": demo.launch()