# Tag Info

### Benefit of using Vector2 data type over separate x & y variables

First of all, it's way less clutter. If you have a position, a velocity and an acceleration, that's already 6 variables you have to deal with, 9 in 3d. Secondly, and this is the most important part, ...

### If a 3D vector represents a point, how can it have a length?

Does that mean that the magnitude is simply it is distance from the origin point (0, 0, 0)? That's exactly that. Among other things, a vector can represent a point (a position), a direction and/or a ...
Accepted

### How can I rotate an object based on another's offset to it?

The answer is actually pretty easy if you do the math. You have a fixed distance of Y and a variable distance of X (See Picture 1). You need to find out the angle between Z and X and turn your turret ...
Accepted

### How can I find the perpendicular to a 2D vector?

I always forget how to do this when I need it so I wrote a couple of extension methods. ...

### Why can't I use the operator '>=' with Vector3s?

Defining >= for a Vector3 type makes no sense. What determines if one vector is greater than another? Their magnitude or ...
Accepted

### How can I get the normal vector for a plane from a set of vertices?

You could easily find the normal by calculating two vectors, V1 = P2-P1, and V2 = P3-P1, and then find the cross product N = V1 x V2. Then you normalize N. Depending on the ordering of the vertices (...
Accepted

### If a 3D vector represents a point, how can it have a length?

Does that mean that the magnitude is simply it is distance from the origin point (0, 0, 0)? The tl;dr answer may be: Yes, you can imagine it like that. But I'm not sure whether this might not lead ...
Accepted

### How do I tell if my enemy can see my player?

The dot product of two vectors can tell you if they face each other or not. First vector can probably be the enemies view direction the second one should be a vector pointing from player's position to ...
Accepted

### How do I interpret the dot product of non-normalized vectors?

Others have pointed out how you can use the sign of the dot product to broadly determine the angle between two arbitrary vectors (positive: < 90, zero: = 90, negative: > 90), but there's another ...
Accepted

### Why can't I use the operator '>=' with Vector3s?

To simplify the answer, Vector3 is a custom struct provided by the UnityEngine namespace. ...

### What are some good examples of the practical usages of cross product in game development?

Generating Normals As Maximus Minimus notes in the comments, when we have a mesh without normal vectors (say just raw vertex positions from a procedural generator or 3D scanned point cloud), we can ...
Accepted

### How can I "zero out" velocity in an arbitrary direction?

This is pretty simple linear algebra. You can make a little helper method for it: ...

### Benefit of using Vector2 data type over separate x & y variables

Compare the function signatures of both RotatePoints versions. Lone variables: ...
Accepted

### What's the 'proper' way to get unit vectors?

A Unit Vector is of length 1. A given vector can be converted to a unit vector by dividing it by it's magnitude. (With the exception of course that a zero length vector can not be converted). Note ...
Accepted

### How can I check if a player-drawn line follows a path?

Here's a vector-based solution. I haven't tried it, but it seems fine conceptually. Theory I gather you've stored the shape as line segments. Here's the letter A represented with three line segments....
Accepted

### Why does a unit vector show direction?

First we get a vector from B to A, as in the following picture: Now we have a vector that tells us how to get exactly from B to A. In code it looks something along these lines: ...

### Benefit of using Vector2 data type over separate x & y variables

Readability > Writeability I feel like it's just slow me down and barely has any benefit other than organizing your code. You are correct in that it (slightly) slows you down writing that code. ...

### How can I draw a line of certain length and direction?

You can simply get the vector pointing in the right direction, then scale it by the distance you want and add that to the initial point. This will define a new end point for your line. ...
Accepted

### Does vector transformation order matter?

Because of the linearity (aka distributive property) of vector addition and matrix multiplication, it doesn't matter! Yay! ...
Accepted

### Moving a 2D object along circular arc between two points

You can use Bezier Curves. Given 2 given points, you have to define one third point yourself that controls where the curve is made. In your example you can create the point between your two given ...
Accepted

### What is a direction vector and why should it be normalized?

A 2D vector has two values (x and y), and it basically says how far you go from the point of origin in the x- and in the y-...
Accepted

### Unity: transform.LookAt(target) not "looking at" target?

The Problem: Your eyes default rotation makes them look to the negative X axis. However, Transform.LookAt() rotates the transform, so that the Transform.forward looks at the target. The Transform....
Accepted

### How to find point on a circle that's opposite another point?

Calculate a vector from B to A, normalize it (divide by the vector's length), then multiply by the circle size: ...

### If a 3D vector represents a point, how can it have a length?

Does that mean that the magnitude is simply it is distance from the origin point (0, 0, 0)? You can see it that way, but only seeing it that way may lead to a wrong understanding. First of all, a ...

### Benefit of using Vector2 data type over separate x & y variables

Operator overloading. Vector v3 = v2 + v1; There is now only one place in your code where you have to write, test and debug vector addition, as opposed to tens, ...

### What are normal, tangent and binormal vectors and how are they used?

I know this is old but i would like to add a little practical information. As stated by others but more specifically related to graphical programming. A Normal aka (a surface normal) is orthogonal to ...