It is possible to narrow it down to the rectangular face formed by these two lines, and I have tried boundingbox, intersecting the rectangular face’s enclosing box with other solid enclosing boxes as a way of determining this, but without success. Perhaps there is a more direct way?
Even if intersecting lookes successful. … what if it reality there is only one endpoint or just one edge of the object between these parallel edges. You would need to catch that situation too.
I don’ t know Ruby but could envision this in a model.
Have you tried:
# object_vertices is an array of the object's vertices from edges and faces
object_pts = object_vertices.map(&:position)
Sketchup::Face#clasify_point()
result = object_pts.any? {|pt|
where = face.classify_point(pt)
where != Sketchup::Face::PointOutside &&
where != Sketchup::Face::PointNotOnPlane
}
?
If the object is a line, it just passes through the face, and its start and end points are not on the face, so that the returned result will show that both points are on the outside of the face.
Well, you asked about an object between two parallel lines (ie, face edges.)
In the case of a line passing through a face’s plane, you would likely need to find the intersection point using the Geom::intersect_line_plane
module method, and then test the intersection point using Face#classify_point
.
The area plane (face) between two parallel lines is finite, the common plane (plane) is infinite in extent, if a line in the plane, and how?
Step 2 - you get the point where the edge’s line intersects the face’s plane.
Step 2 - you then need to use face.classify_point to see if that point is on the face that has that plane.
Look up Dan’s links to understand the steps needed.
As shown in the figure, a line is between two lines parallel to each other, and the three lines are in the same plane, use intersect_line_plane, the return result will be nil.
Since you keep modifying the problem, I’ll “tap out” and let you figure it out for yourself.
You have moved the goal-posts !
These are not ‘lines’, they are ‘edges’ - a ‘line’ has a special meaning in Geom…
An edge has a line but it is infinitely long.
First off you need to establish if the two existing edges are coplanar.
Three points define a plane.
So the start and end points of edge one, and the start of edge two define a plane.
If the end of edge two is on that plane you know the two edges are coplanar.
Next, if the start and end of the new edge - i.e. edge three - are on the plane it is also coplanar.
To determine if edge three is wholly between the two original edges is more convoluted…
In your first illustration - the original two edges seem to have parallel vectors, there are tests to show you that.
If the third coplanar edge also has a vector parallel with those, then you simply need to work out if the start of that edge is between the start points of the two original edges… make vectors from it to those and compare them - the angle between the vectors will vary depending on location, also vector dot and cross products might be helpful…
Repeat for the line’s end point.
In you second illustration the third edge starts outside the two original edges so its vector ‘product’ should reveal that to you…
If the new edge is not parallel to the first two then it’s more convoluted, but do able…
Do the logic tests in bite sized chunks…
- create a plane in which these two lines lie
- from the first vertex of the object, lower the perpendicular to the plane (we get point=pt)
- then lower the perpendicular to each line from pt (we get pt1 pt2)
- compare the direction of the vectors ptpt2 ptpt1, if in different directions then be between the lines, if in the same direction then outside
- repeat the operation for all vertexes of the object