Home > vbmeg > functions > common > coordinate > vb_trans_fiducial_coord.m

vb_trans_fiducial_coord

PURPOSE ^

Transform matrix to fiducial coordinate

SYNOPSIS ^

function [trans_mat, marker_trans] = vb_trans_fiducial_coord(marker)

DESCRIPTION ^

 Transform matrix to fiducial coordinate

 Usage:
  trans_mat = vb_trans_fiducial_coord(marker)
  [trans_mat, marker_trans] = vb_trans_fiducial_coord(marker)
 --- Input
 Fiducial coordinate
 marker(1,:): Left ear 
 marker(2,:): Nose     
 marker(3,:): Right ear

 --- Output
 trans_mat = Rigid Body Transformation matrix  (4 x 3)
 marker_trans : transformed fiducial coordinate
 
 X_trans = vb_affine_trans(X, trans_mat)

 Origin: perpendicular to Left->Right ear line from Nose 
 X-axis: Origin -> Nose
 Y-axis: Right->Left ear line
 Z-axis: Origin -> Up

 Coordinate Transform by trans_mat
 x_trans = ( x - org_marker ) * rot
         = x*rot - org_marker*rot
         = [x, 1] * trans_mat
 trans_mat = [rot ; - org_marker*rot]        (4 x 3)

 2008-07-25 made by M. Sato

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    [trans_mat, marker_trans] = vb_trans_fiducial_coord(marker)
0002 % Transform matrix to fiducial coordinate
0003 %
0004 % Usage:
0005 %  trans_mat = vb_trans_fiducial_coord(marker)
0006 %  [trans_mat, marker_trans] = vb_trans_fiducial_coord(marker)
0007 % --- Input
0008 % Fiducial coordinate
0009 % marker(1,:): Left ear
0010 % marker(2,:): Nose
0011 % marker(3,:): Right ear
0012 %
0013 % --- Output
0014 % trans_mat = Rigid Body Transformation matrix  (4 x 3)
0015 % marker_trans : transformed fiducial coordinate
0016 %
0017 % X_trans = vb_affine_trans(X, trans_mat)
0018 %
0019 % Origin: perpendicular to Left->Right ear line from Nose
0020 % X-axis: Origin -> Nose
0021 % Y-axis: Right->Left ear line
0022 % Z-axis: Origin -> Up
0023 %
0024 % Coordinate Transform by trans_mat
0025 % x_trans = ( x - org_marker ) * rot
0026 %         = x*rot - org_marker*rot
0027 %         = [x, 1] * trans_mat
0028 % trans_mat = [rot ; - org_marker*rot]        (4 x 3)
0029 %
0030 % 2008-07-25 made by M. Sato
0031 %
0032 % Copyright (C) 2011, ATR All Rights Reserved.
0033 % License : New BSD License(see VBMEG_LICENSE.txt)
0034 
0035 Left = 1;
0036 Nose = 2;
0037 Right= 3;
0038 
0039 % Origin: perpendicular to Left->Right ear line from Nose
0040 % X-axis: Origin -> Nose
0041 % Y-axis: Right->Left ear line
0042 % Z-axis: Origin -> Up
0043 
0044 % Approximate Origin : center of left-right
0045 co  = (marker(Left,:) + marker(Right,:))/2; 
0046 
0047 % Y-axis: Right->Left ear line
0048 ey  = marker(Left,:)-marker(Right,:); 
0049 ey  = ey/sqrt(sum(ey.^2));
0050 
0051 % Approximate X-axis: center -> Nose
0052 ex0 = marker(Nose,:) - co; 
0053 
0054 % Z-axis: Origin -> Up
0055 % orthogonal to ex0 & ey
0056 ez  = cross(ex0 , ey); 
0057 ez  = ez/sqrt(sum(ez.^2));
0058 
0059 % X-axis: Origin -> Nose
0060 % orthogonal to ey & ez
0061 ex  = cross(ey,ez); 
0062 ex  = ex/sqrt(sum(ex.^2));
0063 
0064 % Rotation matrix
0065 rot = [ex(:) ey(:) ez(:)]; 
0066 
0067 % Origin : perpendicular to Left->Right ear line from Nose
0068 org_marker = sum(ex0.*ey)*ey + co; 
0069 
0070 trans_mat = [rot ; - org_marker * rot];
0071 
0072 marker_trans = [marker ones(3,1)]*trans_mat;

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005