Vector3 Vector3:RotateAroundAxis(Vector3 axis, number r)

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.

8 Likes

You should title/format your post after a problem instead of a specific proposed API solution. Ref: How to post a Feature Request (“Focus on problems”)

Also consider whether you are trying to solve an XY problem. Describe the core problem you are trying to solve.

There are no use cases mentioned that Roblox could use to determine what the impact of implementing this feature would be so it will be hard to prioritize.