Geometric Analysis of cross-seciton
1 次查看(过去 30 天)
显示 更早的评论
Devrim Tugberk
2019-7-23
Dear Matlab Community,
I have a 3D scatter plot representing a cross-section of a vessel. My goal is to have a script that will: identify the center of this cross-section and generate lines from this centerpoint in a circular motion in increments of 1 degrees between each line (up to 360 degrees).
4 个评论
Devrim Tugberk
2019-7-25
I didn't achieve much yet. My communication with the program still is very limited. The only thing i achieved was to locate the centerpoint for each cross-section (without a script).
采纳的回答
darova
2019-7-25
Simple formula of polygon centroid: WIKI
27 个评论
Devrim Tugberk
2019-7-25
Thank you for the time but this doesn't help me at all. My problem isn't finding the centroid, my problem is generating lines ALL coming from the centroid and each line will be seperated by 1 degree and going all the way around the cross-section until 360 degrees is reached.
darova
2019-7-25
I have an idea:
define angle of each point
interpolate old data with new angles
t1 = linspace(0,2*pi,360); % create new array of angles
x1 = interp1(t,x,t1); % interpolate X (t - old array of angles)
y1 = interp1(t,y,t1); % interpolate Y
Devrim Tugberk
2019-7-25
The idea sounds logical, also please refer to the second image i attached as a post (below). The suggestion you made would work but not for my purpose since my idea is to compute this process to many cross-sections and the idea is the be able to compare each cross-section.
In other words: a set of lines with fixed increments are genrated on cross_1 and cross_2. Line one (1 degrees away from initial line) is the same for cross_1 and cross_2 and the idea is to see where that line hits on cross_1 versus cross_2.
Thank you for the effort you're putting in, i hope i'm clear
darova
2019-7-25
You can use this formula to calculate angle
Calculate angles between neighbour points and get all angles
simple example:
a3' = a1 + a2 + a3
You have all points (x,y) and angles for them - interpolate data as i have shown before
Devrim Tugberk
2019-7-25
what about the z-coordinates? since my cross_section is a 3D scatter plot as mentioned in quesiton
Devrim Tugberk
2019-7-25
I have xyz coordinates, generating this 3D scatter plot and all i want are lines generated from the centerpoint of this plot and the lines generated will be in increments of 1 degree
darova
2019-7-25
Just lines? They have nothing to do with data?
t = 0:1:360;
r = 2;
x0 = 199;
y0 = 29;
x = r*cosd(t) + x0;
y = r*sind(t) + y0;
hold on
for i = 1:length(x)
plot([x0 x(i)],[y0 y(i)],'.-r')
end
hold off
Devrim Tugberk
2019-7-25
okay again, thank you so much for your patience. Here is the script i use to generate my cross sections:
vv=cellfun(@(x) x(:,1:3),Cross_sections,'un',0); % assuming the first three columns in each cell represents x,y & z
v=cat(1,vv{:}); % gathering x,y, & z of each cell into one matrix
scatter3(v(:,1),v(:,2),v(:,3))
% ^- x ^- y ^- z
axis equal % equal axis lengths
for k = 1:size(vv) %numel
figure(k);
scatter3(vv{k}(:,1),vv{k}(:,2),vv{k}(:,3));
end
so on the SAME plot of each cross_section, i want to generate lines with fixed angle increments (as you have succesfully done in your previous script) so the only thing i will need from you at this point is to incorparate your script with mine into one script that plots the cross_section and on the same plot generates the lines where i can visually see wether those fixed increment lines DO or DO NOT hit any of my points and that's it.
Thank you so much.
Devrim Tugberk
2019-7-26
i think your previous answer was more useful, could you maybe refer to my comment?
thank you
Devrim Tugberk
2019-7-26
I have another script that extracts this cross_sections data (not relevant) and the script below extracts the cross_sections data from each cell and plots them:
vv=cellfun(@(x) x(:,1:3),Cross_sections,'un',0); % assuming the first three columns in each cell represents x,y & z
v=cat(1,vv{:}); % gathering x,y, & z of each cell into one matrix
scatter3(v(:,1),v(:,2),v(:,3))
% ^- x ^- y ^- z
axis equal % equal axis lengths
for k = 1:size(vv) %numel
figure(k);
scatter3(vv{k}(:,1),vv{k}(:,2),vv{k}(:,3));
end
and here is the script you provided regarding the lines which is what i want:
t = 0:5:360;
r = 2;
x0 = 199;
y0 = 29;
x = r*cosd(t) + x0;
y = r*sind(t) + y0;
hold on
for i = 1:length(x)
plot([x0 x(i)],[y0 y(i)],'.-r')
end
hold off
The last few things i need are:
1) the addition of z since we are working 3D
2) i need these lines generated for each, individual cross_section automatically on the same plot
3) x0 and y0 need to be the centroid of each cross_section and should be re-calculated for each cross_section individually.
Again, thank you so much for working me through this
Devrim Tugberk
2019-7-26
I was trying very hard to understand you and also help you understand me. The script you sent me is exactly what i needed. I thank you for your time and effort and i apologize for my lack of knowledge.
darova
2019-7-26
编辑:Walter Roberson
2019-7-26
Pay attention also that centroid i found is very approximate. It is not a center of mass
Rik
2019-7-26
编辑:Walter Roberson
2019-7-26
I know from personal experience how difficult it can be to make clear what you mean, especially in text, and especially if one or both of the parties are not native speakers of the language used.
Walter Roberson
2019-7-26
Once someone has accepted your Answer or voted for you, if the acceptance or vote is withdrawn then you still get the points.
There are no point credits for number of comments or number of Answers.
(There is a badge for Most Accepted Answers in a given calendar year.)
Devrim Tugberk
2019-7-29
Dear Darova,
there is no harm done and maybe it's true, language might be a barrier and i might have misinterpret your words.
On another note, perhaps you could help m figure out information about the points where the red lines intersect the blue lines (cross_section).
Thank you
Devrim Tugberk
2019-7-29
That won't work for me since i NEED the red lines to be in fixed angles but option 1 generates the red lines in order to go through the points. I want the point data of the fixed red lines crossing the interpolated blue lines.
Devrim Tugberk
2019-7-29
编辑:Devrim Tugberk
2019-7-29
no problem!
So i need the coordinate data corresponding to the green dots (all of the points, not just the ones i drew) that i have drawn on the image. The green dot representing the intersection between the blue lines and the red lines.
Thank you
darova
2019-7-29
Using interp option you have vector
What if just extend this vector (make it longer) ?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
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 (한국어)