You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Geometric Analysis of cross-seciton
1 view (last 30 days)
Show older comments
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 Comments
Michael Madelaire
on 23 Jul 2019
Do you have one of these cross-sections?
Devrim Tugberk
on 25 Jul 2019
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).
Accepted Answer
darova
on 25 Jul 2019
Simple formula of polygon centroid: WIKI
27 Comments
Devrim Tugberk
on 25 Jul 2019
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
on 25 Jul 2019
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
on 25 Jul 2019
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
on 25 Jul 2019
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
on 25 Jul 2019
what about the z-coordinates? since my cross_section is a 3D scatter plot as mentioned in quesiton
Devrim Tugberk
on 25 Jul 2019
i'm sorry, this isn't what i'm looking for :(
Devrim Tugberk
on 25 Jul 2019
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
Devrim Tugberk
on 25 Jul 2019
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
on 26 Jul 2019
i think your previous answer was more useful, could you maybe refer to my comment?
thank you
Devrim Tugberk
on 26 Jul 2019
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
darova
on 26 Jul 2019
Edited: Walter Roberson
on 26 Jul 2019
You don't understand me?
Devrim Tugberk
on 26 Jul 2019
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
on 26 Jul 2019
Edited: Walter Roberson
on 26 Jul 2019
Pay attention also that centroid i found is very approximate. It is not a center of mass
Rik
on 26 Jul 2019
Edited: Walter Roberson
on 26 Jul 2019
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
on 26 Jul 2019
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
on 29 Jul 2019
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
on 29 Jul 2019
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
on 29 Jul 2019
Edited: Devrim Tugberk
on 29 Jul 2019
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
More Answers (0)
See Also
Categories
Find more on Annotations 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 (한국어)