- Home /

# Creating planes in Unity

I am using unity and vuforia target images and I need to construct three planes. The first plane is to be constructed using three target images (consider them as points). The second plane must be perpendicular to the first and also pass through two points one and two (which are used to construct the first plan). The third plane must be perpendicular to first plane and normal to the vector which is formed by the 1st and second point.

The picture below demonstrates this. The blue triangle is the first plane set up using the target images (points) which are labelled 1,2 and 3. The black plane is the second and the red is the third.

Any help on how to achieve this through code would be greatly appreciated.

**Answer** by Bunny83
·
Sep 03, 2019 at 11:15 AM

It's not quite clear what exactly you refer to by "plane". Do you just mean an infinite mathematical plane? Or do you mean creating an actual visual Mesh? If you want a mesh it's not quite clear how it should look like. With 3 points you will get a triangle for the first one. For the second and third it would not be clear where you want to place the 3rd point (yes, perpendicular to the first plane but that third point could be anywhere on that plane).

I'll assume you talk about creating an infinite plane that you can raycast against. If you actually wanted to create a mesh you have to be much more clear what you want to create.

For a mathematical plane Unity has the very simple Plane struct. It has several options to create a plane. So for the first one, assuming A, B and C are your 3 corner points as Vector3, you would simply do:

```
Plane groundPlane = new Plane(A, C, B);
```

It's A-C-B because the points need to be ordered clockwise in order for the plane to face up.

For the other two plane all we need is the perpendicular upward direction of the first plane. For this we simply calculate the cross product between AC and AB. Note that the order matters.

```
Vector3 up = Vector3.Cross(C - A, B - A).normalized;
```

Now you can simply construct a new point "D" by adding your newly created up vector to your point A. Finally we can construct the other two planes with the points A,B,D and A,C,D. The wanted order / orientation of those planes is not clear from your drawing. So the rest is up to you.

```
Vector3 D = A + up * wantedDistanceFromA;
Plane planeThroughAandB = new Plane(A,B,D);
Plane planeThroughAandC = new Plane(A,C,D);
```

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

how can I use the vuforia text recogniton with out using the sample package? 0 Answers

when view next scene the 3D modal appear black ? 0 Answers

Combine Two Image Targets to generate a model (Unity + Vuforia) 0 Answers

how to access the buttons when the AR camera is turned on. 0 Answers

Trouble with ZXing QR Scanning 0 Answers