Trouble with finding appropriate conditions for logic
6 ビュー (過去 30 日間)
古いコメントを表示
I have a blunt body (Apollo capsule) modeled. I wrote a function to read in the vertices and the normals from the STL of this model. Given a velocity vector, I want to be able to figure out which facets of the capsule are in the shadow region (region where there is relatively no flow) and also any facets not on the heat shield (the facets that are not part of the cone and the radius at the top). I tried writing conditions down using the angle between the velocity vector and the normal vector of each facet. Right now I'm coloring these facets red so I can see if the conditions are detecting the right facets. The problem that I'm having is that some of the facets of interest are getting detected and some areas are not.
Included are some images of what the capsule looks like from the side and in 3d space and also the problem I am running into. The red line indicates the velocity vector pointing up. The whole underside of the capsule should be selected as well as the lower half of the rounded edge (the edge between the large heat shield and the cone sides).
1 件のコメント
Fredrick_jong
2013 年 3 月 17 日
Hi,
I was wondering, how did you manage to plot the Apollo capsule on MATLAB? I am currently trying to do that but I am unable to. Your assistance will be greatly appreciated. Many thanks in advance.
採用された回答
Cedric
2013 年 1 月 17 日
編集済み: Cedric
2013 年 1 月 17 日
Could you have an issue with the orientation of your facets, e.g. by coding vertice IDs clockwise when they should be coded counterclockwise or vice versa? That would make part of your normals point in the wrong direction which would change the sign of the scalar product with the velocity vector (if it's what you use to detect facets in the shadow region).
Without seeing your code, there isn't much more that comes to my mind.
EDIT: here are a few hints after looking at your code.
- The red line that you display vertically is different from the "free-stream vector" b that you define in facet_sort.m.
- You rotate vertices in Apollo.m but you forget to rotate normals .
These two combined explain the angle. If you set b=[0 0 1] in facet_sort.m for example, you will see that the heat shield will be displayed in red.
Several for loops could be eliminated if you had efficiency requirements. E.g. in facet_sort.m, you could replace the computation of theta (the whole for loop) by:
flagsShadow = normals * b.' < 0 ; % Or > 0 depending the orientation
% your facets.
and propagate these flags back into PlotFacets.m to select the color, instead of performing tricky computations with angles.
Hope it helps!
Cedric
その他の回答 (2 件)
Cedric
2013 年 1 月 17 日
Which method did you chose finally to..
- Flag facets in the shadow.
- Flag facets from the shield.
- Define colors.
Could you paste the code? Here it seems that you have something like a union of the upper part and facets exposed to flow.
9 件のコメント
Harold
2013 年 1 月 29 日
3 件のコメント
Cedric
2013 年 1 月 29 日
編集済み: Cedric
2013 年 1 月 29 日
In fact, you could have the transpose of what I built above for vId, so you can exploit linear indexing:
function vId = f2v(fId)
% Return a 3xn array of vertices IDs, where n is the number of elements
% of fId (vector of facet IDs).
vId = [3*fId(:),3*fId(:)+1, 3*fId(:)+2].' ;
end
I don't know if you are familiar with linear indexing.. if not, look at the following:
>> A = [1 2; 3 4] ;
>> A(:)
ans =
1
3
2
4
Arrays are saved in memory in "column". A(:) means get all elements of A following the linear order in memory, which means that you get the entire column 1 first and the the entire column 2. This means for example that is v is a vector, v(:) is always the column version of this vector, even if v is a row vector.
So having vId as a 3xn matrix means that if you access it linearly with vId(:) you get a column vector with the 3 vertices of facet 1 of fId first, then the 3 vertices of facet 2 of fId, etc .. which can be useful.
参考
カテゴリ
Help Center および File Exchange で Graphics Object Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!