Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
rotate a vector and points
otaolafr
Member Posts: 113 EDU
Answers
-
opTransform is for rotating geometry in the context. For transforming vectors (and other things like lines and planes) you can just multiply the transform by the point:
var myTransform = rotationAround(myLine, 30 * degree);
var newPoint = myTransform * (vector(1, 2, 3) * meter);Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc2 -
i cant succed to make it work....ilya_baran said:opTransform is for rotating geometry in the context. For transforming vectors (and other things like lines and planes) you can just multiply the transform by the point:
var myTransform = rotationAround(myLine, 30 * degree);
var newPoint = myTransform * (vector(1, 2, 3) * meter);
trying this :(point1 and 2 are previously defined)var Line1=line(point1,point2);var transf=rotationAround(X_AXIS,definition.xangle);var linerotated= transf*Line1;
it needed a unit. thanks!0 -
Without the specific error (including line number) and the whole feature, it's impossible to debug. Please post a link to a public document.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0
-
it is okey, actually when i tried same thing that you told me with vectors, it didnt work, but after i gave them units it worked. so, i solved to translate the points and after do the line.ilya_baran said:Without the specific error (including line number) and the whole feature, it's impossible to debug. Please post a link to a public document.
thanks anyway0 -
Yes, we can do with a line, but I hope I dont have to create a line only for rotating the entity.
using point and vector would be fantastic.
Thank you.0 -
You don’t have to create a physical line - the Line object is a point (with units) and a vector (unitless)yudhi_ariadi said:Yes, we can do with a line, but I hope I dont have to create a line only for rotating the entity.
using point and vector would be fantastic.
Thank you.Senior Director, Technical Services, EMEA0 -
for the newbs (like me) ending up on this thread searching how to rotate a direction vector.
I tried
coneAngleRotation = rotationAround(rotationAxis, angle);
normalize(toPlaneNormal = coneAngleRotation * (toPlaneNormal * meter)
in order to rotate the unitless direction vector "toPlaneNormal". This doesn't work because in this multiplication the vector is interpreted as a point rather than a direction. It'll give an outcome, but it depends on the units chosen and isn't what you're intending. So best to create a line and rotate it that way:
coneAngleRotation = rotationAround(rotationAxis, angle);
var toPlaneNormalLine = line(point, toPlaneNormal);
toPlaneNormalLine = coneAngleRotation * toPlaneNormalLine;
toPlaneNormal = toPlaneNormalLine.direction;0 -
note: this vector transform only works in the proper order: transform * vector.
0




