Skip to content

Conversation

@gilbertogalvis
Copy link
Contributor

@gilbertogalvis gilbertogalvis commented Oct 22, 2021

Originally this issue #430 had problems with making MATLAB quiver3 work for multiple axes. That problem was easy to fix. However, testing several examples with quiver3 I realized that the barb of the arrows did not work well in 3D. The barb of the 2D arrows did, but the 3D case did not.

The structure that MATLAB returns when using quiver and quiver3 does not return the barb coordinates of the arrows, it only returns the initial and final coordinates for each arrow. Therefore, the calculation of the barb coordinates must be done manually. Doing this in the 2D case is very simple, but in the 3D case it is a very complex geometric problem. For this reason doing this update took time.

Fortunately I managed to figure out everything I needed by completely recoding the updateQuiver.m file. Now the quiver and quiver3 functions work great for all cases. Also, I took the opportunity to fix the code style.

Below I share examples

Example 1

tiledlayout(1,2)

% Left plot
ax1 = nexttile;
quiver3(ax1,X,Y,Z1,U1,V1,W1)
axis equal
title(ax1,'Left Plot')

% Right plot
ax2 = nexttile;
quiver3(ax2,X,Y,Z2,U2,V2,W2)
axis equal
title(ax2,'Right Plot')

fig2plotly(gcf);

Screen Shot 2021-10-22 at 11 07 13 AM

Example 2

tiledlayout(2,2)

% Left plot
ax1 = nexttile;
quiver3(ax1,X,Y,Z1,U1,V1,W1)
axis equal
title(ax1,'Left Plot')

% Right plot
ax2 = nexttile;
quiver3(ax2,X,Y,Z2,U2,V2,W2)
axis equal
title(ax2,'Right Plot')

ax3 = nexttile;
quiver3(ax3,X,Y,Z2,U2,V2,W2)
axis equal
title(ax3,'Right Plot')

ax4 = nexttile;
quiver3(ax4,X,Y,Z1,U1,V1,W1)
axis equal
title(ax4,'Left Plot')

fig2plotly(gcf);

Screen Shot 2021-10-22 at 11 07 39 AM

Example 3

tiledlayout(1,2)

% Left plot
ax1 = nexttile;
quiver3(ax1,X,Y,Z1,U1,V1,W1)
axis equal
title(ax1,'Left Plot')

% Right plot
ax2 = nexttile;
quiver(ax2,X,Y,U2,V2)
axis equal
title(ax2,'Right Plot')

quiver(X,Y,U1,V1)
axis equal
title('Left Plot')

fig2plotly(gcf);

Screen Shot 2021-10-22 at 11 08 50 AM

Example 4

tiledlayout(2,2)

% Left plot
ax1 = nexttile;
quiver3(ax1,X,Y,Z1,U1,V1,W1)
axis equal
title(ax1,'Left Plot')

% Right plot
ax2 = nexttile;
quiver3(ax2,X,Y,Z2,U2,V2,W2)
axis equal
title(ax2,'Right Plot')

ax3 = nexttile;
quiver(ax3,X,Y,U2,V2)
axis equal
title(ax3,'Right Plot')

ax4 = nexttile;
quiver(ax4,X,Y,U1,V1)
axis equal
title(ax4,'Left Plot')

fig2plotly(gcf);

Screen Shot 2021-10-22 at 11 09 15 AM

@gilbertogalvis gilbertogalvis merged commit 01679c4 into master Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants