Home > General-Functions > SUGR > Homography_2D > sugr_distance_angular_2D.m

sugr_distance_angular_2D

PURPOSE ^

% Angular distance of two 2D entities

SYNOPSIS ^

function distance = sugr_distance_angular_2D(a, b)

DESCRIPTION ^

% Angular distance of two 2D entities

 distance = sugr_distance_angular_2D(a,b)

 *       'Point_2D'+'Point_2D'
 *       'Point_2D'+'Line_2D'
 *       'Line_2D'+'Point_2D'

 TODO: sugr_distance_Euclidean_2D 'Line_2D'+'Line_2D' if parallel

 distance.a  = angular distance

 distance.sa = standard deviation of angular distance

 distance.dof = degrees of freedom = 1

 if distance = 0 -> dof =-1

 Wolfgang Förstner
 wfoerstn@uni-bonn.de

 wf 2/2011

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Angular distance of two 2D entities
0002 %
0003 % distance = sugr_distance_angular_2D(a,b)
0004 %
0005 % *       'Point_2D'+'Point_2D'
0006 % *       'Point_2D'+'Line_2D'
0007 % *       'Line_2D'+'Point_2D'
0008 %
0009 % TODO: sugr_distance_Euclidean_2D 'Line_2D'+'Line_2D' if parallel
0010 %
0011 % distance.a  = angular distance
0012 %
0013 % distance.sa = standard deviation of angular distance
0014 %
0015 % distance.dof = degrees of freedom = 1
0016 %
0017 % if distance = 0 -> dof =-1
0018 %
0019 % Wolfgang Förstner
0020 % wfoerstn@uni-bonn.de
0021 %
0022 % wf 2/2011
0023 
0024 function distance = sugr_distance_angular_2D(a, b)
0025 
0026 global Threshold_Euclidean_Normalization
0027 
0028 pair = strcat(num2str(a.type), num2str(b.type));
0029 
0030 distance.dof = 1;
0031 
0032 if norm(a.h - b.h) > Threshold_Euclidean_Normalization
0033     switch pair
0034         case '11'
0035             Cahh = sugr_get_CovM_homogeneous_Vector(a);
0036             Cbhh = sugr_get_CovM_homogeneous_Vector(b);
0037         case '12'
0038             Cahh = sugr_get_CovM_homogeneous_Vector(a);
0039             Cbhh = sugr_get_CovM_homogeneous_Vector(b);
0040         case '21'
0041             Cahh = sugr_get_CovM_homogeneous_Vector(a);
0042             Cbhh = sugr_get_CovM_homogeneous_Vector(b);
0043         case '22'
0044             Cahh = sugr_get_CovM_homogeneous_Vector(a);
0045             Cbhh = sugr_get_CovM_homogeneous_Vector(b);
0046     end
0047     ncab = norm(cross(a.h, b.h));         % norm crossproduct
0048     ipab = a.h'*b.h;                      % inner product
0049  
0050     angle = atan2(ncab, ipab);            % angle
0051     distance.a = angle;
0052  
0053     ja = (ipab * a.h'-b.h') / ncab; % Jacobian angle --> a.h
0054     jb = (ipab * b.h'-a.h') / ncab; % Jacobian angle --> b.h
0055  
0056     distance.sa = sqrt(ja * Cahh * ja' + jb * Cbhh * jb');
0057 else
0058     distance.a = 0;
0059     distance.sa = 0;
0060     distance.dof = - 1;
0061 end
0062

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005