Code covered by the BSD License  

Highlights from
Matlab Offscreen Rendering Toolbox

image thumbnail
from Matlab Offscreen Rendering Toolbox by Tianli Yu
Project 3D mesh onto image using off screen OpenGL rendering, determine face color, visibilty, etc.

Vector2CamS1(ViewPointV, LookAtV, UpV, fcV, ccV)
%% Wish 1:	construct the matlab camera parameter from different vectors

function CamParamS = Vector2CamS1(ViewPointV, LookAtV, UpV, fcV, ccV)

	CamParamS.fcV = fcV;
	CamParamS.ccV = ccV;
	
	%% construct the rotation matrix, assume LookAtV and UpV are normalized
	CamParamS.RcM = zeros(3, 3);
	CamParamS.RcM(3, :) = LookAtV';
	CamParamS.RcM(1, :) = cross(LookAtV, UpV)';
	CamParamS.RcM(1, :) = CamParamS.RcM(1, :) / norm(CamParamS.RcM(1, :));
	
	CamParamS.RcM(2, :) = cross(LookAtV, CamParamS.RcM(1, :)')';
	CamParamS.RcM(2, :) = CamParamS.RcM(2, :) / norm(CamParamS.RcM(1, :));

	%% the TcV
	CamParamS.TcV = - CamParamS.RcM * ViewPointV;

Contact us at files@mathworks.com