Ability to use the power of on datatypes?

Is it possible, or could roblox implement a way to use ^ on datatypes like Vector2, Vector3, Colo3, UDim, CFrame, etc… I can’t seem to do it in studio using:

CFrame.new(2,2,2) ^ 4

Here’s what studio shows:

Meanwhile here’s what happens when I do it in my own luau based lua (luam):

Is it possible to make the roblox version work like the luam one?
(or if some admin is reading this, maybe the roblox dev team could add it? Its just a small thing but its good to have.)

You could just use the __pow metatable method or define a function to do this, but it’s not possible with ROBLOX’s version of Lua I believe

You could just create a function to do it for you…

local function powercframes(cframe, power)
   local res = cframe
    for i = 1, power do
        res *= cframe
    end
    return res
end

Oddly, you can multiply CFrames but you can’t perform powers on them, which is sort of strange.
p.s. I probably made a stupid mistake in my code somewhere - please let me know!

Oh okay, thanks. Still a bit odd that they don’t have built-in support for it tho.

1 Like

The code returns a cframe of 10,10,10,… when doing powercframes(CFrame.new(2,2,2), 4). It should be 16,16,16,…

I’m kinda busy right now, I’ll fix it in a bit. Feel free to “unsolution” it - perhaps other people can help out while I’m gone.

1 Like

ok im back (what i was doing didn’t take long at all, strangely…)
anyways, here’s a different method

local function powercframes(cframe, power)
	local xval = cframe.X ^ power
	local yval = cframe.Y ^ power
	local zval = cframe.Z ^ power
	return CFrame.new(xval, yval, zval)
end
print(CFrame.new(2,2,2))
print(powercframes(CFrame.new(2,2,2), 4))

@Malte0621 i think it works now. im half asleep so i might’ve made another stupid mistake :confused:

What about the rotation matrix?
m11, m12, m13, m21, m22, m23, m31, m32, m33?