changeset 3:ffd7efa3e5c0

Added reverse map from information space to triangle; moved info coors to transmat window.
author samer
date Fri, 03 Feb 2012 18:08:07 +0000
parents cfdca07197b6
children 931e71c24aa3
files mt_calibrate.m mt_get_transmat_at.m mt_revmap.m mt_show_transmat.m
diffstat 4 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mt_calibrate.m	Thu Feb 02 03:12:22 2012 +0000
+++ b/mt_calibrate.m	Fri Feb 03 18:08:07 2012 +0000
@@ -12,11 +12,13 @@
 	P  = Sys.refpoints;
 	fprintf('\nCalibrating for triangle vertices at:\n'); disp(P);
 	p0 = P(:,1);
-	Sys.map = info_map_fn(p0,inv(P(:,2:3)-repmat(p0,1,2)));
+	[Sys.map, Sys.revmap] = info_map_fn(p0,P(:,2:3)-repmat(p0,1,2));
 end
 
-function f=info_map_fn(p0,M)
-	f=@(p)clip_tri(M*(p-p0));
+function [f,g]=info_map_fn(p0,M)
+	iM=inv(M);
+	f=@(p)clip_tri(iM*(p-p0));
+	g=@(p)p0+M*p;
 end
 
 function x=clip_tri(x)
--- a/mt_get_transmat_at.m	Thu Feb 02 03:12:22 2012 +0000
+++ b/mt_get_transmat_at.m	Fri Feb 03 18:08:07 2012 +0000
@@ -12,9 +12,10 @@
 % The selected transition matrix will be shown using mt_show_transmat,
 % and it's information coordinates printed in the title of the main scatter plot.
 
-function [T,I]=mt_get_transmat_at(Sys,Id,K,X,Y)
+function [T,P,I]=mt_get_transmat_at(Sys,Id,K,X,Y)
+	logK=log(K);
 	normpos = Sys.map([X;Y])';
-	target = normpos *log(K);
+	target = normpos*logK;
 	tmats = Sys.transmats{K};
 	info = Sys.info{K};
 	L = size(info,1);
@@ -30,8 +31,9 @@
 	I = info(J,:);
 	%Mask=2*int16(Mask); Mask(J)=1;
 	%set(Sys.hScat{K},'CDATA',Mask); % scatc(info,Mask,16); rotate3d on;
-	figure(Sys.fig); title(sprintf('info: %.2f, %.2f, %.2f',I(1),I(2),I(3)));
+	%figure(Sys.fig); title(sprintf('info: %.2f, %.2f, %.2f',I(1),I(2),I(3)));
 	%figure(50); title(sprintf('pos: %.2f, %.2f',normpos(1), normpos(2)));
 	%fprintf('normpos: %.2f, %.2f',normpos(1), normpos(2));
-	mt_show_transmat(Id,T);
+	mt_show_transmat(Id,T,I);
+	if nargin>1, P=Sys.revmap(I(1:2)'/logK); end
 end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mt_revmap.m	Fri Feb 03 18:08:07 2012 +0000
@@ -0,0 +1,4 @@
+% mt_revmap - Map from information space back to triangle space
+%
+% mt_revmap :: mt_system, real, real -> [[2]].
+function p=mt_revmap(sys,x,y), p=sys.revmap([x;y]); end
--- a/mt_show_transmat.m	Thu Feb 02 03:12:22 2012 +0000
+++ b/mt_show_transmat.m	Fri Feb 03 18:08:07 2012 +0000
@@ -5,7 +5,11 @@
 %    [[K,K]] ~'transition matrix'
 % -> action void.
 
-function mt_show_transmat(Id,T)
+function mt_show_transmat(Id,T,I)
 	figure(Id); 
 	imagesc(T,[0,1]); 
 	axis xy;
+	if nargin>2
+		title(sprintf('H=%.2f, R=%.2f, PI=%.2f',I(1),I(2),I(3)));
+	end
+end