rectangle intersect with line and display which line or point got intersect?
1 次查看(过去 30 天)
显示 更早的评论
Prakash Choudhary
2019-6-4
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 个评论
Prakash Choudhary
2019-6-5
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
2019-6-5
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
2019-6-5
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
2019-6-5
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
2019-6-5
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
2019-6-5
Sorry for That The value of D=200 however i missed to mention that before
Prakash Choudhary
2019-6-5
and the value of x2v,y2v however is same come from the rectangle one side lines
Adam Danz
2019-6-5
编辑:Adam Danz
2019-6-5
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
2019-6-5
i atteched the picture which can help you to understand my situation for the rectangle intersect.
Adam Danz
2019-6-5
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
2019-6-5
yes i want to know that coordinates where it overlaps/ intersect the 2 or 3 by 1
Prakash Choudhary
2019-6-5
and its more like a polyshape object i consider as a rectangle because it made of a four different points
Adam Danz
2019-6-5
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).
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Elementary Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)