Questions on vectorToObjectSpace and clarity on :Inverse() on Jeep model from suburban

Around lines 29-37 in the CarScript found in the Jeep found in the roblox suburban map, from my findings I’m pretty sure that the offset * car.chassis.CFrame = thruster.CFrame when the offset multiplied by the car.Chassis.CFrame equals thruster.CFrame:


So I’m pretty sure I’m good on line 29, however 30, I read the CFrame Math Operators Article on vectorToObjectSpace() but still do not understand how it works or rather the purpose of it.
line 30:

local speed = car.Chassis.CFrame:vectorToObjectSpace(car.Chassis.Velocity)

and I’m pretty sure I can understand the rest (31-37) once I understand this line. Can someone explain in depth? Thanks!

For the first part youre mostly right, you just mixed up the order
The car.Chassis.CFrame has to stay in the front like

offset = car.Chassis.CFrame:Inverse() * thruster.CFrame

|
v

car.Chassis.CFrame * offset = thruster.CFrame

As for vectortoobjectspace, its basically the same as toobjectspace (or a:Inverse * b like you have above), but it only looks at the rotation, and that rotation is in the form of a vector

Say you have two cframes a and b

Here are two ways to get the relative rotation, one more similar to toobjectspace and the other more similar to vectortoobjectspace:

(a:Inverse() * b).LookVector --more similar to toobjectspace
((a-a.p):Inverse() * CFrame.new(Vector3.new(0,0,0), b.LookVector)).LookVector --more similar to vectortoobjectspace

The formal method uses a shortcut like (a-a.p):Inverse() * vector, but they should be the same

1 Like

So from my understanding, vectorToObjectSpace takes a CFrames rotation Inverse() ignoring x, y, z and multiplies it by a vector. What does this do? Is it some kind of rotational offset?

It rotates the vector by the inverse (opposite) rotation of the cframe put as simply as I can
So it subtracts the rotation of the cframe from the rotation of the vector

1 Like

The vector inside of the brackets?
image
So in that case should the vector3 value be a rotation value like orientation or lookvector?
Thanks for help btw

Think of it like this, what can I multiply (x) by a to get b. That is just a linear equation of ax=b, solve for x which is b/a. As you may know, matrix division doesnt exist. What does exist though is matrix multiplication, also known as the hadamard product. If you don’t know, the inverse of a value depends on what operands you which to invert. Say I have 5 - 10 and want to make it so that I will get the same expression with just addition I would use the additive inverse to said negator (10) 5 + -10 = 5-10 and therefore applies to all sets, that means that b/a = b*1/a. :Inverse() in roblox is the inverse of the hadamard product

2 Likes

How does this apply to vectorToObjectSpace? My understanding of Inverse is that it can be used to cancel by multiplying a CFrame Inverse on both sides, leaving behind a new subject. Tbh I did not get a lot of what you said cause I don’t know the terminology that u used.

@PapaBreadd
Edit: I understand how formula works I just don’t know how the speed is worked out using vectorToObjectSpace, I thought speed was distance / time:

local speed = car.Chassis.CFrame:vectorToObjectSpace(car.Chassis.Velocity)

Thanks everyone for the help :smiley:

im pretty sure it just makes it relative to the cframes lookat vectors. like if the velocity was 0,0,1 it would be transformed to the cframes lookvector

1 Like

Thank you, I completely forgot that multiplying a vector like Vector3.new(0, 0, -1) by a CFrame with the position part of the CFrame subtracted was the same as CFrame.LookVector. This clears up a lot of confusion for me