I still don't know what :Cross is

Hello!
I’ve been scripting for a lot of time, but I do not understand what vector3 (i think):Cross() means

So, what does it to and what :Cross takes

2 Likes

Vector Cross Products

a:Cross(b) is a function that returns the Vector Cross Product of the two vectors a and b.

From a conceptual standpoint, the cross product of two vectors in R3 (3 dimensions) returns a vector perpendicular to the two given vectors.

If that is hard to visualize, let me introduce you to the “left hand rule!”

Take your left hand and make that gesture. Your index finger becomes vector ‘a,’ and your middle finger becomes vector ‘b.’ The result of the cross produce will be your thumb, facing upward. Do note that you use your left hand; if you use your right, the result will be inverted.

17 Likes

Basically it returns a vector facing up/down according to A
Like “rotated” 90 degrees according to A?
But only facing Up/Down?

1 Like

Not rotated; perpendicular. That is, a vector whose angle measurements compared to the two other vectors is 90 degrees.

In your case, saying it is simply vector A rotated by 90 degrees is fairly meaningless because in order to conduct a rotation, an axis of rotation is needed. We never say ‘rotated by 90 degrees’ in a 3d environment, we usually say ‘rotated 90 degrees on the X axis relative to the world.’

The other vector, B, provides that frame of reference.

EDIT:

Here is a non-axis-aligned example for better visualization.

3 Likes

Another interesting fact:
The magnitude of the cross product is equal to the area of the parallelogram defined by those two vectors:
download

3 Likes

Alright, Weird, I think I kinda got it, I will try to put in practice
It’s just
In this example:
image
Why did you used that example?
And why is it sizing up/down according to Y angle

But, something like this:

1 Like

The cross product vector in that animation was oscillating like that because it’s magnitude is dependent on the angle between the two input vectors. Hence, the cross product is also a useful way to tell if vectors are parallel or perpendicular. The product of two right-angle vectors would have a magnitude of 1, and the product of two parallel vectors would be 0. (The cross product’s direction would be undefined, since there can be an infinite number of possible vectors that are perpendicular to a straight line.)

In this sense, dot products are sort of the reverse of this. The dot product of two vectors is zero if they are perpendicular, and the product of their magnitudes if they are orthogonal.

1 Like

Whether it goes upwards or downwards depends on the order of the operands.

For example, (in Roblox’s coordinates) (1, 0, 0):Cross((0, 0, 1)) would be (0, -1, 0), according to the right-hand rule. In reverse order, (0, 0, 1):Cross((1, 0, 0)) would be (0, 1, 0)

3 Likes

Nevermind, I think I got it.

It’s a perpendicular to the 2 vectors!!
this image helped me a bit.

image
The result will be always on Right side?

1 Like

if “Result” is b X a, then yes. a X b would point in the opposite direction. (that image isn’t using the right hand rule though)

2 Likes