- Home /

# Mapping dot product to positive range

A dot product between two angles gives me a value ranging from [-1,1], but I'm trying to use it in a target weighting system where every value (distance, facing, etc) is evaluated in a range of [0,1], with 1 being the highest possible weight. As such, is there any simple way to remap a dot product, such that a value of -1 is evaluated as 0 or 0.1 (the lowest possible weight), a value of 0 is evaluated as 0.5, and a value of 1 tops out at 1?

**Answer** by DiegoSLTS
·
Jun 23, 2015 at 08:43 PM

You can't change what values are returned by the dot product, it's an algebraic definition, but you can easily map that value on another range after getting it. Something like this should work to map the [-1,1] range to the [0,1] range:

```
float dotProductResult = /*some dot product*/;
dotProductResult = (dotProductResult + 1)/2;
```

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

Multiple Cars not working 1 Answer

Help Understanding Script 2 Answers

How to calculate inner vertices of a line renderer? (math question) 1 Answer