Draw a polygon from line equation

  • MATLAB
  • Thread starter minhduc515
  • Start date
  • Tags
    Line Polygon
In summary, the conversation is about how to use MATLAB to draw a quadrilateral using line equations. The suggestion is to plot the lines and find the intersection points, or solve for the coordinates of the vertices and draw the lines between them. The speaker also mentions using the solve function to find the intersection points.
  • #1
minhduc515
12
1
I'm trying to draw a quadrilateral in matlab. I has 4 line equations.
Can i draw that polygon, using line equations ? I knew MATLAB can draw polygon from coordinates, but i don't want to use it.
 
Physics news on Phys.org
  • #2
You're saying that you want to draw a quadrilateral, and you have the equations of the four sides. Then just plot those lines, and they should intersect to give you the quadrilateral. Use the plot or fplot functions to plot the lines. Remember to use hold on between drawing the graphs.
 
  • #3
Yes, i tried, but i don't want to have leftovers between two lines
 
  • #4
minhduc515 said:
Yes, i tried, but i don't want to have leftovers between two lines
Are you saying that you don't want the sides be extended? In that case, you'll have to solve two equations at a time and find the coordinates of the four vertices. Then draw the lines from one vertex to the other, i.e. range ##x## from one vertex to the other, find ##y## for intermediate points, and plot.If you give the four equations, I can help you start.
 
  • Like
Likes minhduc515
  • #5
This is my polygon. a,b,Z are constants
I think it's hard to find intersect between lines, so it's the reason why i don't want using coordinates to plot
240772
 
  • #6
minhduc515 said:
This is my polygon. a,b,Z are constants
I think it's hard to find intersect between lines, so it's the reason why i don't want using coordinates to plot
Two small questions: 1. One axis is X, the other is y or R? 2. Is everything other than x and you a constant (including z)?
 
  • Like
Likes minhduc515
  • #7
1. One axis is X, the other is R
2. Z, b and a are constant
 
  • Like
Likes Wrichik Basu
  • #8
minhduc515 said:
I think it's hard to find intersect between lines
Finding the intersection between two lines is just a matter of solving a trivial linear system ...
 
  • #9
Orodruin said:
Finding the intersection between two lines is just a matter of solving a trivial linear system ...
And it can be done using solve function.

To the OP: that's what you have to do. I can't connect to MATLAB currently from my phone (I have poor network), so I cannot try at this moment. Your variables are ##x## and ##R##. Use the above function to solve the equations.
 
  • Like
Likes minhduc515

1. How do I convert a line equation into a polygon?

To convert a line equation into a polygon, you will need to plot several points on the line. These points will serve as the vertices of the polygon. Once you have plotted enough points, you can connect them to form the polygon.

2. What is the equation for a straight line?

The equation for a straight line is y = mx + b, where m is the slope of the line and b is the y-intercept. In the context of drawing a polygon, the slope and y-intercept will determine the direction and starting point of the line.

3. How many points do I need to draw a polygon from a line equation?

You will need at least three points to draw a polygon from a line equation. These points should be evenly spaced along the line and will serve as the vertices of the polygon.

4. Can I use any line equation to draw a polygon?

No, not all line equations can be used to draw a polygon. The equation should represent a straight line, and the slope and y-intercept should result in a line that forms a closed shape when connected with points.

5. Is there a specific order in which I should plot the points for a polygon from a line equation?

Yes, the order of the points is important when drawing a polygon from a line equation. The points should be plotted in a counter-clockwise or clockwise direction to ensure the line segments connect to form a closed shape.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
6
Views
885
  • General Math
Replies
2
Views
1K
  • New Member Introductions
Replies
1
Views
63
  • Linear and Abstract Algebra
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Replies
10
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
976
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
928
  • Calculus and Beyond Homework Help
Replies
4
Views
2K
Back
Top