 # Transform.Rotation vector not working for any direction

Hi, I’m new in this forum and I have a question about how to rotate vectors.

I try to rotate the vector (0,0,1) -35 degrees in any direction. The way I have to make this rotation is as follows:

``````Vector3d vectorToRotate = new Vector3d(0, 0, 1);

Vector3d orientation= new Vector3d(0, 1, 0);

vectorToRotate.Transform(Transform.Rotation((-35*Math.PI)/180, orientation, Point3d.Origin));
``````

If the direction of rotation is parallel to any axis the behavior of the code is as
expected, however if the address does not match any of the axes the result is
not suitable:

Orientation vectorToRotate behavior

(0,1,0) (-0.57, 0, 0.81) Right

(1,0,0) (0, 0.57, 0.81) Right

(0.7,0.7,0) (0.4,0.4, 0.81) Incorrect

The plane of rotation in the first two is perpendicular to the orientation vector,
however the plane of rotation is parallel to the latter orientation vector.

Someone can help me to correct this behavior?

Hi Miguel,

This seems to produce the correct result:

``````protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var angle = -35.0;
var radians = angle * Math.PI / 180.0;

var v0 = Vector3d.ZAxis;

var center = Point3d.Origin;
var axis = new Vector3d(0.7, 0.7, 0);
axis.Unitize();

RhinoApp.WriteLine("Before transform = {0}", v0.ToString());

var xform = Transform.Rotation(radians, axis, center);
var v1 = v0;
v1.Transform(xform);

RhinoApp.WriteLine("After transform = {0}", v1.ToString());