%% Data generation
clear all; close all
cdef = obtainCrystal('generic_potash_alum', 5)
dec = obtainDec(cdef.A, 'mapping', cdef.groupMappingMatrix)
hrep.A  =cdef.A;

%% experimenting
% clc; close all
% figure,hold on
% viewPolytope(struct('A', dec.validityCone.A, 'h', dec.validityCone.h), ...
%     'infinityBoxSize', 3);
% originalHc = [1 3 3];
% thisHc = [0 0 0];
% hcMapped = originalHc;
% plot3(originalHc(1), originalHc(2), originalHc(3), 'rx')
% while any((thisHc -hcMapped) ~= 0)
%     thisHc = hcMapped
%     hcMapped = mapToValidConeDec(thisHc, dec, 1e-10)'
%     %hrep.h = cdef.groupMappingMatrix * hCmapped;
%     %viewPolytope(hrep)
%     (dec.validityCone.A * thisHc')' > 0
%     %length(find(((dec.validityConeOriginal.A * dec.mappingFullToReduced') * thisHc')' > 1e-10))
%     %length(find((dec.validityConeOriginal.A * (dec.mappingReducedToFull * thisHc'))' > 1e-10))
%     plot3(hcMapped(1), hcMapped(2), hcMapped(3), 'bx')
% end

%% experimenting
clc; close all;
continueFlag = 1;
while continueFlag
    figure,hold on
    thisHc = [1 1 1] + [0 rand*10*[1 1]]
    hcMapped = mapToValidConeDec(thisHc, dec)'
    
    hrep.h = cdef.groupMappingMatrix * thisHc';
    viewPolytope(hrep)
    
    hrep.h = cdef.groupMappingMatrix * hcMapped';
    viewPolytope(hrep)
    
    continueFlag = input('Continue (1) or exit (0): ');
end