- Home /

# How to visualize Vector math in Unity?

I'm trying to visualize solving these issues with vectors, such as the dot product. I just can't seem to visualize the position of gameObjects as quantities with a direction. If I wanted the Dot Product of an object at (2,4,0) and another object at (5,2,0), how can I draw that out on paper with the direction?

I don t understand what you mean. So I'm not going to put this as an answer but maybe this will help you. A dot product has no direction it is just a scalar number that represents the sum of the products.

I think position and direction are also different. I could be wrong but position (x,y,z) is (number of units in the x, # of units in the y, # of units in the z) away from origin (0,0,0). Direction (x,y,z) would be adding (x,0,0) + (0,y,0) + (0,0,z).

So in your example (2,4,0) as a position is 2 units away from origin in the x axis and 4 units away from the origin in the y axis. So in unity this object would be in the center of your world but off to the right 2 and up 4 (I think not 100% if + is right or left, guess it depends on which way your looking).

(2,4,0) as a direction is a vector {square root of([2^2]+[4^2]) = (4+16) = 20} in magnitude and points up mostly. Draw a vector with the tail starting from origin pointing 2 in the +x direction and a vector with the tail starting at the tip of the previous vector to 4 in the +y direction then draw a line from the origin to the head of the last vector.

**Answer** by s_guy
·
Jun 24, 2013 at 11:20 PM

The language you use in your question I think is complicating things. A vector3 can represent an object in r3 space, but usually with dot products it helps to think of it as an actual vector (the physics concept, not the data structure).

That is, the vector you're using in a dot product conveys a direction and a magnitude, not just an x,y,z value in r3 space. Think of it as the line from 0,0,0 to the position of that x,y,z position. The magnitude is just the length of this line. This makes adding, subtracting, and more complex operations much easier to visualize.

"If I wanted the Dot Product of an object at (2,4,0) and another object at (5,2,0), how can I draw that out on paper with the direction?"

Draw a line from 0,0,0 to 2,4,0. Call it 'a'.

Draw a line from 0,0,0 to 5,2,0. Call it 'u'.

Draw the

*projection*of line a onto line u, as depicted here (this image doesn't use the exact coordinates from your example).

**Think of it as "how far the first vector goes in the direction of the second vector".** *Note that this means a.u is different than u.a.*

Practical uses:

quantity is positive if the two vectors are pointing in similar directions (acute angle)

quantity is zero if they are perpendicular (on any plane)

quantity is negative if the two vectors are pointing away from each other (obtuse angle)

Unity's official docs were a good, brief refresher course for me on this. http://docs.unity3d.com/Documentation/Manual/UnderstandingVectorArithmetic.html

For a deeper study, the Kahn academy videos on this are excellent. They can be a little more "abstract math" oriented, but he does a great job of walking through vectors, vector math, and how to gain an intuitive sense of vector math, i.e. what a vector operation "means". https://www.khanacademy.org/math/linear-algebra/vectors_and_spaces

You can jump straight to his lecture on vector dot product and cross product intuition, but I advise building up to it. https://www.khanacademy.org/math/linear-algebra/vectors_and_spaces/dot_cross_products/v/dot-and-cross-product-comparison-intuition

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.