Customized 3D vector representation
5 views (last 30 days)
Show older comments
Hello everyone
I was wondering if it would be possible to customize the way in which the directionality of a three-dimensional vector is represented in MatLab, in such a way that the arrow has volume and presents a sphere at half its length, as in this image, which is shown can be found in the paper Domain wall dynamics in two-dimensional van der Waals ferromagnets
and that if I recall correctly has been done with povray.
0 Comments
Accepted Answer
Matt J
on 6 Feb 2024
Edited: Matt J
on 6 Feb 2024
The graphical element you describe can be created from a combination of a cylinder (the shaft of the arrow), a cone (the head of the arrow) and a sphere. All 3 can be co-plotted using a very simple interface with this FEX package:
Below is an example specific to your goals. Note that once you have the vector H of graphics handles, you can use hgtransform to re-position, resize, and re-orient the arrow to your liking.
[shaftCenter,shaftRadius,shaftHeight]=...
deal([0 0 0], 0.2, 10); %Arrow shaft parameters
[headTip,headAngle,headHeight]=...
deal([1.1*shaftHeight/2,0,0], 30, shaftHeight/6); %Arrow head parameters
[sphereCenter,sphereRadius]=deal([0,0,0], shaftHeight/12); %Sphere parameters
Shaft=cylindricalFit.groundtruth([],shaftCenter,shaftRadius,shaftHeight,[0,0]); %Data-less ground truth objects
Head=rightcircularconeFit.groundtruth([],headTip,headAngle,headHeight,[180,0]);
Sphere=sphericalFit.groundtruth([], sphereCenter,sphereRadius);
figure
hold on
H(1)=plot(Shaft,{'FaceAlpha',1});
H(2)=plot(Head,{'FaceAlpha',1});
H(3)=plot(Sphere,{'FaceAlpha',1});
view(-50,30)
hold off
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!