The solid a regular tetrahedron fills as it is carried along a screw.
The tetrahedron's corners are (5, 1, 1), (5, −1, −1), (3, 1, −1) and (3, −1, 1): the regular tetrahedron of edge 2√2 inscribed in the cube from (3, −1, −1) to (5, 1, 1).
The screw is about the z axis: the tetrahedron turns right-handed about it (from +x toward +y) and rises 5 for every whole turn, rigidly, from a turn of 0° to one of 540°. Make the solid of everything the tetrahedron passes through.
Its silhouette under the screw turns at its corners, so the swept solid's walls are sheets swept by its edges, joined where the corners' helices run, and the turns of the screw stay apart (it rises 5 a turn and is 2 tall).
expected
closed form
volume
153.463114
no closed form: cad-kernel, OCCT and cadrs agree to 2e-10; the mean of their values
area
324.9050839
no closed form: cad-kernel, OCCT and cadrs agree to 7e-11; 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
2.11 s; CPU time 7.28 s; peak memory 42.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
153.4631148
153.463114
4.7e-09
area
324.9050842
324.9050839
9.8e-10
agrees with
occt, kentron, next.BREP, cadrs, springrep
mesh
28152 triangles, closed
centre of gravity
(1.31895e-09, 0.837625, 3.75) its STEP's solid
inertia
about it, of unit density: Ixx 1954.92; Iyy 2105.26; Izz 2469.87; Ixy 2.64014e-07; Iyz -6.10937e-07; Izx 143.893
//! The solid a regular tetrahedron fills screwed about the z axis — right-handed, rising 5 a turn//! — from a turn of 0° to 540°: the tetrahedron on (5, 1, 1), (5, −1, −1), (3, 1, −1), (3, −1, 1).use cad_kernel::build::hull;
use cad_kernel::geom::{tolerance, V};
use cad_kernel::swept::closed::closed;
use cad_kernel::topo::Brep;
use cad_kernel::trajectory::{Screw, Trajectory};
constCORNERS: [V; 4] = [[5., 1., 1.], [5., -1., -1.], [3., 1., -1.], [3., -1., 1.]];
constLEAD: f64 = 5.;
constTURN: f64 = 540f64.to_radians();
pubfnbuild() -> Result<Brep, String> {
// the tetrahedron: its corners' convex hulllet tool = hull(&CORNERS)?;
// the screw about z: a radian a radian of the roll, rising the lead a turnlet path = Trajectory::Twist(Screw {
origin: [0., 0., 0.], axis: [0., 0., 1.], ratio: 1., advance: LEAD,
});
// the kernel's closed swept solid: a polyhedral tool whose edges lean to the screw's axis,// each screwed into a patch of the ruled helicoid (its flat faces mesh exactly, at any bar)closed(&tool, &path, [0., TURN], tool.size(), tolerance(tool.size()))
.map_err(|why| format!("the tetrahedron's sweep not built: {why:?}"))
}
Time
2.92 s; CPU time 2.92 s; peak memory 412.7 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
153.463114
153.463114
5.1e-11
area
324.9050839
324.9050839
3.4e-11
agrees with
cad-kernel, kentron, next.BREP, cadrs, springrep
mesh
39448 triangles, closed
centre of gravity
(1.05478e-13, 0.837625, 3.75) its STEP's solid
inertia
about it, of unit density: Ixx 1954.92; Iyy 2105.26; Izz 2469.87; Ixy 4.7841e-11; Iyz 4.62932e-12; Izx 143.893
"""A regular tetrahedron carried along a screw. The solid a regular tetrahedron fills as it is
carried along a screw.
The tetrahedron's corners are (5, 1, 1), (5, −1, −1), (3, 1, −1) and (3, −1, 1): the regular
tetrahedron of edge 2√2 inscribed in the cube from (3, −1, −1) to (5, 1, 1).
The screw is about the z axis: the tetrahedron turns right-handed about it (from +x toward +y) and
rises 5 for every whole turn, rigidly, from a turn of 0° to one of 540°. Make the solid of
everything the tetrahedron passes through.
Its silhouette under the screw turns at its corners, so the swept solid's walls are sheets swept by
its edges, joined where the corners' helices run, and the turns of the screw stay apart (it rises 5
a turn and is 2 tall)."""fromOCP.BRepBuilderAPIimport (BRepBuilderAPI_MakeFace, BRepBuilderAPI_MakePolygon,
BRepBuilderAPI_MakeSolid, BRepBuilderAPI_Sewing)
fromOCP.BRepLibimportBRepLibfromOCP.TopAbsimportTopAbs_SHELLfromOCP.TopoDSimportTopoDSfromOCP.gp import gp_Pnt
from bench importRefusedfrom sweep import flat_contacts_screwed, found, screwed, united
CORNERS = [(5, 1, 1), (5, -1, -1), (3, 1, -1), (3, -1, 1)]
LEAD = 5# rise per whole turnSTART, STOP = 0, 540# degreesdeftetrahedron():
"""The four triangles between the corners, sewn into a solid."""
sewing = BRepBuilderAPI_Sewing(1e-7)
for i inrange(4):
corners = [gp_Pnt(*c) for j, c inenumerate(CORNERS) if j != i]
polygon = BRepBuilderAPI_MakePolygon(*corners, True)
sewing.Add(BRepBuilderAPI_MakeFace(polygon.Wire()).Face())
sewing.Perform()
solid = BRepBuilderAPI_MakeSolid(TopoDS.Shell(found(sewing.SewedShape(), TopAbs_SHELL)[0]))
ifnot solid.IsDone():
raiseRefused("BRepBuilderAPI_MakeSolid declined the tetrahedron's sewn faces")
solid = solid.Solid()
BRepLib.OrientClosedSolid_s(solid)
return solid
defbuild():
tool = tetrahedron()
# Each face is cut along its contact with the screw, a line parallel to the axis.returnunited(screwed(tool, LEAD, START, STOP, flat_contacts_screwed(tool, LEAD)))
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
26 ms; CPU time 27 ms; peak memory 12.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
153.463114
153.463114
2.2e-11
area
324.9050839
324.9050839
1.4e-11
agrees with
cad-kernel, occt, next.BREP, cadrs, springrep
mesh
48060 triangles, closed
centre of gravity
(5.20881e-16, 0.837625, 3.75) its STEP's solid
inertia
about it, of unit density: Ixx 1954.92; Iyy 2105.26; Izz 2469.87; Ixy 1.93078e-13; Iyz 2.61644e-13; Izx 143.893
//! The solid a regular tetrahedron fills as it is carried along a screw: the tetrahedron with//! corners (5, 1, 1), (5, −1, −1), (3, 1, −1) and (3, −1, 1), turned right-handed about the z axis//! while rising 5 a turn, rigidly, from a turn of 0° to 540°.//!//! The tetrahedron is the solid its four triangles enclose; its sweep is kentron's sweep of a//! solid (`sweep::solid`, one screw).usecrate::bench::p;
usecrate::shared::offset::polygon_face;
use kentron::boolean;
use kentron::math::Axis;
use kentron::sweep::{self, RigidMotion};
use kentron::topology::{Model, Shape};
use std::f64::consts::TAU;
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let (a, b, c, d) = (p(5.0, 1.0, 1.0), p(5.0, -1.0, -1.0), p(3.0, 1.0, -1.0), p(3.0, -1.0, 1.0));
letmut faces = Vec::new();
for triangle in [[a, b, c], [a, c, d], [a, d, b], [b, d, c]] {
faces.push(polygon_face(m, &triangle)?);
}
let tetrahedron = boolean::enclosed_solids(m, &faces)?;
sweep::solid(m, tetrahedron, &RigidMotion::Screw { axis: Axis::Z, lead: 5.0, from: 0.0, to: 1.5 * TAU })
}
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.
Time
313 ms; CPU time 313 ms; peak memory 52.9 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
153.463114
153.463114
4.7e-12
area
324.9053063
324.9050839
6.8e-07
agrees with
no other kernel
mesh
41184 triangles, closed
centre of gravity
(3.24104e-16, 0.837625, 3.75) its STEP's solid
inertia
about it, of unit density: Ixx 1954.93; Iyy 2105.27; Izz 2469.87; Ixy 8.58575e-14; Iyz -8.06605e-14; Izx 143.897
//! The solid the regular tetrahedron with corners A = (5, 1, 1), B = (5, −1, −1), C = (3, 1, −1)//! and D = (3, −1, 1) fills as the screw about the z axis that rises 5 a turn carries it from a//! turn of 0° to one of 540°.//!//! solidcraft-kernel has no sweep of a solid, so the sweep is built by elementary geometry from//! the kernel's helical sweep of planar regions (`sweep_helix`). A point the tetrahedron passes//! over that is outside it where it starts is reached first through a face moving outward there.//! A point p moves with (−p.y, p.x, 5/2π) per radian of the screw, so a face's outward normal n//! meets that motion in a dot product linear across the face, and the face leads wherever it does//! at all three corners. ACD (n along (−1, 1, 1)) and ABC (n along (1, 1, −1)) lead at all of//! theirs; BCD and ABD trail at all of theirs. So the sweep is the tetrahedron where it starts,//! with the screw sweeps of ACD and ABC, each crossing the motion, never moving along itself; the//! tetrahedron where it ends is their far end.usesuper::square_bar_screwed_through_rod::screw;
usecrate::solids::*;
use solidcraft_kernel::loft_to_point;
/// The plane of the triangle `p`, from its first corner along its first side, and the triangle/// drawn on it.fntriangle(p: [Vec3; 3]) -> R<(Plane, Loop2)> {
let bad = || KernelError::Invalid("the triangle's plane".into());
let x = (p[1] - p[0]).normalized().ok_or_else(bad)?;
let n = (p[1] - p[0]).cross(p[2] - p[0]).normalized().ok_or_else(bad)?;
let plane = Plane { origin: p[0], x, y: n.cross(x) };
let at = |q: Vec3| v2((q - p[0]).dot(plane.x), (q - p[0]).dot(plane.y));
Ok((plane, Loop2::polygon(&[at(p[0]), at(p[1]), at(p[2])])))
}
pubfnbuild() -> R<Body> {
let (a, b, c, d) = (v3(5.0, 1.0, 1.0), v3(5.0, -1.0, -1.0), v3(3.0, 1.0, -1.0), v3(3.0, -1.0, 1.0));
let (base, lp) = triangle([b, c, d])?;
letmut swept = loft_to_point(&base, &lp, a)?;
for face in [[a, c, d], [a, b, c]] {
let (plane, lp) = triangle(face)?;
let region = Region2 { outer: lp, holes: vec![] };
swept = union(&swept, &screw(&plane, ®ion, 5.0, 0.0, 540.0)?)?;
}
Ok(swept)
}
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 2.9 ms; peak memory 11.4 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 regular tetrahedron carried along a screw.//// 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
27 ms; CPU time 26 ms; peak memory 10.2 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
153.463114
153.463114
9.0e-11
area
324.9050838
324.9050839
6.3e-11
agrees with
cad-kernel, occt, kentron, cadrs, springrep
mesh
41634 triangles, closed
centre of gravity
(-2.16445e-11, 0.837625, 3.75) its STEP's solid
inertia
about it, of unit density: Ixx 1954.92; Iyy 2105.26; Izz 2469.87; Ixy -1.0498e-08; Iyz -1.80056e-09; Izx 143.893
//! The solid a regular tetrahedron fills as it is carried along a screw.//!//! Through the kernel's whole sweep of a solid (`sweep_solid`): the tetrahedron as a convex//! polyhedron, its four corners and four faces, along the screw about the z axis that turns 1 and//! rises 5/2π per radian, from 0 to 3π (540°). The kernel bounds the sweep by the tetrahedron's back//! faces at the start, its front faces at the end, and the sheets its silhouette edges sweep between.usecrate::solids::p;
usecrate::Refusal;
use brep_kernel::{sweep_solid, BrepSolid, ScrewStep, SolidMotion, SolidTool};
use std::f64::consts::{PI, TAU};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let tool = SolidTool::Polyhedron {
vertices: vec![p(5.0, 1.0, 1.0), p(5.0, -1.0, -1.0), p(3.0, 1.0, -1.0), p(3.0, -1.0, 1.0)],
faces: vec![vec![0, 1, 2], vec![0, 1, 3], vec![0, 2, 3], vec![1, 2, 3]],
};
let motion = SolidMotion {
steps: vec![ScrewStep { axis_origin: p(0.0, 0.0, 0.0), axis_direction: p(0.0, 0.0, 1.0), turn: 1.0, advance: 5.0 / TAU }],
from: 0.0,
to: 3.0 * PI,
};
Ok(sweep_solid(&tool, &motion)?)
}
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
28 ms; CPU time 53 ms; peak memory 10.6 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
153.4631138
153.463114
1.9e-09
area
324.9050834
324.9050839
1.3e-09
agrees with
cad-kernel, occt, kentron, next.BREP, springrep
mesh
39864 triangles, closed
centre of gravity
(-9.60737e-16, 0.837625, 3.75) its STEP's solid
inertia
about it, of unit density: Ixx 1954.92; Iyy 2105.26; Izz 2469.87; Ixy -2.71943e-13; Iyz 3.09955e-13; Izx 143.893
//! The solid a regular tetrahedron (corners (5, 1, 1), (5, −1, −1), (3, 1, −1), (3, −1, 1))//! fills as it is screwed about the z axis, rising 5 a turn, from a turn of 0° to 540°.//!//! The tetrahedron is the cube from (3, −1, −1) to (5, 1, 1) less what lies beyond each of its//! faces' planes (a large block placed on the far side of the plane through three corners, cadrs's//! affine transform of a box, cut away); its sweep is cadrs's sweep of a solid (a turn and a slide//! along its axis at once: a screw).usecrate::bench::{block, cut, p3};
usecrate::shared::swept::{screwed, z_axis};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel, Kernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let corners = [p3(5.0, 1.0, 1.0), p3(5.0, -1.0, -1.0), p3(3.0, 1.0, -1.0), p3(3.0, -1.0, 1.0)];
let centre = p3(4.0, 0.0, 0.0);
letmut solid = block(k, p3(3.0, -1.0, -1.0), p3(5.0, 1.0, 1.0))?;
for skip in0..4 {
let t: Vec<_> = (0..4).filter(|&i| i != skip).map(|i| corners[i]).collect();
// The face's outward normal (away from the centre) and two directions in its plane.letmut n = (t[1] - t[0]).cross(&(t[2] - t[0])).normalize();
if n.dot(&(centre - t[0])) > 0.0 {
n = -n;
}
let x = (t[1] - t[0]).normalize();
let y = n.cross(&x);
// The block from (−10, −10, 0) to (10, 10, 10) in that frame: wholly beyond the plane.let unit = block(k, p3(-10.0, -10.0, 0.0), p3(10.0, 10.0, 10.0))?;
let m = nalgebra::Matrix3::from_columns(&[x, y, n]);
let beyond = k.transform_affine(unit, m, t[0].coords)?.first()?;
solid = cut(k, solid, beyond)?;
}
screwed(k, solid, z_axis(), 5.0, 0.0, 540.0)
}
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
64 ms; CPU time 63 ms; peak memory 10.3 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
153.463114
153.463114
6.5e-12
area
324.9050839
324.9050839
3.2e-12
agrees with
cad-kernel, occt, kentron, next.BREP, cadrs
mesh
42040 triangles, closed
centre of gravity
(-1.27327e-15, 0.837625, 3.75) its STEP's solid
inertia
about it, of unit density: Ixx 1954.92; Iyy 2105.26; Izz 2469.87; Ixy -3.08787e-13; Iyz -3.23697e-13; Izx 143.893
//! The solid a regular tetrahedron with corners (5, 1, 1), (5, −1, −1), (3, 1, −1) and (3, −1,//! 1) fills as it is screwed about the z axis, rising 5 a turn, from 0° to 540°.use springrep::boolean::{difference, half_space};
use springrep::sweep::solid;
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{boxed, deg, screwing, v3};
pubfnbuild() -> Result<Brep, String> {
// the cube (3, −1, −1)–(5, 1, 1) with its other four corners cut off, each by the plane// through the three tetrahedron corners beside itlet center = v3(4.0, 0.0, 0.0);
letmut tetrahedron = boxed([3.0, -1.0, -1.0], [5.0, 1.0, 1.0], "cube")?;
for k in [
v3(-1.0, -1.0, -1.0),
v3(-1.0, 1.0, 1.0),
v3(1.0, -1.0, 1.0),
v3(1.0, 1.0, -1.0),
] {
let corner = half_space(&tetrahedron, center + k / 3.0, k).map_err(e)?;
tetrahedron = difference(&tetrahedron, &corner).map_err(e)?;
}
solid(&tetrahedron, &screwing(5.0, 0.0, deg(540.0)), "screw").map_err(e)
}
geomsolver left no solid to show.
Time
51 ms; CPU time 53 ms; peak memory 26.3 MB
Notes
refused error[E080]: `part`: native CAD boundary construction for continuous motion sweeps is not yet supported
// The solid a regular tetrahedron fills as it is carried along a screw. The tetrahedron is centred// 4 along x, and its three axes of symmetry run through its centre along x, y and z: one corner and// its half turns about the three are its four, (5, 1, 1), (5, -1, -1), (3, 1, -1) and (3, -1, 1).// Its three edges from that corner are equal, which makes it regular, their length an unknown the// solve finds (2√2); it stands 2 tall, the corner 2 above its half turn about x; and the corner// lies toward +x of its half turn about y and toward +y of its half turn about z, which says which// of the four roots is meant. It is the join of two opposite edges: every point of a segment// between a point of the one and a point of the other. The screw is about z, right-handed, rising 5// a turn; the part is the kernel's sweep of the tetrahedron from a turn of 0 to 540 degrees.unit mm
use std
use std.sets
use std.motion (screws)
centre := point
centre coincident std.x
std.origin distance(4mm, along: std.x) centre
along_y := axis
along_y parallel(sense: same) std.y
centre coincident along_y
along_z := axis
along_z parallel(sense: same) std.z
centre coincident along_z
param edge: Lengthhint(3mm)
a := point
b := point
c := point
d := point
a symmetry(std.x) b
a symmetry(along_y) c
a symmetry(along_z) d
a distance(edge) b
a distance(edge) c
a distance(edge) d
b distance(2mm, along: std.z) a
c distance(>= 0mm, along: std.x) a
d distance(>= 0mm, along: std.y) a
construction tetrahedron := solid({ p | some q in std.sets.Segment(a, b), r in std.sets.Segment(c, d):
p in std.sets.Segment(q, r) })
feed := frame
feed screws(5mm) std.z
part := solid({ p | some t in (0deg, 540deg): p in tetrahedron at(under: feed) t })
anvilcad left no solid to show.
Time
1.1 ms; CPU time 950 µs; peak memory 3.4 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 regular tetrahedron carried along a screw.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())
}