[vtkusers] Question about surface normal

Luca Pamparana luca.pamparana at gmail.com
Thu Nov 5 10:23:26 EST 2009


Hi David,

Yes, the user point that I talk about would lie outside the plane, of course.

So, basically what I have is a series of planes in my 3D scene all
around a point in my 3D world and what I want to achieve is create
these planes with the explicit normals pointing towards this point.

Cheers,

Luca

>
> On Thu, Nov 5, 2009 at 3:05 PM, Luca Pamparana <luca.pamparana at gmail.com> wrote:
>> Hi David,
>>
>> Thanks for your reply. So, if I have got it correct:
>>
>> - I can take vectors AC and BD and using the cross product find the
>> current normal vector.
>> - The normal vector I want would be described as user_specified_point
>> - (any of my polygon points). Is this correct?
>> - Then I could use your transformation function to transform the 4 points...
>>
>> If I was to use a vtkPlane object, would this be easier? In the
>> example that you send me, the function specifies the center of the
>> plane and the surface normal. Would the plane center be invariant
>> under this transformation? I would have thought that if I was to
>> specify a normal explicitly, the points would have to be
>> recalculated....
>>
>> Sorry for the constant mailing. I hope this would be the final question!
>>
>> Thanks,
>>
>> Luca
>>
>> On Thu, Nov 5, 2009 at 2:44 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
>>> 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