Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How does inverse function work and how to use it?

Asked by 7 years ago

I would like how to know how inverse can be used

Could I use it like this?

local i = 0
function Example()
    if i > 1 then
        i = i:inverse
    end
    print(i)
end

Example()

0
Not exactly; you use the inverse function for CFrames (also known as CoordinateFrames). This article will (hopefully) help you w/ this & steer you in the right direction :) : http://wiki.roblox.com/index.php?title=Understanding_CFrame TheeDeathCaster 2368 — 7y
0
No, the point is how do i get the opposite value if -1 is the inverse of 1, such things. I wanna know how to get the Inverse of values GeezuzFusion 200 — 7y
0
inverse = x * -1 User#5423 17 — 7y

2 answers

Log in to vote
3
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
7 years ago
Edited 7 years ago

"Inverse" is a term from mathematics that has two meanings:


The inverse function of a function "undoes" that function. i.e., if F is the inverse of f, then F(f(x)) should be the same as x. Examples:

*x^2 is the inverse of math.sqrt(x) * math.acos the inverse of math.cos * math.sin the inverse of math.asin.

Not all functions are invertible (meaning some functions don't have inverses)


The identity of an operation is the1 value that "does nothing" to other values:

  • The identity of + (for numbers) is 0 since x + 0 is x
  • The identity of * (for numbers) is 1 since x * 1 is x
  • The identity of * (for CFrames) is CFrame.new(0, 0, 0) since x * CFrame.new() is x
  • The identity of + (for Vector3s) is Vector3.new(0, 0, 0) since x + Vector3.new() is x

The inverse of a value x with respect to an operation is the value y that "cancels" with x yielding the identity of that operation.

Not all values have inverses.

  • the inverse of x with respect to + (for numbers) is -x since x + -x is 0, the additive identity
  • the inverse of x with respect to * (for numbers) is 1/x or x^-1 since x * 1/x is 1, the multiplicative identity. 0 does not have a multiplicative inverse
  • the inverse of x with respect to + (for Vector3s) is -x since x + -x is Vector3.new(0, 0, 0), the additive identity
  • the inverse of x with respect to * (for CFrames) is x:inverse() since x * x:inverse() is CFrame.new(), the multiplicative identity of CFrames

  1. identities are unique 

Ad
Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

As i read in the comments, the thing you want is:

Value = -Value

Your question is about :inverse, wich is a method that can be called on CFrames.

As tested in roblox studio:

v = 2 print(-v), prints -2

v = -2 print(-v), prints 2

Answer this question