- Home /

# How to use dot product return value

So, is there anyway to make the dot product change linearly? What I mean by this is when the angle is 45 degrees, I want it to be 0.5 instead of 0.7071 as you can see in this image:

Instead I want 45 degrees to be 0.5, 60 degrees to be 0.33 and 30 degrees to be 0.66. Same would apply for the other side(135 should be -0.5)

Thank you

**Answer** by Bunny83
·
Aug 08, 2014 at 11:09 PM

Sure, what the dot product of two normalized vectors returns is the cosine between those two angles. What you want is the angle, so all you need to do is to take the arccos of that value to get the angle in radians. To get a value between 0 and 1 you just need to divide by PI. So 0 is 0° and 1 is 180° 0.5 is 90°

```
float v = Mathf.Acos(dot) / Mathf.PI;
```

Consider going straight to Vector3.Angle This does all the same calculations for you.

Wait, but how would you go from angle to a value that goes between 1 and -1?

Wait nevermind... would (pi/2 - Vector3.angle) / (pi/2) work?

Vector3.Angle() is in degrees so to map between -1 and 1 it would be:

```
Vector3.Angle(refVector, vector) / -90.0 + 1.0;
```

### 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.

### Follow this Question

### Related Questions

[Mac Build] changes path letters following dot to underscore 0 Answers

Drawing a GUIBox on player/enemies in MiniMap 0 Answers

Mapping dot product to positive range 1 Answer

help fix expando object .js file error. 0 Answers

Instantiating Dots 1 Answer