Rotate Vector around Axis?

Hi there, i have a seemingly easy question, but i just cannot figure out what i am doing wrong. maybe someone could help me with this.
i want to rotate a vector around an axis (wich is generated from two vectors). i have tried to recreate it in a playground

i just dont even understand what is happening here - shouldnt it rotate around the axis between point1 and point2 (of course setting the angle manually in line 65)?

i hope someone could gell me whats wrong here.

Thanks a lot!!

The main issue seems to be line 56, where you changed point1 by subtractInPlace. To solve it you can use subtract to calculate rotationAxis instead.

Also you might want to normalize the axis, but Quaternion.RotationAxis(axis, angle) works anyway.

hmm it does not seem to be the problem… it does not change anything:

Maybe change




Or can you please be more precise on what is the problem
You want to rotate around certain point/pivot, like center of your rotationAxis?


it also does not work as expected.

So what i want to do:
i have a vector A. and i have two other vectors B & C. the line between B&C is the pivot axis, A should be rotated around this Axis.
how do i do that?

Thanks a lot

Thanks this gave me some clarifications like that your vectors are points(positions) and not rotation-vectors. I think you can just add center position of your rotationAxis as offset:

Fixed PG:

But more elegant would be to use BabylonJS mesh capabilities:

1 Like