You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
rectangle intersect with line and display which line or point got intersect?
6 views (last 30 days)
Show older comments
Dwy0 = 200;
Dwy = 100;
B1x = data(:,2);
B2x = data(:,2)+4*7.*D;
B3x = data(:,2)+4*7.*D;
B4x = data(:,2);
B1y = data(:,3) + (D/2);
B2y = data(:,3) + (Dwy/2);
B3y = data(:,3) - (Dwy/2);
B4y = data(:,3) - (D/2);
xv = [B3x,B4x,B1x,B2x];
yv = [B3y,B4y,B1y,B2y];
x2v = [B4x B1x];
y2v = [B4y B1y];
AA=intersect([xv,yv],[x2v,y2v])
plot(AA,'b.')
hold on;grid on
plot(xv,yv,'.')
% plot(x2v,y2v)
20 Comments
Prakash Choudhary
on 5 Jun 2019
In this code how can i show that the line x2v,y2v intersected by the rectangle and its for n rectangle with n lines the realtion between that i cant be able to display in here or simulate this thing!!!
Prakash Choudhary
on 5 Jun 2019
data(:,2) is x coordinates for N numbers
data(:,3) is y coordinates for N numbers
sir!!! you can consider random points and the code will give you the rectangle and line segments but the intersect part is not satisfying to me so i need help SOS!!!
Adam Danz
on 5 Jun 2019
Yes, we could generate our own fake data to help you solve your problem. But there's always a risk that the data we generate in the dark aren't similar enough to your actual data and that leads to a lot of wasted time and a lot of unnecessary dialogue. So it's your responsibility to produce some kind of data for people to work with that reproduces the problem.
Prakash Choudhary
on 5 Jun 2019
Yes sir but how can i attach the xlfile here i can just copy the coordinates here
xaxis yaxis
0 1148
1100 0
480 287
1300 700
220 2500
800 1600
2000 1100
1600 2000
2500 0
1000 3000
0 3500
480 4000
2250 2500
1600 3500
2500 4000
2900 560
3400 1600
2900 3000
4000 287
3700 2000
Adam Danz
on 5 Jun 2019
There we go; we can work with that. However,
- your 'data' matrix has 3 columns so we're missing a column of data
- We're also missing the value of 'D'.
Prakash Choudhary
on 5 Jun 2019
Sorry for That The value of D=200 however i missed to mention that before
Prakash Choudhary
on 5 Jun 2019
and the value of x2v,y2v however is same come from the rectangle one side lines
Adam Danz
on 5 Jun 2019
Edited: Adam Danz
on 5 Jun 2019
Ok, what about the 3rd column of 'data'?
" how can i show that the line x2v,y2v intersected by the rectangle"
x2v and y2v are both [20 x 2] matrices so they will produce two lines. And what rectangle do you expect those two lines to intersect?
I might be helpful to include an image of the intersection.
Prakash Choudhary
on 5 Jun 2019
i atteched the picture which can help you to understand my situation for the rectangle intersect.
Adam Danz
on 5 Jun 2019
I don't see any rectangles nor do I see any intersections.
Are you asking for the coordinates where the orange vertcial line that is circled and labeled "2" would intersect the blue lines if it extended vertically?
I can't help without reproducible code and that still hasn't been provided.
Prakash Choudhary
on 5 Jun 2019
yes i want to know that coordinates where it overlaps/ intersect the 2 or 3 by 1
Prakash Choudhary
on 5 Jun 2019
and its more like a polyshape object i consider as a rectangle because it made of a four different points
Adam Danz
on 5 Jun 2019
The solution probably isn't that complicated. You have to find the x value of the vertical lines; then, given that x value, find the y value on the blue line (interpolate if needed). The solution probably would have taken less time to write than the time spent going back and forth trying to understand your data. There has already been 20 comments on this and still, no data. We could exchange comments for the next few months and I still won't be able to help until you attach some data for me to work with.
You already produced a figure. That's impossible to do without data. So you have the data. You just need to save it to a mat file and attach it. Unfortunately I have other obligations today but I might have time to help you later (if there are data to work with).
Answers (0)
See Also
Categories
Find more on Delaunay Triangulation in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)