Add octave github action

fixes-turtlebasket
Mattia Montanari 2023-02-14 15:05:20 +01:00
parent b4de1e3a72
commit 9876960d08
3 changed files with 44 additions and 49 deletions

View File

@ -23,3 +23,11 @@ jobs:
with: with:
go-version: 1.15 go-version: 1.15
- run: cd examples/go/openGJK && go build && go test -v - run: cd examples/go/openGJK && go build && go test -v
Run_Octave_example:
runs-on: ubuntu-latest
container: gnuoctave/octave:7.3.0
steps:
- name: Check out repository code
uses: actions/checkout@v3
- run: cd examples/matlab/; run runme.m

View File

@ -32,31 +32,33 @@ B = -A;
dist = openGJK( A, B ); dist = openGJK( A, B );
fprintf('The minimum distance between A and B is %.2f\n',dist); fprintf('The minimum distance between A and B is %.2f\n',dist);
% VISUALISE RESULTS % VISUALISE RESULTS ONLY IN MATLAB
% .. create new figure if(exist('OCTAVE_VERSION', 'builtin') == 0)
figure('units','centimeters', 'WindowStyle','normal', 'color','w',... % .. create new figure
'Position',[0 8.5 9 6],'defaultAxesColorOrder',parula,... figure('units','centimeters', 'WindowStyle','normal', 'color','w',...
'Renderer','opengl') 'Position',[0 8.5 9 6],'defaultAxesColorOrder',parula,...
% .. adjust properties 'Renderer','opengl')
axis equal tight off; hold all; % .. adjust properties
% .. display body A axis equal tight off; hold all;
DT = delaunayTriangulation(A'); % .. display body A
[K,~] = convexHull(DT); DT = delaunayTriangulation(A');
trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),... [K,~] = convexHull(DT);
'EdgeColor','none','FaceColor',[.4 1 .9 ],... trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),...
'FaceLighting','flat' ) 'EdgeColor','none','FaceColor',[.4 1 .9 ],...
% .. display body B 'FaceLighting','flat' )
DT = delaunayTriangulation(B'); % .. display body B
[K,~] = convexHull(DT); DT = delaunayTriangulation(B');
trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),... [K,~] = convexHull(DT);
'EdgeColor','none','FaceColor',[.4 1 .8 ],... trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),...
'FaceLighting','flat' ) 'EdgeColor','none','FaceColor',[.4 1 .8 ],...
% .. represent the computed distance as a sphere 'FaceLighting','flat' )
[x,y,z] = sphere(100); % .. represent the computed distance as a sphere
surf(x.*dist/2,y.*dist/2,z.*dist/2,'facecolor',[.9 .9 .9],... [x,y,z] = sphere(100);
'EdgeColor','none','FaceLighting','flat','SpecularColorReflectance',0,... surf(x.*dist/2,y.*dist/2,z.*dist/2,'facecolor',[.9 .9 .9],...
'SpecularStrength',1,'SpecularExponent',10,'facealpha',.7) 'EdgeColor','none','FaceLighting','flat','SpecularColorReflectance',0,...
% ... adjust point of view 'SpecularStrength',1,'SpecularExponent',10,'facealpha',.7)
view(42,21) % ... adjust point of view
% ... add light view(42,21)
light('Position',[5 -10 20],'Style','local'); % ... add light
light('Position',[5 -10 20],'Style','local');
end

View File

@ -29,35 +29,20 @@ else
optflug = '-O'; optflug = '-O';
end end
% SELECT SILET COMPILATION MODE. % SELECT SILET COMPILATION MODE.
if 1 if 1
silflag = '-silent'; silflag = '-silent';
else else
silflag = '-v'; silflag = '-v';
end end
% TRY COMPILING MEX FILE % COMPILE MEX FILE
fprintf('Compiling mex function... ') mex(fullfile('..','..','openGJK.c'),...
try
mex(fullfile('..','..','openGJK.c'),... % Source of openGJK
'-largeArrayDims', ... % Support large arrays '-largeArrayDims', ... % Support large arrays
optflug, ... % Compiler flag for debug/optimisation optflug, ...
fullfile('-I','..','..','include'),... % Folder to header files ['-I',fullfile('..','..','include')],... % Folder to header files
'-outdir', pwd, ... % Ouput directory for writing mex function
'-output', 'openGJK',... % Name of ouput mex file '-output', 'openGJK',... % Name of ouput mex file
'-DMATLAB_MEX_BUILD',... % Define variable for mex function in source files '-DMATLAB_MEX_BUILD',... % Define variable for mex function in source files
silflag ) % Silent/verbose flag silflag )
% File compiled without errors. Return path and name of mex file
fprintf('completed!\n')
fprintf('The following mex file has been generated:')
fprintf('\t%s\n',[pwd,filesep,'openGJK.',mexext])
catch
% Build failed, refer to documentation
fprintf('\n\n ERROR DETECTED! Mex file cannot be compiled.\n')
fprintf('\tFor more information, see ')
fprintf('<a href="http://www.mathworks.com/help/matlab/ref/mex.html">this documentation page</a>.\n\n')
return
end
% RUN EXAMPLE % RUN EXAMPLE
fprintf('Running example... ') fprintf('Running example... ')