You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: regularSO3Grid.m
    path of file: ./repos/mtex/geometry/geometry_tools
    
    the code of the file until where you have to start completion: function [SO3G,S2G,sec,angles] = regularSO3Grid(varargin)
% regular grid in Euler orientation space
%
% Syntax
%   SO3G = regularSO3Grid(cs)
%   SO3G = regularSO3Grid(cs,ss,'resolution',2.5*degree)     % specify the resolution
%   SO3G = regularSO3Grid(cs,ss,'resolution',5*degree,'ZYZ') % use ZYZ convention
%   SO3G = regularSO3Grid(cs,ss,'phi2','sections',10)        % 10 phi2 sections
%   SO3G = regularSO3Grid('ClenshawCurtis','bandwidth',64) % 
%
% Input
%  cs - @crystalSymmetry
%  ss - @specimenSymmetry
%
% Options
%  resolution - Euler angle resolution
%  sections - number of sections
%
% Flags
%  phi1 | Phi | phi2 - sections along which variable
%
% Output

    
function [SO3G,S2G,sec,angles] = regularSO3Grid(varargin)
% regular grid in Euler orientation space
%
% Syntax
%   SO3G = regularSO3Grid(cs)
%   SO3G = regularSO3Grid(cs,ss,'resolution',2.5*degree)     % specify the resolution
%   SO3G = regularSO3Grid(cs,ss,'resolution',5*degree,'ZYZ') % use ZYZ convention
%   SO3G = regularSO3Grid(cs,ss,'phi2','sections',10)        % 10 phi2 sections
%   SO3G = regularSO3Grid('ClenshawCurtis','bandwidth',64) % 
%
% Input
%  cs - @crystalSymmetry
%  ss - @specimenSymmetry
%
% Options
%  resolution - Euler angle resolution
%  sections - number of sections
%
% Flags
%  phi1 | Phi | phi2 - sections along which variable
%
% Output
%  SO3G - @orientation
%

% extract symmetry
[SRight,SLeft] = extractSym(varargin);

% get Euler angle bounds
[max_rho,max_theta,max_sec] = fundamentalRegionEuler(SRight,SLeft,varargin{:});

N = ceil(get_option(varargin,'bandwidth',256)/2);

if check_option(varargin,'GaussLegend