Grab a single scalar from a vector?

Is there a way to grab a single component from a vector? Say given a vector of (0,10,20) grab the y component only in an expression?

wouldn’t the vector be separated in XYZ components?
like:
axis.rotation = (x, y, z)
so yo can do
axis.rotation.y

not in front of Flame now

Yes. You should do a dot product. Multiplying two vectors will give you a scalar:

dot (V1, V2)
so your expression should be :
dot ((0, 10, 20),(0,1,0))

dot

Returns the scalar dot-product of two given vectors. The dot-product is the product of the lengths of two vectors and the cosine of the angle between them. If the two vectors are at a right angle (90 degrees), their dot-product is 0.
If the product of their lengths equals 1 and they point in opposite directions (180 degrees), their dot-product is -1. The dot-product is equivalent to the expression V1.x * V2.x + V1.y * V2.y + V1.z * V2.z.

3 Likes

Of course! Brilliant. Thanks @Sinan. I was looking for a simpler approach… in Vex I could do something like:

f@y = (set(4, 5, 6)).y;

to grab the y component but a dot will work a treat.

ah, didn’t quite get the question :point_up_2:

1 Like