Matlab code of shape

7 views (last 30 days)
rosee
rosee on 6 Jan 2024
Edited: DGM on 8 Jan 2024
Hello, could you assist me in plotting this figure in MATLAB, taking into account that only the theta angle is known.
  5 Comments
rosee
rosee on 6 Jan 2024
Can you help me find the vertices using a side and theta?
Image Analyst
Image Analyst on 7 Jan 2024
Why? Why do you want to do this? What is the context? For example, is it your homework you're asking us to do for you, or some real world application? Why do you need this?

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 6 Jan 2024
Apply some elementary trig.
Angle = theta/2 --> known
L = length of side --> known
x/L = sin(Angle)
y/L = cos(Angle)
x = L * sin(Angle)
y = L * cos(Angle)
So you draw from (0,0) to (x,y), and draw down again to (2*x,0)
  3 Comments
DGM
DGM on 7 Jan 2024
Edited: DGM on 7 Jan 2024
@SAAAA So let me get this straight. You and @rosee apparently have the same task, but neither of you understand that you're the ones that have all the information about the thing you need to do.
The original question asked for an infinite family of parallelograms. Saying that they're not even polygons makes the problem definition even less specific.
You have a shape with four vertices. At first it was a polygon, but now it's not. Or maybe it still is, who knows?
If the sides are curved, then how are they curved? Are they strictly circular arcs? Cubics? Something else? In any case, what information defines the side? Its chord length? Arc length? Are multiple parameters required? Are some assumed?
Is it safe to assume the part is symmetric? Is there location/scale/rotation information? Is some of that also assumed?
It's up to you to communicate your needs. Put together the information that you have about the task and use that to build a description of the task as you understand it.
rosee
rosee on 7 Jan 2024
I have a shape with the curvature of a circle, the chords of these circles are equal and you can connect them to form a rhombus, it is also symmetrical.

Sign in to comment.


DGM
DGM on 7 Jan 2024
Edited: DGM on 7 Jan 2024
So the inputs are:
  • the chord length L (they're all equal)
  • one of the interior angle pairs
I choose to assume that the given angles are the angles between the chord lines, and not the angles between the tangent lines. This leaves us needing some way to define the curvature of the arcs, so I will assume that we also are given some radius of curvature R such that 2*R >= L.
I will assume that the object is centered at the origin, and that the given interior angles are those corresponding to the "rhombus" vertices which lie along y=0.
It should be noted that none of this ensures that the shape is not self-intersecting.
There's probably a smarter way to construct this, but I'm just going to do something naive.
% parameters
L = 1; % chord length
th = 60; % selected interior angle (degrees)
R = 0.75; % radius of curvature
n = 100; % number of points per arc
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if R < L/2
error('R must be at least equal to L/2')
end
% distance between the chord vertices and the origin
rx = L*cosd(th/2);
ry = L*sind(th/2);
% construct one arc section
a = 2*asind(L/(2*R)); % the included angle of the arc
a0 = -th/2 - 90 - a/2; % the arc offset angle
tharc = linspace(a0,a0 + a,n); % get one of the arcs
% convert to rectangular
xarc = R*cosd(tharc);
yarc = R*sind(tharc);
% shift the arc into the NE quadrant
xarc = flip(xarc - xarc(1));
yarc = flip(yarc - yarc(end));
% replicate to form a closed path
% i'm omitting duplicate vertices except at the end
xarc = [xarc -flip(xarc(1:end-1)) -xarc(2:end) flip(xarc(1:end-1))];
yarc = [yarc flip(yarc(1:end-1)) -yarc(2:end) -flip(yarc(1:end-1))];
% draw the chord lines
plot([rx 0 -rx 0 rx],[0 ry 0 -ry 0],'--'); hold on
% draw the arcs
plot(xarc,yarc)
axis equal
grid on
I don't know if my assumptions are what you need.
  6 Comments
rosee
rosee on 8 Jan 2024
Thank you very much, I tried applying the condition to the shape but it didn't change.
DGM
DGM on 8 Jan 2024
Edited: DGM on 8 Jan 2024
I've told you enough times that I can't know what you did or what you want unless you actually say it. You're old enough that I shouldn't have needed to tell you in the first place. You need to go all the way back to the beginning, read the answer I gave, and tell me whether or not it suits your problem definition. If it does not, then you need to tell me what your problem definition actually is. Unless you do that, we're just wasting time.
I'm just going to put this here so that I can delete my notes.
% other stuff of unknown importance
thxy = [th 180-th]; % the included angles between the outer chords (x,y)
aexy = max(a - thxy,0); % the included angles of any loops (x,y)
lexy = 2*R*sind(aexy/2); % the chord length of any loops (x,y)
rixy = [rx ry] - lexy % the half-width of the shape, excluding loops (x,y)
ait2 = abs(a - thxy)/2 % the half-angle between tangents, excluding loops (x,y)

Sign in to comment.

Categories

Find more on Matrices and Arrays 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!