function B = randompolyori (N,T) % RANDOMPOLYORI Creates random polygon orientations in Partiview format % In Partiview, a polygon in a plane defined by orthonormal vectors % u,v in R^3 is represented by the 1x6 vector [u(1) u(2) u(3) v(1) v(2) v(3)] % % B = randompolyori (N,T) % full version % B = randompolyori (N) % T is 1000. This is the most common option. % B = randompolyori () % returns a 1x6 vector with one random orientation. % % N is a positive integer (default = 1) % T is a positive integer (default = 1000) % % B is a N x 6 matrix with each row having % 6 values representing a random orientation % % Especially if N is large, it may not be necessary to generate % N random orientations. Thus T are generated, and then % repeated (about) N/T times. % % Dinoj Surendran dinoj@cs.uchicago.edu (28 Feb 04) if nargin < 1, N=1; end; if nargin < 2, T=1000; end; for r = 1 : min (T,N) a = orth(rand(3,3)); B (r,1:6) = [a(:,1)' a(:,2)']; end if N > T B = repmat (B,ceil(N/T),1); end; B = B (1:N,:); % rem: to add this to a P x Q matrix R repesentnig a speck file, use % R = horzcat ( R, randompolyori(P) );