Transform
Transform operations: translate, rotate, scale, and mirror applied to a cone.
//! Transform operations: translate, rotate, scale, and mirror applied to a cone. use cadrum::Solid; use glam::DVec3; use std::f64::consts::PI; fn main() { let example_name = std::path::Path::new(file!()).file_stem().unwrap().to_str().unwrap(); let base = Solid::cone(8.0, 0.0, DVec3::Z, 20.0) .color("#888888"); let solids = [ // original — reference, no transform base.clone(), // translate — shift +20 along Z base.clone() .color("#4a90d9") .translate(DVec3::new(40.0, 0.0, 20.0)), // rotate — 90° around X axis so the cone tips toward Y base.clone() .color("#e67e22") .rotate_x(PI / 2.0) .translate(DVec3::new(80.0, 0.0, 0.0)), // scaled — 1.5x from its local origin base.clone() .color("#2ecc71") .scale(DVec3::ZERO, 1.5) .translate(DVec3::new(120.0, 0.0, 0.0)), // mirror — flip across Z=0 plane so the tip points down base.clone() .color("#e74c3c") .mirror(DVec3::ZERO, DVec3::Z) .translate(DVec3::new(160.0, 0.0, 0.0)), ]; let mut f = std::fs::File::create(format!("{example_name}.step")).expect("failed to create file"); cadrum::io::write_step(&solids, &mut f).expect("failed to write STEP"); let mut svg = std::fs::File::create(format!("{example_name}.svg")).expect("failed to create SVG file"); cadrum::io::write_svg(&solids, DVec3::new(1.0, 1.0, 1.0), 0.5, &mut svg).expect("failed to write SVG"); }
-
03_transform.svg