Function truck_modeling::builder::rsweep [−][src]
pub fn rsweep<T: ClosedSweep<Point3, Curve, Surface>, R: Into<Rad<f64>>>(
elem: &T,
origin: Point3,
axis: Vector3,
angle: R
) -> T::Swept
Expand description
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.
Remarks
axis
must be normalized. If not, panics occurs in debug mode.
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);