Function truck_rendimpl::modeling::builder::rsweep [−][src]
pub fn rsweep<T>(
elem: &T,
origin: Point3<f64>,
axis: Vector3<f64>,
angle: Rad<f64>
) -> <T as MultiSweep<Point3<f64>, NURBSCurve<Vector4<f64>>, NURBSSurface<Vector4<f64>>>>::Swept where
T: ClosedSweep<Point3<f64>, NURBSCurve<Vector4<f64>>, NURBSSurface<Vector4<f64>>>,
Sweeps a vertex, an edge, a wire, a face, or a shell by the rotation.
Details
If the absolute value of angle
is more than 2π rad, then the result is closed shape.
For example, the result of sweeping a disk is a bent cylinder if angle
is less than 2π rad
and a solid torus if angle
is more than 2π rad.
Examples
// Torus use truck_modeling::*; const PI: Rad<f64> = Rad(std::f64::consts::PI); let v: Vertex = builder::vertex(Point3::new(3.0, 0.0, 0.0)); let circle: Wire = builder::rsweep(&v, Point3::new(2.0, 0.0, 0.0), Vector3::unit_z(), PI * 2.0); let torus: Shell = builder::rsweep(&circle, Point3::origin(), Vector3::unit_y(), PI * 2.0); let solid: Solid = Solid::new(vec![torus]);
// Modeling a pipe. use truck_modeling::*; const PI: Rad<f64> = Rad(std::f64::consts::PI); // Creates the base circle let v: Vertex = builder::vertex(Point3::new(1.0, 0.0, 4.0)); let circle: Wire = builder::rsweep(&v, Point3::new(2.0, 0.0, 4.0), -Vector3::unit_z(), PI * 2.0); // the result shell of the pipe. let mut pipe: Shell = Shell::new(); // Draw the first line pipe let mut first_line_part: Shell = builder::tsweep(&circle, Vector3::new(0.0, 0.0, -4.0)); pipe.append(&mut first_line_part); // Get the new wire let boundaries: Vec<Wire> = pipe.extract_boundaries(); let another_circle: Wire = boundaries.into_iter().find(|wire| wire != &circle).unwrap().inverse(); // Draw the bent part let mut bend_part: Shell = builder::rsweep( &another_circle, Point3::origin(), Vector3::unit_y(), PI / 2.0, ); pipe.append(&mut bend_part); // Get the new wire let boundaries: Vec<Wire> = pipe.extract_boundaries(); let another_circle: Wire = boundaries.into_iter().find(|wire| wire != &circle).unwrap().inverse(); // Draw the second line pipe let mut second_line_part: Shell = builder::tsweep(&another_circle, Vector3::new(-4.0, 0.0, 0.0)); pipe.append(&mut second_line_part); assert_eq!(pipe.shell_condition(), ShellCondition::Oriented);