The Utah Teapot in Rust with Bézier Surfaces


While writing my crate for Isogeometric Analysis, I found myself in need of testing the Bézier implementation somehow. I thought it would be fun, as usual, to test with the mythical Utah Teaopt. I found the original dataset here. Actually, the entire teaset is provided, so I could test with all the models.

Loading Data

I loaded data by guessing the original format, I hope I did it properly. Two arrays are defined: the second array contains a list of vertices expressed in the 3D space, the first array contains indices describing bicubic Bézier surfaces, referencing the second array, with the index starting from 1 in row major order. So I wrote a procedure in my crate to load this data.

Representation with Gnuplot

The result was very simple to draw with the existing crate:

use isogeometric_analysis::bezier::BezierTeapot;
use isogeometric_analysis::core::RealRange;
use isogeometric_analysis::core::Evaluator;
let patches = BezierTeapot::build_patches();
for patch in patches {
    let r = RealRange { a: 0f64, b: 1f64 };
    let (_xpoints, ypoints) = Evaluator::<2, 3, 100>::evaluate_parametric_range2d(&patch, &r, &r);

The same can be done for the teaspoon and the teacup:

let patches = BezierTeacup::build_patches();
let patches = BezierTeaspoon::build_patches();

This is the result:

The plots were drawn using this crate with these commands:

cargo run -- --bezier-teapot
cargo run -- --bezier-teacup
cargo run -- --bezier-teaspoon

Have fun! Bye! 😉

Leave a Reply

Your email address will not be published. Required fields are marked *