Home > matGeom > geom3d > circle3dPosition.m

circle3dPosition

PURPOSE ^

CIRCLE3DPOSITION Return the angular position of a point on a 3D circle.

SYNOPSIS ^

function theta = circle3dPosition(point, circle)

DESCRIPTION ^

CIRCLE3DPOSITION Return the angular position of a point on a 3D circle.

   POS = circle3dPosition(POINT, CIRCLE)
   Returns angular position of point on the circle, in degrees, between 0
   and 360.
   with POINT: [xp yp zp]
   and CIRCLE: [X0 Y0 Z0 R THETA PHI] or [X0 Y0 Z0 R THETA PHI PSI]
   (THETA being the colatitude, and PHI the azimut)

   See also:
   circles3d, circle3dOrigin, circle3dPoint

   ---------
   author : David Legland
   INRA - TPV URPOI - BIA IMASTE
   created the 21/02/2005

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function theta = circle3dPosition(point, circle)
0002 %CIRCLE3DPOSITION Return the angular position of a point on a 3D circle.
0003 %
0004 %   POS = circle3dPosition(POINT, CIRCLE)
0005 %   Returns angular position of point on the circle, in degrees, between 0
0006 %   and 360.
0007 %   with POINT: [xp yp zp]
0008 %   and CIRCLE: [X0 Y0 Z0 R THETA PHI] or [X0 Y0 Z0 R THETA PHI PSI]
0009 %   (THETA being the colatitude, and PHI the azimut)
0010 %
0011 %   See also:
0012 %   circles3d, circle3dOrigin, circle3dPoint
0013 %
0014 %   ---------
0015 %   author : David Legland
0016 %   INRA - TPV URPOI - BIA IMASTE
0017 %   created the 21/02/2005
0018 %
0019 
0020 %   HISTORY
0021 %   27/06/2007: change 3D angle convention
0022 %   2011-06-21 use degrees for angles
0023 
0024 
0025 % get center and radius
0026 xc = circle(:,1);
0027 yc = circle(:,2);
0028 zc = circle(:,3);
0029 
0030 % get angle of normal
0031 theta   = circle(:,5);
0032 phi     = circle(:,6);
0033 
0034 % find origin of the circle
0035 ori     = circle3dOrigin(circle);
0036 
0037 % normal vector of the supporting plane (cartesian coords)
0038 vn      = sph2cart2d([theta phi]);
0039 
0040 % create plane containing the circle
0041 plane   = createPlane([xc yc zc], vn);
0042 
0043 % find position of point on the circle plane
0044 pp0     = planePosition(ori,    plane);
0045 pp      = planePosition(point,  plane);
0046 
0047 % compute angles in the planes
0048 theta0  = mod(atan2(pp0(:,2), pp0(:,1)) + 2*pi, 2*pi);
0049 theta   = mod(atan2(pp(:,2), pp(:,1)) + 2*pi - theta0, 2*pi);
0050 
0051 % convert to degrees
0052 theta = theta * 180 / pi;

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019