- 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 never$$anonymous$$d... 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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.