Draw a polygon from line equation

  • Context: MATLAB 
  • Thread starter Thread starter minhduc515
  • Start date Start date
  • Tags Tags
    Line Polygon
Click For Summary

Discussion Overview

The discussion revolves around the challenge of drawing a quadrilateral in MATLAB using line equations rather than coordinates. Participants explore methods to plot the polygon defined by the equations of its sides while addressing concerns about line extensions and intersections.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks to draw a quadrilateral using line equations, expressing a preference against using coordinates.
  • Another participant suggests plotting the lines and using the 'hold on' command to avoid overwriting previous plots.
  • Concerns are raised about unwanted extensions of lines between intersections, prompting a discussion on solving equations to find vertices.
  • One participant mentions the difficulty of finding intersections and expresses reluctance to use coordinates for plotting.
  • Further inquiries are made about the axes and constants involved in the equations.
  • Some participants assert that finding intersections is straightforward and can be accomplished with a linear system, suggesting the use of the 'solve' function in MATLAB.

Areas of Agreement / Disagreement

Participants express differing views on the complexity of finding intersections between lines and whether to use coordinates. There is no consensus on the best approach to draw the quadrilateral.

Contextual Notes

Participants mention the need to solve equations to find vertices, but there is no agreement on the method or ease of doing so. The discussion includes assumptions about the constants involved and the definitions of the axes.

minhduc515
Messages
9
Reaction score
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
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.
 
Yes, i tried, but i don't want to have leftovers between two lines
 
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   Reactions: minhduc515
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
 
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   Reactions: minhduc515
1. One axis is X, the other is R
2. Z, b and a are constant
 
  • Like
Likes   Reactions: Wrichik Basu
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 ...
 
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   Reactions: minhduc515

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K