File size: 1,576 Bytes
aa6f176 8ccdb9f 374023a aa6f176 374023a d12da82 a3a9900 2542f69 aa6f176 374023a aa6f176 374023a aa6f176 a1e213e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 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() |