- Home /

# How to get the cross direction for 3 points?

How would I get the normal/cross from the three points marked in red? Assuming the points go in order 1, 2, 3 - Left to right.

**Answer** by Bunny83
·
May 09, 2018 at 11:31 AM

Since this is a 2d problem you can simply calculate the normal in 2d of each line, normalize both, combine them and normalize the result again. It might be useful to create those two extension methods for Vector3:

```
public static class Vector3ExtRotate
{
// rotate vector clockwise 90° around y
public static Vector3 XZ_CW (this Vector3 aVec)
{
return new Vector3(aVec.z, aVec.y, -aVec.x);
}
// rotate vector counter clockwise 90° around y
public static Vector3 XZ_CCW (this Vector3 aVec)
{
return new Vector3(-aVec.z, aVec.y, aVec.x);
}
}
```

Now when you have the points A, B and C you can do:

```
Vector3 n1 = (B-A).XZ_CCW().normalized;
Vector3 n2 = (C-B).XZ_CCW().normalized;
Vector3 n = (n1 + n2).normalized;
```

Note it's also possible to just do

```
Vector3 n1 = (A-B)..normalized;
Vector3 n2 = (C-B)..normalized;
Vector3 n = (n1 + n2).normalized;
```

However this would result in an invalid direction if the points A, B and C are on the same line (180° angle). My first solution only gives trouble when you have "0°". So when A and C are equal.

My solution gives you the combined normal on the "right" side of the line. If you want the "left" side just use "XZ_CW" instead of "XZ_CCW" or just invert the result ^^.

**Answer** by Cursor9
·
May 09, 2018 at 09:54 AM

if you know the Positions of the Points you could just calculate the Directions from Point 2 to the Points 1 and 3 and than calculate the cross product with 2to1 and 2to3.

Direction from Point A to B := B - A.

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