Matlab code of shape

Hello, could you assist me in plotting this figure in MATLAB, taking into account that only the theta angle is known.

5 commentaires

Dyuman Joshi
Dyuman Joshi le 6 Jan 2024
Only the theta angle is known? Then there are infinite possible quadrilaterals for that configuration. Which one do you want to make?
If you are expecting to make a particular shape, you will have to provide specifc information related to that.
Walter Roberson
Walter Roberson le 6 Jan 2024
(The infinite possible quadrilaterals are because the length of the sides are not determined.)
rosee
rosee le 6 Jan 2024
Thank you for your advice, it works like a rhombus, with equal sides.
rosee
rosee le 6 Jan 2024
Can you help me find the vertices using a side and theta?
Image Analyst
Image Analyst le 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?

Connectez-vous pour commenter.

Réponses (2)

Walter Roberson
Walter Roberson le 6 Jan 2024

0 votes

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 commentaires

Image Analyst
Image Analyst le 6 Jan 2024
You can use plot or line
DGM
DGM le 7 Jan 2024
Modifié(e) : DGM le 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 le 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.

Connectez-vous pour commenter.

DGM
DGM le 7 Jan 2024
Modifié(e) : DGM le 7 Jan 2024

0 votes

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 commentaires

rosee
rosee le 8 Jan 2024
Hello, thank you for your assistance. Are there specific conditions that should be applied to remove the specified parts?
DGM
DGM le 8 Jan 2024
That's a question for you. The answer I gave above is clearly working partially on guesswork because there is still an incomplete description of the task. Even now, my assumptions have not been confirmed. I can't tell you if you want to do a certain thing. It's up to you to tell me what you want.
Consider two assumptions I've made:
  • the given angles are those between the chord lines, not the tangent lines
  • that R is a given parameter and not otherwise derived from some yet undescribed information
If either of those are not what you need, then the answer above and any answer to the question you just asked will be wrong.
Again, assuming that we're even talking about the same thing, the shape will be self-intersecting if the included angle of the arc (a) is larger than the smallest of the interior angles between chord lines.
isintersecting = a > min([th 180-th])
Whether that should be treated as a constraint on R, L or th is unknown, since we don't know which should take precedence. We don't even know if R is given.
rosee
rosee le 8 Jan 2024
Thank you very much, the only information I have is the angle and diameter that I marked on the figure.
DGM
DGM le 8 Jan 2024
Modifié(e) : DGM le 8 Jan 2024
What are you asking? What does this image mean? Are you asking to find the distance between intersections? Again, is the marked angle the half-angle between the chords or the tangents?
I don't even know if you're asking about finding information about the generated shape, or if you're changing the parameters used to define the shape in the first place because the original problem statement still hasn't been confirmed.
I gave you the limiting relationship for self-intersection:
isintersecting = a > min([th 180-th])
So from that relationship,
% minimum R for given L,th
Rmin = L/(2*sind(min([th 180-th])/2))
% maximum L for given R,th
Lmax = 2*R*sind(min([th 180-th])/2)
% allowable range of th for given R,L
thrange = sort([a 180-a])
This means that you'd be mistaken to think that there might be two points of potential self-intersection. There might be zero or two. There might also be four -- or only one.
Do with that what you will. Other than the plotting, this exercise -- whatever it actually is -- is just a bunch of basic trigenometry. Get a pencil and paper and work out the diagrams.
rosee
rosee le 8 Jan 2024
Thank you very much, I tried applying the condition to the shape but it didn't change.
DGM
DGM le 8 Jan 2024
Modifié(e) : DGM le 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)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange

Question posée :

le 6 Jan 2024

Modifié(e) :

DGM
le 8 Jan 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by