[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] angle between two vectors

From: Jerome BENOIT
Subject: Re: [Help-gsl] angle between two vectors
Date: Sun, 28 Mar 2010 23:11:09 +0800
User-agent: Mozilla-Thunderbird (X11/20090707)

Hello List,

a better idea is to build some code around the atan2 function.


John D Lamb wrote:
On Sun, 2010-03-28 at 11:07 +0200, Jordi wrote:
I am quite new to maths and gsl I would like to get the angle between two

In C it should be something like the following. (You may have to check
where acos is defined, check norm_u * norm_v != 0; and you may want a
direction with the angle.) For floats use snrm and sdot instead of dnrm
and ddot.

  gsl_vector* u, v;
  double norm_u, norm_v, x, angle;
  norm_u = gdl_blas_dnrm( u );
  norm_v = gdl_blas_dnrm( v );
  gsl_blas_ddot( u, v, &x );
  angle = acos( x / (norm_u * norm_v ) );


reply via email to

[Prev in Thread] Current Thread [Next in Thread]