Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Distance between two parallel planes
jacob_kingery
Member Posts: 39 EDU
Is there a way to find the distance between two parallel planes? Specifically, I want to determine if two planes are the 'same'; that is, there is no distance between them along the normal axis.
0
Comments
-
Easiest way is probably
var samePlane = samePoint(plane1.origin, project(plane2, plane1.origin));<br>We might add some more utility functions for this type of stuff...Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0 -
If you have confirmed that the planes are indeed parallel, you can check if they are coincident by:
1. Constructing a vector between the plane's origins.
2. Checking if that vector is perpendicular to the plane's normal.
i.e.arePlanesCoincident is boolean = perpendicularVectors( (plane2.origin - plane1.origin), plane1.normal ); <br>A shorthand for this wouldn't be right to provide in std, since the computation is nonsense unless the planes are parallel. Perhaps we could have an "arePlanesCoincident" function which does both checks, and an "arePlanesParallel" function which does just the first?0 -
If you do want just the distance, you can alternatively grab the z-component of plane2's origin, from the prospective of plane1.
i.e.distance is ValueWithUnits = worldToPlane(plane1.origin, plane2)[2];0 -
Ilya,
A note on documentation - it is confusing to me that in the documentation there are two functions called "project". I understand that they do different things because they can recognize their inputs, but I think it would be much more intuitive if that were all contained within one description of the function.
0 -
Amanda,
That's an interesting point. Thus far, we've only been documenting overloads together in special cases: Where a parameter is optional, or where the type needn't be specified (as withtoString).
In this case, the two definitions of project seem distinct enough to warrant separate documentation, but it's definitely not ideal to the end user to have them in the different files.
Perhaps we could pull a bunch of the more commonly used functions into a file which imports all the necessary types? It'd be nice, when perusing the docs, if you could generally find things they need in a small set of files, and it would allow us to pair similar functions together to avoid this confusion (project/project, fromWorld/worldToPlane, etc.)
0 -
Kevin,
In your second suggestion (distance is ValueWithUnits = worldToPlane(plane1.origin, plane2)[2];), it appears that the point and plane parameters are switched (should beworldToPlane(plane2, plane1.origin)). Also,worldToPlaneseems to return a vector with only 2 elements (I believe x- and y-coordinates). Do you know why there wouldn't be a z-coordinate?0 -
Ah, yup, that's what I get for not testing my own code. worldToPlane projects the point onto the plane, leaving out the z-coordinate. Useful for sketching, but not for this.
You could usefromWorld(coordSystem(plane1.origin, plane1.x, plane1.normal), plane2.origin) [2];
(Though that's still untested)
There will soon be a CSys constrictor which just takes a plane, which makes that slightly easier.
A slower but simpler method isnorm(plane2.origin - project( plane1, plane2.origin ));
0 -
@amanda_sutherland
In the library I can actually find 3 project functions (onto a Line, Plane, or Vector) and the third one is inconsistent w.r.t. the argument order
I'll make a note to refactor that.
We may also write more for other curve and surface types.
Not sure I understand your suggestion for conveying thatproject(blah, vector)projectsvectorontoblah.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0 -
@ilya_baran
I meant that it would be useful to note all the variations of project in the same place.0



