 # Transform.rotation in Rhino3dm expects 3 args?

Just getting started in Rhino3dm.js (and Javascript for that matter), and running into the following error when I try to define a simple rotation Transform:

Uncaught (in promise) BindingError {name: “BindingError”, message: “function Transform.rotation called with 4 arguments, expected 3 args!”

my code is just:

let rotationTransform = rhino.Transform.rotation(Math.sin(rotation_angle), Math.cos(rotation_angle), axis_vector, pt1);

I’ve used the RhinoCommon version of this Transform plenty of times, and the docs are pretty clear that there are 4 args required, not 3…

FYI, the value of the args are as follows:
Math.sin(rotation_angle) = 0.17410813759359597
Math.cos(rotation_angle) = 0.9847265389049334
axis_vector = [0, 0, -0.5]
pt1 = [0.0000016560283029321, -0.0000016561149323024438, 144.37180070758296]

I know I’m missing something obvious here… Any idea what’s going on?

I can see the documentation is quite old. I’ll ping someone to update this.

In the source code, I see this:

``````static BND_Transform Rotation(double angleRadians, ON_3dVector rotationAxis, ON_3dPoint rotationCenter);
``````

So that would look like this:

``````(static) Rotation(angleRadians, rotationAxis, rotationCenter) → {Transform}
``````

or

``````(static) Rotation(double, Array.<x, y, z>, Array.<x, y, z>)
``````

Does this help?

– Dale

@dale thanks so much for the quick reply!

That did help. I also realized I had to add the “new” keyword. So my code now looks like:

let rotationTransform = new rhino.Transform.rotation(rotation_angle, axis_vector, pt1);

However, as soon as that was fixed I realized that Transforms are not applied to objects the same way as RhinoCommon. For instance, I have a mesh object called “tube” and I was trying to apply the Transform like this:

tube.Transform(rotationTransform);

but realized the correct way to apply it in JS is like this:

tube.rotate(rotation_angle, axis_vector, pt1);

Can you help me understand why things work so differently in Rhino3dm.js, and why I would want to create a Transform object if I’m just going to explicitly define it as part of the .rotate() method?