[vtkusers] How to get angle between two 3D points
Marco Sambin
m.sambin at gmail.com
Tue Apr 23 02:39:17 EDT 2013
Hi.
This looks more like a C# question, and I am not a C# expert at all.
However, you may want to take a look here:
http://msdn.microsoft.com/it-it/library/ms146627.aspx
Having said this, computing the dot product between two vectors and their
modulus is so simple that you probably may prefer to compute them directly
from your C# code, especially if marshalling of parameters to call a VTK
method is complex.
Regards,
Marco
Il giorno 23/apr/2013 06:39, "Arindam" <arindam at triassicsolutions.com> ha
scritto:
> Thanks for your reply.I already tried and i got the angle by this.but i
> was getting one issue here.vtkMath is having a method called Dot<http://www.vtk.org/doc/release/5.0/html/a01710.html#z331_0>(const double x[3], const double y[3]) and
> Norm <http://www.vtk.org/doc/release/5.0/html/a01710.html#z333_0> (const
> float x[3]) in c++.but i was doing my application in c#.Where this two
> method prototype is like Dot(IntPtr X,Intptr Y) and Norm(Intptr X) . How
> can we convert it?Please help.
>
> On 4/22/2013 8:35 PM, Marco Nawijn wrote:
>
> As the other Marco already mentioned, you need at least three points (or
> 2 vectors) to calculate the angle between them.
> If you have them, you can simply apply the cosine rule which states (in
> words):
> the cosine of the angle between two vectors is the dot product of the
> vectors divided by the their lengths multiplied.
> so in math:
> dot(a,b)
> cos(angle) = -----------
> norm(a)*norm(b)
>
> I have not checked it, but I guess vtk will have buildin functions for
> calculating dot (or inner) products and norms.
> Take a look at the functionality provided in the vtkMath library.
>
> Kind regards,
>
> (another) Marco
>
>
>
>
> On Mon, Apr 22, 2013 at 10:23 AM, Marco Sambin <m.sambin at gmail.com> wrote:
>
>> Hi.
>> In order to define an angle, you will need at least THREE points. Is the
>> third point the origin (0,0,0) in your case?
>> I guess you will need to identify the plane "containing" those three
>> points, and then you will be able to compute the angle on that plane, in a
>> "2D fashion".
>> Regards,
>>
>> Marco
>>
>>
>>
>> On Mon, Apr 22, 2013 at 10:19 AM, Arindam <arindam at triassicsolutions.com
>> > wrote:
>>
>>> Hi,
>>>
>>> I want to calculate angle between two 3D points.Suppose the points are
>>> (5,5,5) and (1,2,3). For 2D points i know how can i do this.But for 3D
>>> points i need help from some one.Any help will be appreciated.
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> 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
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> 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
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> 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
>
> Follow this link to subscribe/unsubscribe:http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130423/3abfb1c1/attachment.htm>
More information about the vtkusers
mailing list