# How to build a plane passing through 3 points

**URL:** https://discourse.vtk.org/t/how-to-build-a-plane-passing-through-3-points/11926
**Category:** Support
**Created:** [July 11, 2023, 7:34am UTC](https://discourse.vtk.org/t/how-to-build-a-plane-passing-through-3-points/11926 "2023-07-11T07:34:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ioneianni](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ioneianni/32/7429_2.png) [@ioneianni](https://discourse.vtk.org/u/ioneianni)
#### Post date: [July 11, 2023, 7:34am UTC](https://discourse.vtk.org/t/how-to-build-a-plane-passing-through-3-points/11926/1 "2023-07-11T07:34:05Z")

</div>

Hi,  
I would like to build a plane knowing only three points. Here is my code, but it dosen’t work can someone help please?  
planes = []  
planes.append(vtkPlanes())  
planes[0].SetPoints(points\_bct)  
piano\_aorta = planes[0].GetPlane(0)  
The problem is that pianoaorta is empty

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [July 11, 2023, 10:56am UTC](https://discourse.vtk.org/t/how-to-build-a-plane-passing-through-3-points/11926/2 "2023-07-11T10:56:22Z")

</div>

Welcome to VTK, @ioneianni !

I don’t believe vtkPlanes will compute a plane the way you want it to. You’ll instead have to supply an origin point and a normal to define the plane yourself. Fortunately, this isn’t too difficult.

Select one of your points `{p1, p2, p3}` as the plane’s Origin. Let’s say you pick `p1`. Now, compute two vectors `v1` and `v2` from the other two points by subtracting `p1` from those points. Normalize the vectors. Finally, find the cross product of the normalized vectors to give you a normal.

In VTK code, you can do this with

```auto
from vtk import vtkMath
p1 = your first point. Could be list or tuple
p2 =
p3 =
v1 = [0, 0, 0] # make it a list because a list is assignable
v2 = [0, 0, 0]
normal = [0, 0, 0]
vtkMath::Subtract(p2, p1, v1);
vtkMath::Normalize(v1);
vtkMath::Subtract(p3, p1, v2);
vtkMath::Normalize(v2);
vtkMath::Cross(v1, v2, normal);

```

Now you can define a plane with something like

```auto
planes[0].SetNumberOfPlanes(1)
plane = planes[0].GetPlane(0)
plane.SetOrigin(p1)
plane.SetNormal(normal)

```

Hope that helps!

---

<div class="post-metadata">

### Author: ![ioneianni](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ioneianni/32/7429_2.png) [@ioneianni](https://discourse.vtk.org/u/ioneianni)
#### Post date: [July 11, 2023, 2:10pm UTC](https://discourse.vtk.org/t/how-to-build-a-plane-passing-through-3-points/11926/3 "2023-07-11T14:10:58Z")

</div>

Thanks, for your answer!
