Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions core/utils/octave_only/builtin/camproj.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
function camproj()
%Undocumented Utility Function
function varargout = camproj(varargin)
%Set or get camera projection mode (Octave stub)
%
% SYNOPSIS:
% camproj('perspective')
% camproj('orthographic')
% mode = camproj()
%
% DESCRIPTION:
% Octave-compatible stub for camproj. This function provides basic
% compatibility but does not actually change the camera projection in
% Octave, as this feature is not fully supported. The function silently
% accepts the commands without error to allow scripts to run.
%
% NOTE:
% In Octave, perspective vs orthographic projection may not be fully
% supported or may behave differently than in MATLAB. This stub allows
% code to run without errors, but visual output may differ.

%{
Copyright 2009-2024 SINTEF Digital, Mathematics & Cybernetics.
Expand All @@ -20,5 +36,12 @@ This file is part of The MATLAB Reservoir Simulation Toolbox (MRST).
along with MRST. If not, see <http://www.gnu.org/licenses/>.
%}

warning("camproj not implemented in octave")
% Silently accept the command
% In Octave, camera projection mode is not fully implemented
% This stub allows scripts to run without errors

if nargout > 0
% If output is requested, return 'orthographic' as default
varargout{1} = 'orthographic';
end
end
101 changes: 98 additions & 3 deletions core/utils/octave_only/builtin/makehgtform.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
function makehgtform()
%Undocumented Utility Function
function T = makehgtform(varargin)
%Create 4x4 transformation matrix for graphics
%
% SYNOPSIS:
% T = makehgtform('xrotate', angle)
% T = makehgtform('yrotate', angle)
% T = makehgtform('zrotate', angle)
%
% DESCRIPTION:
% Octave-compatible implementation of makehgtform for basic rotations.
% Creates a 4x4 homogeneous transformation matrix for graphics objects.
%
% PARAMETERS:
% 'xrotate', angle - Rotation around X-axis by angle (in radians)
% 'yrotate', angle - Rotation around Y-axis by angle (in radians)
% 'zrotate', angle - Rotation around Z-axis by angle (in radians)
%
% RETURNS:
% T - 4x4 homogeneous transformation matrix

%{
Copyright 2009-2024 SINTEF Digital, Mathematics & Cybernetics.
Expand All @@ -20,5 +37,83 @@ This file is part of The MATLAB Reservoir Simulation Toolbox (MRST).
along with MRST. If not, see <http://www.gnu.org/licenses/>.
%}

error('toimplement')
% Initialize as identity matrix
T = eye(4);

% Process arguments
i = 1;
while i <= length(varargin)
arg = varargin{i};

if ischar(arg)
switch lower(arg)
case 'xrotate'
if i+1 <= length(varargin)
angle = varargin{i+1};
T = T * xrotation_matrix(angle);
i = i + 2;
else
error('makehgtform:MissingAngle', ...
'xrotate requires an angle argument');
end

case 'yrotate'
if i+1 <= length(varargin)
angle = varargin{i+1};
T = T * yrotation_matrix(angle);
i = i + 2;
else
error('makehgtform:MissingAngle', ...
'yrotate requires an angle argument');
end

case 'zrotate'
if i+1 <= length(varargin)
angle = varargin{i+1};
T = T * zrotation_matrix(angle);
i = i + 2;
else
error('makehgtform:MissingAngle', ...
'zrotate requires an angle argument');
end

otherwise
error('makehgtform:UnsupportedTransform', ...
'Transformation ''%s'' not implemented in Octave version', arg);
end
else
error('makehgtform:InvalidArgument', ...
'Expected string transformation type');
end
end
end

function T = xrotation_matrix(angle)
% Rotation around X-axis
c = cos(angle);
s = sin(angle);
T = [1, 0, 0, 0;
0, c, -s, 0;
0, s, c, 0;
0, 0, 0, 1];
end

function T = yrotation_matrix(angle)
% Rotation around Y-axis
c = cos(angle);
s = sin(angle);
T = [ c, 0, s, 0;
0, 1, 0, 0;
-s, 0, c, 0;
0, 0, 0, 1];
end

function T = zrotation_matrix(angle)
% Rotation around Z-axis
c = cos(angle);
s = sin(angle);
T = [c, -s, 0, 0;
s, c, 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
end