This function takes in an akOrigin (the ObjectReference to act as the center) and an akObject (the ObjectReference you want to be rotated). Note that this function returns a float[3] array; it does not perform the actual rotation. It returns a new set of X, Y, Z worldspace coordinates in the [0], [1], and [2] elements of the array that correspond to the coordinates your reference should be located at, once it's been rotated by the degrees you specified in the function call. You will need to create a new array to accept the return of this function. Once you have the coordinates returned by this function, you can call whatever movement function you like at that point (most likely SplineTranslateTo) using whatever parameters you choose.
Enjoy. I've tested it and it works.
float[] function GetPosXYZRotateAroundRef(ObjectReference akOrigin, ObjectReference akObject, float fAngleX, float fAngleY, float fAngleZ)
Rotates a point (coordinates of akObject) offset from the center of rotation (akOrigin) by the supplied degrees fAngleX, fAngleY, fAngleZ, and returns the new desired position of the point.
Spoiler
float[] function GetPosXYZRotateAroundRef(ObjectReference akOrigin, ObjectReference akObject, float fAngleX, float fAngleY, float fAngleZ);-----------\;Description \ Author: Chesko;----------------------------------------------------------------;Rotates a point (coordinates of akObject) offset from the center of;rotation (akOrigin) by the supplied degrees fAngleX, fAngleY,;fAngleZ, and returns the new desired position of the point.;-------------\;Return Values \;----------------------------------------------------------------; fNewPos[0] = The new X position of the point; fNewPos[1] = The new Y position of the point; fNewPos[2] = The new Z position of the point; |1 0 0 |;Rx(t) = |0 cos(t) -sin(t) |; |0 sin(t) cos(t) |;; |cos(t) 0 sin(t) |;Ry(t) = |0 1 0 |; |-sin(t) 0 cos(t) |;; |cos(t) -sin(t) 0 |;Rz(t) = |sin(t) cos(t) 0 |; |0 0 1 |;R * v = Rv, where R = rotation matrix, v = column vector of point [ x y z ], Rv = column vector of point after rotationfAngleZ = -(fAngleZ) ;Invert Z angle to account for the game's interpretation of Z rotationfloat myOriginPosX = akOrigin.GetPositionX()float myOriginPosY = akOrigin.GetPositionY()float myOriginPosZ = akOrigin.GetPositionZ()float fInitialX = akObject.GetPositionX() - myOriginPosXfloat fInitialY = akObject.GetPositionY() - myOriginPosYfloat fInitialZ = akObject.GetPositionZ() - myOriginPosZfloat fNewXfloat fNewYfloat fNewZ;Objects in Skyrim are rotated in order of Z, Y, X, so we will do that here as well.;Z-axis rotation matrixfloat fVectorX = fInitialXfloat fVectorY = fInitialYfloat fVectorZ = fInitialZfNewX = (fVectorX * cos(fAngleZ)) + (fVectorY * sin(-fAngleZ)) + (fVectorZ * 0)fNewY = (fVectorX * sin(fAngleZ)) + (fVectorY * cos(fAngleZ)) + (fVectorZ * 0)fNewZ = (fVectorX * 0) + (fVectorY * 0) + (fVectorZ * 1);Y-axis rotation matrixfVectorX = fNewXfVectorY = fNewYfVectorZ = fNewZfNewX = (fVectorX * cos(fAngleY)) + (fVectorY * 0) + (fVectorZ * sin(fAngleY))fNewY = (fVectorX * 0) + (fVectorY * 1) + (fVectorZ * 0)fNewZ = (fVectorX * sin(-fAngleY)) + (fVectorY * 0) + (fVectorZ * cos(fAngleY));X-axis rotation matrixfVectorX = fNewXfVectorY = fNewYfVectorZ = fNewZfNewX = (fVectorX * 1) + (fVectorY * 0) + (fVectorZ * 0)fNewY = (fVectorX * 0) + (fVectorY * cos(fAngleX)) + (fVectorZ * sin(-fAngleX))fNewZ = (fVectorX * 0) + (fVectorY * sin(fAngleX)) + (fVectorZ * cos(fAngleX));Return resultfloat[] fNewPos = new float[3]fNewPos[0] = fNewX + myOriginPosXfNewPos[1] = fNewY + myOriginPosYfNewPos[2] = fNewZ + myOriginPosZreturn fNewPosendFunction
Example:
float[] myNewPos = new float[3]myNewPos = GetPosXYZRotateAroundRef(PlayerRef, myCabbage, 25.0, 0.0, 0.0) ;Find out where myCabbage would be if rotated 25.0 degrees on the X axis around the Player.myCabbage.SplineTranslateTo(myNewPos[0], myNewPos[1], myNewPos[2], 0.0, 0.0, 0.0, 1.0, 200.0) ;Move the cabbage to the new rotated position