geometry.intersect — Keep only the volume common to two or more geometry features.
feature = geometry.intersect(feature1, feature2, ...) returns a geometry.Feature for the volume that lies inside every operand.
Syntax
feature = geometry.intersect(feature1, feature2, ...)Inputs
feature- Type
Any- Required
- Variadic
- Default
- —
- Description
- Two or more geometry.Feature operands.
Returns
feature- Type
Any- Description
- geometry.Feature for the volume common to all operands.
Errors
RunMat:geometry:intersect:InvalidInput- When
- The wrong number of arguments is passed. Fewer than two operands are given, an operand is not a geometry.Feature, or the operand graphs define one feature identity differently. A value violates the feature-graph contract.
- Message
geometry.intersect: invalid input
Behavior
At least two operands are required. Their feature graphs are merged so that shared features are kept once; conflicting definitions of one feature identity are rejected. The first operand is the argument of the Boolean and the rest are its tools.
If the operands do not overlap, the realized result is empty and region selections on it fail their cardinality checks.
The call records construction intent only. It appends one operation to an immutable, content-addressed feature graph and returns a new geometry.Feature; it does not run a CAD kernel, tessellate, or touch the filesystem. The graph is realized as exact B-rep topology when a .fea geometry declaration that imports the generating function is materialized for meshing or analysis.
Every failure, including the wrong number of arguments, a value of the wrong kind, and a value that violates the feature-graph contract (a nonpositive or non-finite length, radius, depth, distance, or angle, or an all-zero direction), raises the builtin's own RunMat:geometry:<name>:InvalidInput identifier, and no value is returned. Feature identities are derived from a digest of each operation, so repeating the same construction yields the same feature identity.
Use in a study
Return the finished part from a pure .m function: geometry.finish(feature) turns the final feature into a geometry.Generated product, and geometry.withRegion publishes typed selections under names. A .fea geometry declaration written as generated by function.<name> calls that function, realizes the exact geometry, and exposes each named selection as output.region.<name> for meshing, material assignment, constraints, and loads.
Intersection is a compact way to trim a primitive, for example a sphere clipped by a cylinder to make a dome.
Errors
RunMat:geometry:intersect:InvalidInput reports every failure of the call: the wrong number of arguments, fewer than two operands, an operand that is not a geometry.Feature, or conflicting feature definitions, or a value that violates the feature-graph contract, such as a zero or negative dimension, a non-finite value, or an all-zero direction. A failed call returns nothing, and earlier values are unchanged because builder values are immutable.
Examples
Intersect two spheres
a = geometry.sphere(20e-3, [0 0 0]);
b = geometry.sphere(20e-3, [25e-3 0 0]);
lens = geometry.intersect(a, b);
class(lens)A single operand is rejected
a = geometry.sphere(20e-3, [0 0 0]);
lens = geometry.intersect(a);Using geometry.intersect with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how geometry.intersect changes the result.
Run a small geometry.intersect example, explain the result, then change one input and compare the output.
FAQ
Can I display or mesh a feature directly in a script?⌄
Not yet. geometry.Feature and geometry.Generated are construction values; mesh and meshing.generate accept a loaded geometry.Asset. Realization happens when a .fea geometry declaration imports the generating function.
Related Geometry functions
Construction
geometry.box · geometry.chamfer · geometry.cylinder · geometry.edges · geometry.edgesIntroducedBy · geometry.extrude · geometry.faces · geometry.facesIntroducedBy · geometry.fillet · geometry.finish · geometry.hole · geometry.instance · geometry.pocket · geometry.revolve · geometry.solid · geometry.sphere · geometry.subtract · geometry.transform · geometry.union · geometry.withRegion
Related guides
Source you can read
Every RunMat function's source is public. Read exactly how geometry.intersect is executed, line by line, in Rust.
- View the source for geometry.intersect in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.