A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, threaded by a bar carried along a path whose lead grows as it climbs, as a variable-pitch screw is cut.
The bar, as placed, is the box 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1: it points at the rod's axis, its flat tip 1 inside the rod, and it is 2 wide along the axis.
When it has turned by θ about the z axis, right-handed (from +x toward +y), it has risen 6s + 0.3s², s = θ/360°, rigidly. θ runs from −90° (risen −1.48125, the bar wholly below the rod) to 1260° (risen 24.675, wholly above it). Cut from the rod everything the bar passes through.
The lead grows from about 6 at the bottom to about 8 at the top: no screw carries the bar, and the groove's section is different at every height.
expected
closed form
volume
1324.478271
no closed form: OCCT and cadrs agree to 8e-10; the mean of their values
area
808.4376262
no closed form: OCCT and cadrs agree to 2e-10; the mean of their values
Drawing
TopIsometricFrontRight
Third-angle projection, the three views at one scale. Drawn from occt's result, which passed.
† works around a missing feature. Pick an entry to see its solid, its measures and its code.
Drag to turn, scroll or pinch to zoom, right-drag to move. The solid as its STEP file has it, meshed in the browser by Open CASCADE (occt-import-js): each face colored by the kind of its surface, and the edges that bound each face drawn between them.
Drag to turn, scroll or pinch to zoom, right-drag to move. Black lines are where the surface turns sharply; red ones, seen through the solid, are open edges, where the mesh is not closed.
Time
8.65 s; CPU time 26.3 s; peak memory 55.7 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1324.478271
1324.478271
5.8e-11
area
808.437626
808.4376262
1.9e-10
agrees with
occt, next.BREP, cadrs, springrep
mesh
82858 triangles, closed
centre of gravity
(0.0192327, 0.00138344, 10.0526) its STEP's solid
inertia
about it, of unit density: Ixx 51356.3; Iyy 51383; Izz 14518.9; Ixy -4.32807; Iyz -816.914; Izx -235.045
//! A rod, the cylinder of radius 5 about z from z = 0 to 20, threaded by the bar 4 ≤ x ≤ 12,//! −8 ≤ y ≤ 8, −1 ≤ z ≤ 1 carried so that, turned by θ about z (right-handed), it has risen//! 6s + 0.3s², s = θ/360°, θ from −90° to 1260°: a lead growing from about 6 to about 8.//!//! A screw whose lead grows is no constant twist, so `swept::closed::cut_from` takes the contact's//! road under any motion (`swept::general`): each face's contact a chord where its normal is square//! to the motion's velocity, walls between them, trimmed by membership and cut from the rod.usecrate::sketch::block;
use cad_kernel::build::{disc, prism};
use cad_kernel::geom::tolerance;
use cad_kernel::swept::closed::cut_from;
use cad_kernel::topo::Brep;
use cad_kernel::trajectory::{Pace, Screw, Trajectory};
use cad_kernel::util::interval::{ErrorasIntervalError, Interval};
use cad_kernel::KernelError;
use std::f64::consts::TAU;
use std::sync::Arc;
constROD_RADIUS: f64 = 5.;
constROD_LENGTH: f64 = 20.;
/// The rise's terms: `LEAD·s + GROWTH·s²` after `s` turns.constLEAD: f64 = 6.;
constGROWTH: f64 = 0.3;
constROLL: [f64; 2] = [-90f64.to_radians(), 1260f64.to_radians()];
/// How far the bar has risen when it has turned by θ: `LEAD·s + GROWTH·s²`, `s = θ/τ`, and its/// rate by θ.#[derive(Debug)]structRise;
implRise {
fnof(s: f64) -> f64 { LEAD * s + GROWTH * s * s }
}
implPaceforRise {
fnjet(&self, theta: f64) -> Result<[f64; 2], KernelError> {
let s = theta / TAU;
Ok([Rise::of(s), (LEAD + 2. * GROWTH * s) / TAU])
}
/// The parabola's least and greatest over the stretch: at its ends, or at its vertex where the/// stretch holds it.fnrange(&self, [a, b]: [f64; 2]) -> Result<[f64; 2], KernelError> {
let (s0, s1) = (a.min(b) / TAU, a.max(b) / TAU);
let vertex = -LEAD / (2. * GROWTH);
letmut values = vec![Rise::of(s0), Rise::of(s1)];
if s0 < vertex && vertex < s1 { values.push(Rise::of(vertex)); }
Ok([values.iter().cloned().fold(f64::INFINITY, f64::min),
values.iter().cloned().fold(f64::NEG_INFINITY, f64::max)])
}
/// The rise and its rate over a stretch of θ, in interval arithmetic: `s·(LEAD + GROWTH·s)` and/// `(LEAD + 2·GROWTH·s)/τ`, `s = θ/τ` (what the sweep's candidates' zones are read by).fnenclose(&self, roll: Interval) -> Result<[Interval; 2], IntervalError> {
let k = |x: f64| Interval::point(x);
let s = roll.div(k(TAU)?)?;
let rise = s.mul(k(LEAD)?.add(k(GROWTH)?.mul(s)?)?)?;
let rate = k(LEAD)?.add(k(2. * GROWTH)?.mul(s)?)?.div(k(TAU)?)?;
Ok([rise, rate])
}
}
pubfnbuild() -> Result<Brep, String> {
let up = [0., 0., 1.];
let rod = prism(&disc([0., 0., 0.], up, ROD_RADIUS), 0., ROD_LENGTH)?;
let bar = block([4., -8., -1.], [12., 8., 1.])?;
// as a lathe cuts it: the tool slides up z at the growing rise (a slide rising a unit a unit// of its own parameter, taken at the rise's pace), seen from the rod, which turns by −θ under// it (`Relative`: the source's pose, then the observer's undone, so the bar turns by θ)let rise = Trajectory::Twist(Screw { origin: [0., 0., 0.], axis: up, ratio: 0., advance: TAU });
let tool = Trajectory::Paced { path: Box::new(rise), pace: Arc::new(Rise) };
let spindle = Trajectory::Twist(Screw {
origin: [0., 0., 0.], axis: up, ratio: -1., advance: 0.,
});
let path = Trajectory::Relative { source: Box::new(tool), observer: Box::new(spindle) };
// no constant twist and no path of slides and turns: the kernel's road for any other rigid// motion (K2)let size = rod.size().max(bar.size());
cut_from(&rod, &bar, &path, ROLL, bar.size(), tolerance(size))
.map_err(|why| format!("the bar's sweep not built: {why:?}"))
}
Time
1.84 s; CPU time 1.84 s; peak memory 385.5 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † no sweep of a solid
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1324.478271
1324.478271
5.5e-11
area
808.4376261
808.4376262
1.0e-10
agrees with
cad-kernel, next.BREP, cadrs, springrep
mesh
49984 triangles, closed
centre of gravity
(0.0192327, 0.00138345, 10.0526) its STEP's solid
inertia
about it, of unit density: Ixx 51356.3; Iyy 51383; Izz 14518.9; Ixy -4.32807; Iyz -816.914; Izx -235.045
"""A rod threaded at a lead that grows along it. A rod, the cylinder of radius 5 about the z axis
from z = 0 to z = 20, threaded by a bar carried along a path whose lead grows as it climbs, as a
variable-pitch screw is cut.
The bar, as placed, is the box 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1: it points at the rod's axis, its
flat tip 1 inside the rod, and it is 2 wide along the axis.
When it has turned by θ about the z axis, right-handed (from +x toward +y), it has risen 6s +
0.3s², s = θ/360°, rigidly. θ runs from −90° (risen −1.48125, the bar wholly below the rod) to
1260° (risen 24.675, wholly above it). Cut from the rod everything the bar passes through.
The lead grows from about 6 at the bottom to about 8 at the top: no screw carries the bar, and the
groove's section is different at every height."""fromOCP.BRepAlgoAPIimportBRepAlgoAPI_CommonfromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBox, BRepPrimAPI_MakeCylinderfromOCP.gp import gp, gp_Ax2, gp_Pnt
from bench importRefusedfrom sweep import cut, flat_contacts_screwed, moved, threaded, threaded_motion
ROD_RADIUS, ROD_LENGTH = 5, 20BAR = ((4, -8, -1), (12, 8, 1))
LEAD, GROWTH = 6, 0.3# it rises 6s + 0.3s² at s whole turnsSTART, STOP = -90, 1260# degrees# The motion turns about the rod's axis and rises along it, keeping every point's distance from# it, so only the part of the bar within the rod's radius ever enters the rod; the bar is cut# down to the part within this.REACH = 6defbuild():
bar = BRepPrimAPI_MakeBox(gp_Pnt(*BAR[0]), gp_Pnt(*BAR[1])).Shape()
within = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, -10), gp.DZ_s()), REACH, 20).Shape()
near = BRepAlgoAPI_Common(bar, within)
ifnot near.IsDone():
raiseRefused("BRepAlgoAPI_Common declined the bar's part near the rod")
tool = moved(near.Shape(), threaded_motion(LEAD, GROWTH, 0, START))
# A point p moves with velocity ẑ × p + kẑ, k the rise per radian, which grows. The tip's# normal is level, so it meets the motion square-on where it meets the turn, along its# middle, through the axis, whatever k; the level faces rise all the while (k > 0 from the# start) or sink, and lead or trail all over. So the same faces lead all the way.# Every circle about the axis meets the bar, cut down to within REACH of it, in one arc, so# no point is entered twice in a pass, and the leading faces of each span are swept whole.
pieces = threaded(tool, LEAD, START, STOP, flat_contacts_screwed(tool, LEAD), growth=GROWTH,
whole=True)
rod = BRepPrimAPI_MakeCylinder(gp.XOY_s(), ROD_RADIUS, ROD_LENGTH).Shape()
returncut(rod, pieces)
arris left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
1.52 s; CPU time 2.25 s; peak memory 251 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1324.478016
1324.478271
1.9e-07
area
808.4373914
808.4376262
2.9e-07
agrees with
no other kernel
mesh
45992 triangles, closed
centre of gravity
(0.0192331, 0.00138343, 10.0526) its STEP's solid
inertia
about it, of unit density: Ixx 51356.3; Iyy 51383; Izz 14518.9; Ixy -4.32805; Iyz -816.915; Izx -235.045
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to 20, threaded by the bar//! 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1 turned by θ about the z axis while rising 6s + 0.3s²,//! s = θ/360°, for θ from −90° to 1260°.//!//! The motion is given by its places (`sweep::RigidMotion::Carried`); the bar's sweep is//! kentron's sweep of a solid (`sweep::solid`), cut from the rod.usecrate::bench::{d, frame, p, v};
use kentron::math::{Axis, Direction, Transform};
use kentron::primitives::{Cuboid, Cylinder};
use kentron::sweep::{self, Carriage, RigidMotion};
use kentron::topology::{Model, Shape};
use std::f64::consts::TAU;
use std::sync::Arc;
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let rod = Cylinder::new(5.0, 20.0).build(m)?;
let bar = Cuboid::new(8.0, 16.0, 2.0).with_frame(frame(p(4.0, -8.0, -1.0), d(0.0, 0.0, 1.0))).build(m)?;
let (from, to) = ((-90f64).to_radians(), 1260f64.to_radians());
let place = move |t: f64| {
let theta = from + (to - from) * t;
let s = theta / TAU;
Transform::translation(v(0.0, 0.0, 6.0 * s + 0.3 * s * s)) * Transform::rotation(Axis::new(p(0.0, 0.0, 0.0), Direction::Z), theta)
};
let swept = sweep::solid(m, bar, &RigidMotion::Carried(Carriage(Arc::new(place))))?;
kentron::boolean::difference(m, rod, swept)
}
vcad left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
solidcraft left no solid to show.
Time
1.5 ms; CPU time 1.3 ms; peak memory 4.6 MB
Notes
refused no layer (solidcraft-kernel, solidcore-ops, solidcore) has a sweep of a solid or a sweep along a path of growing lead: every layer's helical sweep rises a constant pitch (`sweep_helix_radial` only moves the section off the axis), and its path sweeps take lines, arcs and splines, none of which is the path that has risen 6s + 0.3s² after s turns
//! Refused. The bar has risen 6s + 0.3s² when it has turned s whole turns, so no screw carries it,//! and the groove's section changes at every height. The helical sweeps of all three layers//! (solidcraft-kernel's `sweep_helix`, solidcore-ops' `screw_sweep` and solidcore's screw sweep//! beneath them) rise a constant pitch, and their radial laws (`sweep_helix_radial`) only move the//! section off the axis as it turns; the path sweeps follow lines, arcs and Bézier or spline//! curves, none of which is that path exactly, with frames that follow the path rather than the//! turn. With no sweep of a solid either, nothing carries even a face of the bar along this motion.usecrate::Refusal;
usecrate::solids::Body;
pubfnbuild() -> Result<Body, Refusal> {
Err("no layer (solidcraft-kernel, solidcore-ops, solidcore) has a sweep of a solid or a sweep along a path of growing lead: \
every layer's helical sweep rises a constant pitch (`sweep_helix_radial` only moves the section \
off the axis), and its path sweeps take lines, arcs and splines, none of which is the \
path that has risen 6s + 0.3s² after s turns"
.into())
}
brepkit left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
popkern left no solid to show.
Time
3.2 ms; CPU time 3 ms; peak memory 11.3 MB
Notes
refused popkern has no sweep of a solid, and this motion's envelope is not one its extrudes, revolves and booleans make exactly
// A rod threaded at a lead that grows along it.//// Refused: popkern has no sweep of a solid (its sweeps carry a profile along a path), and the// envelope this motion leaves is not one its extrudes, revolves and booleans make exactly: the// tool is not symmetric about the planes of its motion, or the motion is a screw or a curve.throw"popkern has no sweep of a solid, and this motion's envelope is not one its extrudes, revolves and booleans make exactly";
aetheris left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
416 ms; CPU time 416 ms; peak memory 98.9 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1324.478271
1324.478271
7.6e-11
area
808.4376262
808.4376262
5.2e-11
agrees with
cad-kernel, occt, cadrs, springrep
mesh
62580 triangles, closed
centre of gravity
(0.0192327, 0.00138344, 10.0526) its STEP's solid
inertia
about it, of unit density: Ixx 51356.3; Iyy 51383; Izz 14518.9; Ixy -4.32807; Iyz -816.914; Izx -235.045
//! A rod threaded by a bar along a path whose lead grows as it climbs.//!//! Through the kernel's sweep of a solid along a turn whose rise grows (`sweep_solid_rising`): the//! bar, the box 4 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 1, as a convex polyhedron; turned by θ about the z axis//! it has risen 6s + 0.3s², s = θ/2π, so the rise is (6/2π)θ + (0.3/4π²)θ², for θ from −90° to//! 1260°; asked for within 5 of the z axis (the rod, which the turn maps onto itself, so the kernel//! may sweep only the bar's part that reaches it); cut from the rod.usecrate::solids::p;
usecrate::Refusal;
use brep_kernel::{
boolean_operation_nary, make_cylinder_brep, sweep_solid_rising, BooleanOperation, BrepSolid, RisingTurn, SolidTool,
SweepClip,
};
use std::f64::consts::TAU;
pubfnbuild() -> Result<BrepSolid, Refusal> {
let rod = make_cylinder_brep(p(0.0, 0.0, 0.0), p(0.0, 0.0, 1.0), 5.0, 20.0)?;
let bar = SolidTool::Polyhedron {
vertices: (0..8)
.map(|i| p(if i & 1 != 0 { 12.0 } else { 4.0 }, if i & 2 != 0 { 8.0 } else { -8.0 }, if i & 4 != 0 { 1.0 } else { -1.0 }))
.collect(),
faces: vec![vec![0, 2, 3, 1], vec![4, 5, 7, 6], vec![0, 1, 5, 4], vec![2, 6, 7, 3], vec![0, 4, 6, 2], vec![1, 3, 7, 5]],
};
let motion = RisingTurn {
axis_origin: p(0.0, 0.0, 0.0),
axis_direction: p(0.0, 0.0, 1.0),
rise: [6.0 / TAU, 0.3 / (TAU * TAU)],
from: (-90f64).to_radians(),
to: 1260f64.to_radians(),
};
let rod_region = SweepClip {
axis_origin: p(0.0, 0.0, 0.0),
axis_direction: p(0.0, 0.0, 1.0),
reference: p(1.0, 0.0, 0.0),
radius: [0.0, 5.0],
axial: [-0.4, 20.4],
angle: None,
};
let swept = sweep_solid_rising(&bar, &motion, &rod_region)?;
Ok(boolean_operation_nary(&[rod, swept], BooleanOperation::Subtract)?)
}
geop left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
247 ms; CPU time 548 ms; peak memory 15.9 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1324.478267
1324.478271
3.0e-09
area
808.4376261
808.4376262
1.4e-10
agrees with
cad-kernel, occt, next.BREP, springrep
mesh
49618 triangles, closed
centre of gravity
(0.0192327, 0.00138344, 10.0526) its STEP's solid
inertia
about it, of unit density: Ixx 51356.3; Iyy 51383; Izz 14518.9; Ixy -4.32805; Iyz -816.914; Izx -235.045
//! A rod (the cylinder of radius 5 about the z axis from z = 0 to z = 20) threaded by a bar (the box//! 4 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 1) turned by θ about the z axis while rising 6s + 0.3s², s = θ/360°,//! as θ runs from −90° to 1260°.//!//! That motion is cadrs's climb (a turn about the axis rising by a polynomial in the turn: here//! 6θ/2π + 0.3θ²/4π², θ in radians); what the bar passes through is cut from the rod by cadrs's//! cut by a swept solid (half a turn at a time, the rod less the bar where each half starts and//! less its leading faces' sweeps); of the bar, its part within 5.5 of the axis (the motion's//! turns and rises map the cylinder about the axis onto itself).usecrate::bench::{block, p3};
usecrate::shared::swept::{cut_swept, near_axis, rod, z_axis};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel, SolidMotion};
use std::f64::consts::PI;
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let bar = block(k, p3(4.0, -8.0, -1.0), p3(12.0, 8.0, 1.0))?;
let bar = near_axis(k, bar, 5.5)?;
let r = rod(k)?;
let motion = SolidMotion::Climb {
axis: z_axis(),
from: (-90f64).to_radians(),
to: 1260f64.to_radians(),
rise: vec![0.0, 6.0 / (2.0 * PI), 0.3 / (4.0 * PI * PI)],
};
cut_swept(k, r, bar, &motion)
}
smlib left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
1.70 s; CPU time 1.70 s; peak memory 74.6 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † no sweep of a whole tool: the tool is cut to the rod's reach before the sweep
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1324.478271
1324.478271
5.2e-12
area
808.437626
808.4376262
2.3e-10
agrees with
cad-kernel, occt, next.BREP, cadrs
mesh
48604 triangles, closed
centre of gravity
(0.0192327, 0.00138345, 10.0526) its STEP's solid
inertia
about it, of unit density: Ixx 51356.3; Iyy 51383; Izz 14518.9; Ixy -4.32807; Iyz -816.914; Izx -235.045
//! The rod of radius 5 about the z axis from z = 0 to 20 less everything the bar 4 ≤ x ≤ 12, |y|//! ≤ 8, |z| ≤ 1 passes through as it turns by θ about the z axis while rising 6s + 0.3s², s =//! θ/360°.use springrep::boolean::difference;
use springrep::geom::{BSpline, Curve};
use springrep::math::Vec3;
use springrep::sweep::{Motion, solid};
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{boxed, deg, rod, turning, v3, within};
pubfnbuild() -> Result<Brep, String> {
// Turned by θ = −90° + 1350°τ it has risen h = 6s + 0.3s², s = θ/360°: the quadratic Bézier// through h(0) and h(1) whose middle point is h(0) + h′(0)/2.let h = |s: f64| 6.0 * s + 0.3 * s * s;
let (s0, s1) = (-0.25, 3.5);
let slope = (6.0 + 0.6 * s0) * (s1 - s0);
let ctrl = vec![
v3(0.0, 0.0, h(s0)),
v3(0.0, 0.0, h(s0) + slope / 2.0),
v3(0.0, 0.0, h(s1)),
];
let knots = vec![0.0, 0.0, 0.0, 1.0, 1.0, 1.0];
let rise = Curve::BSpline(BSpline::new(2, knots, ctrl).map_err(e)?);
let bar = boxed([4.0, -8.0, -1.0 + h(s0)], [12.0, 8.0, 1.0 + h(s0)], "bar")?;
// No sweep of the whole tool: a screw keeps each point's distance from the z axis, so only the// tool within 5.5 of it reaches the rod, and only that part is swept.let tip = within(&bar, 5.5)?;
let motion = Motion::Then(
Box::new(turning(deg(-90.0), deg(1260.0))),
Box::new(Motion::Along {
path: rise,
range: (0.0, 1.0),
up: Vec3::X,
}),
);
let swept = solid(&tip, &motion, "thread").map_err(e)?;
difference(&rod()?, &swept).map_err(e)
}
geomsolver left no solid to show.
Time
154 ms; CPU time 155 ms; peak memory 26.2 MB
Notes
refused error[E080]: `thread` is outside the generating-sweep class (M1: the motion is rotations about fixed axes at constant ratios, or one screw, turn or slide (a joint driven by a law alone read as its joint over the values the law reaches)): temporal contacts are read of constant rates, and a frame the drawing moves turns as the drawing does (#398)
// A rod threaded by a square bar at a lead that grows as it climbs. The rod is the cylinder of// radius 5 about z from z = 0 to 20. The bar is the box 4 <= x <= 12, -8 <= y <= 8, -1 <= z <= 1// as placed: its section in a plane through the rod's axis and the prism over it 8 either side.// No screw carries it, so the motion is a frame the drawing moves: with one parameter t, the// frame `carrier` stands turned t about z and risen 6 s + 0.3 s^2 (s = t / 360 degrees), and the// kernel's sweep of the bar under it as t runs from -90 to 1260 degrees is cut from the rod. Such// a frame carries what is drawn from where it stands as drawn, at the parameter's first value, so// the bar is drawn where it starts.unit mm
use std
use std.solids (cut)
use std.place (coords)
param t: Angleover (-90deg, 1260deg)
in std.top {
private o := point
fix((0, 0)) o
private rim := circle(center: o) hint(r: 5)
radius(5mm) rim
}
part := solid(std.solids.Prism(face(rim), from: 0mm, to: 20mm))
// the bar drawn where it starts, t = -90deg: turned -90deg about z, its middle risen// 6 s + 0.3 s^2 at s = -1/4private start_u := axis
fix(dir == (0, -1, 0)) start_u
private start_v := axis
fix(dir == (0, 0, 1)) start_v
holder := plane(u: start_u, v: start_v)
fix(origin == (0, 0, -6 / 4 + 0.3 / 16)) holder
in holder {
private b0 := point
private b1 := point
private b2 := point
private b3 := point
b0 coords(du: 4mm, dv: -1mm) holder
b1 coords(du: 12mm, dv: -1mm) holder
b2 coords(du: 12mm, dv: 1mm) holder
b3 coords(du: 4mm, dv: 1mm) holder
private lower := line(b0, b1)
private end := line(b1, b2)
private upper := line(b2, b3)
private nose := line(b3, b0)
}
construction bar := solid(std.solids.Prism(face(lower, end, upper, nose), from: -8mm, to: 8mm))
// the frame the bar is carried by: turned t about z and risen 6 s + 0.3 s^2
carrier := frame
carrier.v parallel(sense: same) std.z
carrier.u perpendicular std.z
std.x angle(t, about: std.z) carrier.u
carrier.origin coincident std.z
carrier.origin distance(6mm * t / 360deg + 0.3mm * (t / 360deg)^2, along: n) std.top
construction thread := solid({ p | some t: p in bar at(under: carrier) t })
thread cut part
anvilcad left no solid to show.
Time
1.2 ms; CPU time 970 µs; peak memory 3.5 MB
Notes
refused anvil-brep has no sweep of a solid and no helical curve: a body screwed along an axis sweeps envelopes of its surfaces under the screw, which it cannot make from its profile sweeps
//! A rod threaded at a lead that grows along it.use anvil_brep::Solid;
pubfnbuild() -> Result<Solid, String> {
Err("anvil-brep has no sweep of a solid and no helical curve: a body screwed along an axis sweeps envelopes of its surfaces under the screw, which it cannot make from its profile sweeps".into())
}