Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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_kingeryjacob_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.

Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,215
    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 Inc
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited October 2015
    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 );&nbsp;<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?
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    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];
  • amanda_sutherlandamanda_sutherland Member Posts: 14 EDU
    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. 
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    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 with toString).

    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.)

  • jacob_kingeryjacob_kingery Member Posts: 39 EDU
    Kevin,

    In your second suggestion (distance is ValueWithUnits = worldToPlane(plane1.origin, plane2)[2];), it appears that the point and plane parameters are switched (should be worldToPlane(plane2, plane1.origin)). Also, worldToPlane seems 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?
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited October 2015
    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 use
    fromWorld(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 is norm(plane2.origin - project( plane1, plane2.origin ));

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,215
    @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 that project(blah, vector) projects vector onto blah.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • amanda_sutherlandamanda_sutherland Member Posts: 14 EDU
    @ilya_baran
    I meant that it would be useful to note all the variations of project in the same place.
Sign In or Register to comment.