4 Replies Latest reply on Jul 26, 2013 12:56 AM by Oleg Bezyaev

# Rotate vector with API

Is there any way to using SW API to turn the vector moment of inertia at a certain angle in a certain plane? For example, turn mathematically (not model) axis "Ix" at an angle of 2 degrees in the plane "IxIy".

• ###### Re: Rotate vector with API

Yes, it is possible to do using the MathUtility::CreateTransformRotateAxis method to get the transformation and then apply this transformation to your original vector MathVector::MultiplyTransform.

Function CreateTransformRotateAxis( _

ByVal PointObjIn As Object, _

ByVal VectorObjIn As Object, _

ByVal Angle As Double _

) As Object

PointObjIn - any point lies on your vector (Ix) you want to rotate

VectorObjIn - vector to rotate about. If your plane is IxIy, your rotation vector is normal to IxIy.

Angle - angle in radians

____________________________________________________

Regards,

Artem Taturevych, Application Engineer at Intercad (Australia)

translationXpert – add-in to translate SolidWorks models

myIntercad an integrated tool for SolidWorks Professionals

LinkedIn SolidWorks API Education Group

• ###### Re: Rotate vector with API

I've already tried that.

firstVector - (1,0,0)

angle = 1

MathTransform myNewTransform = swMathUtil.CreateTransformRotateAxis (mycenterOfMass, firstVector, angle * (Math.PI / 180.0));

firstVector.MultiplyTransform (myNewTransform);

after transformations firstVector ArrayData was equal to (1,0,0)

• ###### Re: Rotate vector with API

If by VectorObjIn mean vector  Iz for the plane IxIy - the result is the same))  Vector firstVector stayed (1,0,0)

• ###### Re: Rotate vector with API

I figured out

Was:

MathTransform myNewTransform = swMathUtil.CreateTransformRotateAxis(mycenterOfMass, thirdVextor, angle * (Math.PI / 180.0));

firstVector.MultiplyTransform(myNewTransform);

secondVector.MultiplyTransform(myNewTransform);

After:

MathTransform myNewTransform = swMathUtil.CreateTransformRotateAxis(mycenterOfMass, thirdVextor, angle * (Math.PI / 180.0));

firstVector = firstVector.MultiplyTransform(myNewTransform);

secondVector = secondVector.MultiplyTransform(myNewTransform);