[vtkusers] Question about surface normal

David Doria daviddoria+vtk at gmail.com
Thu Nov 5 09:44:35 EST 2009


On Thu, Nov 5, 2009 at 9:40 AM, Luca Pamparana <luca.pamparana at gmail.com> wrote:
> Hello David,
>
> Thanks for your reply and the tip about using the smart pointers!
>
> I was actually not sure how to generate the normal vector that would
> point to a user specified point. So, my plane has 1 cell and 4 points.
> I have one user specified point say (0, 0, 0). What would be a valid
> unit normal vector that will be normal to the whole plane? I know that
> the dot product of two normal vectors is 0 but I am struggling to
> figure out how to use this in this case.
>
> Sorry this is a real noob question but would be really obliged for any
> help here...
>
> Thanks,
>
> Luca


Say your polygon is composed of points A, B, C, D.

The cross product of any two vectors between any of those points will
give you a vector normal to the polygon (we are assuming here that
A,B,C and D actually lie on a plane).

You can then use the function I sent to align this normal with the
vector you want to be the new normal. Apply the transformation that is
computed in that function to all of your points and you should end up
with a polygon with the normal you want. You will have to align the
center of mass of the points with the origin before applying the
rotation though so that you get the expected result.

Thanks,

David



More information about the vtkusers mailing list