# [vtkusers] Help displaying Plane

Shawn Waldon shawn.waldon at kitware.com
Fri Aug 26 09:39:51 EDT 2016

```Hi Albert,

Sounds like you figured it out.  Here is a clarification for future readers:

A vtkPlaneSource's output is always a parallelogram (square, rectangles and
rhombi are special cases of this). SetOrigin sets one corner of the plane.
SetPoint1 and SetPoint2 set the corners adjacent to that one.  All of these
points are in world coordinates not relative to each other.  The fourth
corner and the normal are computed based on the offsets to these two points
from the origin.

Shawn

On Thu, Aug 25, 2016 at 9:33 PM, Albert Palomer <albert.palo at gmail.com>
wrote:

> Ok, I figured it out after going through the source code
> The SetPoint1 and SetPoint2 set the second point of the vector while the
> first one is set by SetOrigin (by default origin [-0.5 -0.5 0] ). This
> leads to the rhomboid because the two vectors of the parametric equation
>  p=p0+v1*t+v2*s are computed as in v1 = point1 - origin and v2 = point2 -
> origin.  So if you chose Point1 to be only in the X direction and point 2
> to the Y (which in my mind is what should give a square) gives a rhomboid
> because the director vectors of the plane are not perpendicular.
>
> So, to define the plane I do:
>
>
> vtkSmartPointer<vtkPlaneSource> planeSource = vtkSmartPointer<vtkPlaneSource>::New();
>
> // Set origin for computing the two director vectors
>
> planeSource->SetOrigin(0,0,0);
>
> // Set point for first director vector
>
> planeSource->SetPoint1(x_size,0,0);
>
> // Set point for second director vector
>
> planeSource->SetPoint2(0,y_size,0);
>
> // Set center
>
> planeSource->SetCenter(5, 0.0, 0.0);
>
> // Set normal
>
> planeSource->SetNormal(0,0,1);
>
>
> Hope this helps to anybody that might be in the same trouble.
>
>
> Albert Palomer Vila
>
> 2016-08-25 17:47 GMT-07:00 Meehan, Bernard <MEEHANBT at nv.doe.gov>:
>
>> According to the vtkPlaneSource documentation, you aren’t really supposed
>> to define the plane with the SetNormal function. You are supposed to define
>> it with SetPoint1, SetPoint2 and SetCenter. Another popular way of making
>> the plane you want is to start out with the default plane – which is
>> centered at the origin, perpendicular to the z axis, and has an x-direction
>> measurement of 1, and a y-direction measurement of 1. You then use
>> vtkTransform to make it the shape you want it to be.
>>
>> I was going to give you a working example, but ran into something that I
>> didn’t understand.
>> I thought this would make a plane that was 2 units in x, 1 unit in y, and
>> had a center at (1, 0.5) - which seems to be what ParaView does with it …
>> however it seems to come out as a parallelogram?
>>
>> import vtk
>>
>> plane = vtk.vtkPlaneSource()
>> plane.SetPoint1(2.0, 0.0, 0.0)
>> plane.SetPoint2(0.0, 1.0, 0.0)
>> plane.SetCenter(0.0, 0.0, 0.0)
>> plane.Update()
>>
>> mapper = vtk.vtkPolyDataMapper()
>> mapper.SetInputData(plane.GetOutput())
>>
>> actor = vtk.vtkActor()
>> actor.SetMapper(mapper)
>>
>> renderer = vtk.vtkRenderer()
>>
>> render_window = vtk.vtkRenderWindow()
>>
>> render_window_interactor = vtk.vtkRenderWindowInteractor()
>> render_window_interactor.SetRenderWindow(render_window)
>>
>> renderer.SetBackground(0.1, 0.3, 0.9)
>> render_window_interactor.Start()
>>
>> _______________________________________________
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>>
>
> _______________________________________________
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>