How come atan !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! possible...but inverse trigonometric function of cos-1 needs to translated in terms of atan !!!! hmmmm ........... quite complicated thinking
Regards, Sumit On Sun, Mar 28, 2010 at 10:05 PM, Liam Healy <[email protected]>wrote: > I'm a big fan of atan2, but in this case there's no benefit to using it > because an angle between two vectors will always be less than or equal > to 180 degrees, so the quadrant is unambiguous from the cosine. > Dot product and cosine is the right way to go. > > Liam > > On Sun, Mar 28, 2010 at 11:11 AM, Jerome BENOIT <[email protected]> > wrote: > > Hello List, > > > > a better idea is to build some code around the atan2 function. > > > > Jerome > > > > 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 > >>> vectors. > >> > >> 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. > >> > >> #include<gsl/gsl_blas.h> > >> … > >> 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 ) ); > >> > > > > -- > > Jerome BENOIT > > jgmbenoit-at+rezozer*dot_net > > > _______________________________________________ > Help-gsl mailing list > [email protected] > http://lists.gnu.org/mailman/listinfo/help-gsl > _______________________________________________ Help-gsl mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gsl
