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.

Obtaining the perpendicular of a vector in the direction of a reference point

neobobkrauseneobobkrause Member Posts: 82 EDU
I have a vector at a point. I need the vector perpendicular to my vector that points most closely to a reference point. perpendicularVector will give me an arbitrary vector, but not necessarily the one pointing most closely to the reference point. It seems to me that another way of looking at this problem would be to consider a circle with a center perpendicular to my vector, and I to find a point on that circle which is closest to the given reference point, then create a vector pointing from my point to this closest point on the circle.

Thanks for any help.

- Bob


  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 901 ✭✭✭✭✭
    edited June 2018
    so if you have point P1 and vector N1 (which defines a plane by point and normal) and you need the closest point P3 from P1 to some point P2 and P3-P1 should be normal to N1 then you can do it in terms of vector algebra like this:
    P3 = P2- dot(normalize(N1), P2-P1)*N1
    or in terms of builtin functions of standart library:
    P3 = project(plane(P1, N1), P2 )
  • neobobkrauseneobobkrause Member Posts: 82 EDU
    Thanks Konstantin. I'm still ramping into FS and can't seem to get it to work yet.

    The document I'm working with is here. I'm trying to use the 3D Helix custom feature, but I need a few more bells and whistles than it currently has. For example, I need to control the direction of the helix along the spline. So I added a "Reverse direction" option. I also need to control the initial orientation of the helix. So I'm trying to add an "Initial reference point" option. This is where I'm getting stuck. What I want in this simple project is the ability to control whether all side helixes all start oriented toward the reference point. The UI framework is in. I've also taken a shot at some of the heavy-lifting for the implementation to control the orientation, but can't get it to work.

    Once again, any input is much appreciated.

    - Bob
  • MBartlett21MBartlett21 Member Posts: 1,573 EDU
    edited June 2018
    If you want a helix along a straight line, you can use the opHelix function.
    MB - I make FeatureScripts: view FS (My FS's have "Official" beside them)
  • neobobkrauseneobobkrause Member Posts: 82 EDU

    Thank you. Though the sample document depicts a helix around lines, The 3D Helix feature must support all types of curves.

    Turns out, I just needed to walk away and come back with a fresh outlook. I've updated my code, which now generates a helix that starts at the point furthest from an optional initial reference point. I've updated the FS code in the MetaHelix document accordingly.

    - Bob
Sign In or Register to comment.