Hi everyone!
This is a general question that I hope I can get some clarification on. But I'm getting the vector direction, angle, distance, and dot product of an object. I cannot for the life of me understand what some of the output means or how I can use it to set conditions in my code for the direction.
For example:
direction: (0.7, 0.2, -0.6) (no clue)
Dot product: -0.3 (no clue)
Angle: 107.5 (makes sense)
Distance: 1.7 (makes sense)
Normalized direction: (-0.1, -1.0, 0.0) (no clue)
Replies
Direction
Imagine your shoulder is your world origin: 0, 0, 0 and point your finger somewhere. Where your finger is is a value in 3D space relative to that origin, so X=0.7, Y=0.2, Z=-0.6. Directions are very similar to normal XYZ positions, but for most operations they're assumed to be unit length i.e. magnitude == 1, so most of the time these values will be <=1.0.
Dot Product
The dot product is most often used to find the angle between two vectors given in -1.0 to 1.0. So your direction vector was compared against another vector and the result was -0.3 meaning your vector is pointing somewhat opposite the other vector. In this case I think you're comparing to a forward or up vector but you've truncated your values so I can't be sure. The dot product is super useful because it can tell you whether vectors point the same direction. If you get a value close to 1 then they're pointing approximately the same way, -1 and they're opposites, 0 and they're perpendicular (see also: Cross Product).
Angle
Angle doesn't make much sense to me here, angle around which axis and in relation to what? So you're 107.5 degrees around something. This type of value is most useful for human readable output but it needs context to be understood and that's why it may be obvious to you but not to me.
Distance aka Magnitude
Your value here doesn't make sense here either since the magnitude (distance) of your vector is 0.943, though I assume you cut some precision off here so the magnitude is actually closer to 1.0. I also assume what you're actually doing is comparing the distance between two objects here, or distance to world origin maybe.
Normalized Direction
just fits your vector to unit length, so above where it's 0.943, it just extends the vector to 1.0, or trims it if it's greater than 1.
For context, I'm using the data to rotate a rocket and depending on it's tilt, I would enable particles on either side. Previously I did it using basic eulerAngles and it worked great if I was only moving from the origin. So if I rotated on the -X I would enable particles on a certain side. If I rotated on the +Y I would enable particles on another side, and so on. But once you start putting the rocket in arbitrary angles it would break.
It was recommended to me that I try using vectors for this type of thing so that the rocket can be at whatever position in 3D space and still get the same results. (which I couldn't do before).
Which brings me to the original question of how I could use that info to get the same affect. Or if I'm missing some data. If needed I can post code.
You could do that with dot product. So you need to get the direction the models are facing somehow, in Unity it'd be transform.forward or something similar in Unreal, note that you want this in world space not local. Then get the down vector, you can do this 1 of 2 ways but I'll detail the easiest one here, for now you can assume the ground is flat and wouldn't ever change in which case it'd just be 0, -1, 0 (Unity), or 0, 0, -1 (Unreal) and then just do a dot product.
You'll get a value between -1 and 1, if the value crosses some threshold i.e. 0.5 then it's probably the closest to the floor and you can activate it.
Hope that helps.
I was thinking that I needed to get the direction the rocket is point to know what particles to enable. Not sure if that's the right thinking?