This function would take a vector, and another that is perpendicular to it (they do not necessarily have to be unit vectors) and rotate it by r degrees (in radians).
This can be expressed by the following:
function rotateVectorAroundAxis(axis, vector, angle)
local zVector = (vector:Cross(axis)) / axis.Magnitude
return math.cos(angle) * vector + math.sin(angle) * zVector
end
This would be helpful as it could mean you could take the lookVector, and upVector of a part, and rotate the upVector by a specified angle without having to construct a CFrame or have to write the same function every time you want to use it.
By making it a function of a Vector3 too, it makes it much shorter to write too.
For example:
local lookVector = part.lookVector
local upVector = part.upVector
local angle = math.pi/4
--currently
function rotateVectorAroundAxis(axis, vector, angle)
local zVector = (vector:Cross(axis)) / axis.Magnitude
return math.cos(angle) * vector + math.sin(angle) * zVector
end
local rotatedUpVector = rotateVectorAroundAxis(lookVector, upVector, angle)
--compared to
local rotatedUpVector = upVector:RotateAroundAxis(lookVector, angle)
I know its not necessarily much longer, but there are loads of functions for CFrames desipite them being relatively short to write out.
This would improve my experience because I wouldn’t have to remember this function, or copy and paste it when I need it.