image thumbnail
from Forming ray lines for plots by Michael Chan
The objective is to construct different line beams.

rayLinesScheme_parallel (numberOfLines, ...
function [x y numberOfLines_total totalNumberOfBeamSets] = rayLinesScheme_parallel (numberOfLines, ...
    upperBound, lowerBound, degreeStepSize, ...
    centerShiftedBy_x, centerShiftedBy_y, ... % centroid of parallel beams
    rangeForXandY)
% 
% upperBound = 3;
% lowerBound = -3;

% numberOfLines = 10;
stepSize = (upperBound - lowerBound)/numberOfLines;
rangeForXandY = lowerBound:stepSize:upperBound;
c = rangeForXandY;

% random ray lines Scheme
% numberOfLines = length(c); % 2500;

x = rangeForXandY;

  % degreeStepSize = 5;
  degreeRanges = 0:degreeStepSize:360;  % rotation
  radianRanges = degreeRanges*(pi/180);
  gradient = tan(radianRanges);
  numberOfRotations = length(degreeRanges);

  gradient_X = tan(15*(pi/180));
  
%for j = 1:numberOfRotations
% construct the array of parallel lines (1 set)
   for i = 1:numberOfLines
      y(i,:) = (gradient_X*x(i)) + c;
   end
   
   % degreeStepSize = 10;
   degree_angle_range = degreeRanges;
   % center = [0 0];
   center = [centerShiftedBy_x centerShiftedBy_y];
   numberOfSetsOfLineArray = length(degree_angle_range);
   
   parallelLineArraySetsCollection = [];
   count = 0;
   
    for ang = degree_angle_range
        for i =   1:numberOfLines % per set
            coord = [x' y(i,:)'];
   
            lineRotated = rotateCoordinates(coord, center, ang);            
            % hold off;
            plot(coord(:,1),coord(:,2),'b*-');
            axis([lowerBound upperBound lowerBound upperBound]);            
            hold on;
            plot(lineRotated(:,1), lineRotated(:,2),'r+-');
            
            count = count + 1;
            % parallelLineArraySetsCollection = [parallelLineArraySetsCollection; lineRotated(:,1), lineRotated(:,2)];
            parallelLineArraySetsCollection(count,:) = lineRotated(:,2);                      
            x_new(count,:) = lineRotated(:,1);
            
            % plot(center(1),center(2),'xk');
            
        end
            pause(0.3);
            % close;
    end
    
    title('Clockwise by degrees');
    
    %close all;
    %plot(parallelLineArraySetsCollection(:,1), parallelLineArraySetsCollection(:,2));
    
%     x = parallelLineArraySetsCollection(:,1);
%     y = parallelLineArraySetsCollection(:,2);

    x = x_new;
    y = parallelLineArraySetsCollection;
    
    numberOfLines_total = numberOfLines*count;
    
    % Caveat: For plotting outside the function, total number of sets is required
    % to assist in breaking the [x y] into groups of sets
    totalNumberOfBeamSets = length(degree_angle_range);
    
 %fprintf('Lines done (percentage) : %s %%\n', num2str((i/numberOfLines)*100));
%  figure,
%     plot(x, y, '--');               % plot lines
%     axis([lowerBound upperBound lowerBound upperBound]);
%     grid on;
%     pause (0.5);
%     close all;
%end


end


Contact us