Can someone suggest the best way to plot a directional 2D equilateral triangle?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to write some simple code that will plot a 2D equilateral triangle, with the triangle center specified at a distance from an existing equilateral triangle, which is pointing at it? Any help offered would be greatly appreciated.
0 commentaires
Réponses (2)
DGM
le 14 Avr 2021
This is incomplete, but it should be a start.
r=10; % triangle radius
p0=[0 0]; % prior point [x,y]
p=[50 50]; % current point [x,y]
% offset angle based on distance vector
% this may already be known from prior triangle orientation
th=atan2d(p(2)-p0(2),p(1)-p0(1))+180;
% calculate vertex locations
xv=r*cosd(th+[0 120 240 0]) + p(1);
yv=r*sind(th+[0 120 240 0]) + p(2);
% plot this triangle
plot(xv,yv)
xlim([0 100])
ylim([0 100])
axis equal
0 commentaires
Voir également
Catégories
En savoir plus sur Triangulation Representation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!