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.

FS calculating plane normal

graham_lock
graham_lock Member Posts: 276 PRO
Hi,

I'm creating a plane at an offset from a reference plane which I also want to angle at a given number of degrees.

My test code looks like this:

const p is Plane = plane(
                offsetDirection ? (refPlane.origin - (offset * refPlane.normal)) : (refPlane.origin + (offset * refPlane.normal)),
                vector(0, 0.1, 0.3)
                );


            opPlane(context, id + "plane1", {
                        "plane" : p
                    });

How should I go about generating the normal vector to achieve the desired angle?

Thank you.

Best Answer

  • Caden_Armstrong
    Caden_Armstrong Member Posts: 458 PRO
    Answer ✓
    FeatureScript transforms are great, they do a lot of heavy lifting for you.

    If you create a rotation transform:
    var rotationangle = rotationAround(X_AXIS, 30*degree);
    var newVector = rotationangle*oldvector;
    The one thing is that it only works with vectors that have a length.
    So you'll need to take  your normal, give it units (ie oldvector*meter), rotate it, and then remove units (newVector/meter)

    www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
    Experts in Onshape Automation - Custom Features and Integrated Applications

Answers

  • Caden_Armstrong
    Caden_Armstrong Member Posts: 458 PRO
    Answer ✓
    FeatureScript transforms are great, they do a lot of heavy lifting for you.

    If you create a rotation transform:
    var rotationangle = rotationAround(X_AXIS, 30*degree);
    var newVector = rotationangle*oldvector;
    The one thing is that it only works with vectors that have a length.
    So you'll need to take  your normal, give it units (ie oldvector*meter), rotate it, and then remove units (newVector/meter)

    www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
    Experts in Onshape Automation - Custom Features and Integrated Applications
  • graham_lock
    graham_lock Member Posts: 276 PRO
    Thank you.