GLYLIB  0.3.0b
get_angle_between_plane_and_vector.c
Go to the documentation of this file.
00001 // Function written by Oliver Grant, 2011
00002 #include <mylib.h>
00003 #include <molecules.h>
00004 /************** get_angle_between_plane_and_vector() ******************/
00005 double get_angle_between_plane_and_vector(plane p, coord_3D pt1, coord_3D pt2){
00006 
00007 double magnitude, angle;
00008 vectormag_3D plUV,ptV,ptUV; //plane unit vector, points vector, points unit vector
00009 
00010 //get normal unit vector of the plane
00011 magnitude=sqrt(p.A*p.A + p.B*p.B + p.C*p.C); //can i trust p.D?
00012 plUV.i=p.A/magnitude;
00013 plUV.j=p.B/magnitude;
00014 plUV.k=p.C/magnitude;
00015 
00016 //get vector of the two points
00017 ptV.i=(pt1.i-pt2.i);
00018 ptV.j=(pt1.j-pt2.j);
00019 ptV.k=(pt1.k-pt2.k);
00020 magnitude=sqrt((ptV.i*ptV.i) + (ptV.j*ptV.j) + (ptV.k*ptV.k));
00021 
00022 // normalize this vector
00023 ptUV.i=ptV.i/magnitude;
00024 ptUV.j=ptV.j/magnitude;
00025 ptUV.k=ptV.k/magnitude;
00026 
00027 printf("magnitude=%f\nptUV.i=%f,ptUV.j=%f,ptUV.k=%f,plUV.i=%f,plUV.j=%f,plUV.k=%f\n",magnitude,ptUV.i,ptUV.j,ptUV.k,plUV.i,plUV.j,plUV.k);
00028 
00029 // orientation of points vector with respect to the plane
00030 angle=(get_dotprod(plUV,ptUV));  /* angle in radians */
00031 
00032 return angle;
00033 }
 All Classes Files Functions Variables Typedefs Defines