You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a Reactor Designer/Developer, I want to draw arbitrary straight lines to cut up my reactor 2D cross-section made of BluemiraWires, so that I can cut down components for neutronics csg.
We do not currently have a straightforward method of finding where a piece of wire intersects with a straight-line. The reason is likely because we were not expecting the wires to be used this way in 2D when BluemiraWire was initially created.
Proposed solution
Make a method that creates a plane that is both perpendicular to the 2D plane that we are drawing the BluemiraWire in, and parallel to the line of interest; and use slice_shape to find all intersection points, then use parameter_at to find the corresponding parameter.
Alternative solutions 1
Derive the equation for determining the intersection point between a straight line and each of the following curve types:
Straight line: this one is trivial
Arc of circle:
Bezier curve
BSpline
Arc of ellipse
Then, for each edge in the BluemiraWire, apply the corresponding equation to determine where the intersection points are.
So the method should collect all of the intersection points from each edge, and return them as a list of coordinates.
Alternative solutions 2
Simply use scipy.optimize.bisect to perform a binary search using BluemiraWire.value_at(). The search range must be determined appropriately by the user beforehand.
Additional context
This is a very specific use case of BluemiraWire (which are inherently 3D objects) to represent 2D shapes. Should we make a subclass of BluemiraWire (e.g. called Bluemira2DWire)?
The text was updated successfully, but these errors were encountered:
BluemiraWires are 3-D. If you want to intersect them with a line, you will likely run into problems. You can use geometry::tools.py::slice_shape with a BluemiraPlane if you want 3-D intersections.
If you are working in 2-D, I generally recommend using Coordinates which are generally better suited for such work. BluemiraWires with multiple sub-wires can quickly become tricky in many 2-D situations where you expect things to be ordered and they are not.
In the case that it is definitely 2-D and you use Coordinates, you can use geometry::coordinates.py::get_intersect for the intersection between two 2-D shapes.
The wire that I'm dealing with is a BSpline curve, which means I can't use get_intersect without first discretizing, which makes the program equally slow anyways. (I've tried upping the discretization resolution from 10 to 50 points-per-wire elsewhere, and it managed to slow down the program runtime from 0.8s to 3.4s.)
Unfortunately there are no curved lines functionality in coordinates.py which is why I haven't been able to use it.
So far the issue of misordering hasn't come up again after dealing with #3037, which seemed more like a serialization bug anyways, and we've managed to solve part of it by using .OrderedEdges so it hasn't happened again. But please do draw my attention to any misordering bug if you know of it and I'll assess whether that's going to be a problem or not!
Yeah, I kind of solved my own issue in the ocean/csg branch using that. I used slice_shape() to make bluemira.geometry.tools.get_wire_plane_intersect. I'll resolve/close this issue once that branch is merged.
Description of issue / requirement to address
As a Reactor Designer/Developer, I want to draw arbitrary straight lines to cut up my reactor 2D cross-section made of BluemiraWires, so that I can cut down components for neutronics csg.
We do not currently have a straightforward method of finding where a piece of wire intersects with a straight-line. The reason is likely because we were not expecting the wires to be used this way in 2D when BluemiraWire was initially created.
Proposed solution
Make a method that creates a plane that is both perpendicular to the 2D plane that we are drawing the BluemiraWire in, and parallel to the line of interest; and use
slice_shape
to find all intersection points, then useparameter_at
to find the corresponding parameter.Alternative solutions 1
Derive the equation for determining the intersection point between a straight line and each of the following curve types:
Then, for each edge in the BluemiraWire, apply the corresponding equation to determine where the intersection points are.
So the method should collect all of the intersection points from each edge, and return them as a list of coordinates.
Alternative solutions 2
Simply use
scipy.optimize.bisect
to perform a binary search using BluemiraWire.value_at(). The search range must be determined appropriately by the user beforehand.Additional context
This is a very specific use case of BluemiraWire (which are inherently 3D objects) to represent 2D shapes. Should we make a subclass of BluemiraWire (e.g. called
Bluemira2DWire
)?The text was updated successfully, but these errors were encountered: