Conversion from Cartesian X,Y,Z to domain-centric cylindrical coordinates
조회 수: 2 (최근 30일)
이전 댓글 표시
I just have a question on the conversion from Cartesian X,Y,Z to domain-centric cylindrical coordinates. I have a computed variable, an energy flux term, say F.
Currently, F is a function of x,y,z. Here, the x,y,and z are not lat-Lon values but are more like indices. For example, the grid has 480 grids in the X and Y direction with a spacing of 1km each. So I simply define X as 1000 to 480,000 in increments of 1000 (meters). Y and X are the same since the grid is uniform. I use actual Z values which are non-uniform.
What I’d like to do is to transform this variable, F into r,theta,z coordinates with reference to the domain center. What is the best way to do this in Matlab?
댓글 수: 4
Sindar
2020년 1월 24일
편집: Sindar
2020년 1월 24일
An algorithm:
- generate a cylindrical grid (decide whether you want r_max to include all xyz points, or to exclude any unknown points, or somewhere between)
- transform this grid into Cartesian (x2=r*cos(theta), etc.)
- interpolate F from your original grid to the new Cartesian grid (interp3)
- you now have F2 at your new cylindrical grid
채택된 답변
Sindar
2020년 1월 24일
편집: Sindar
2020년 1월 24일
% example data
X = 1000:1000:480000;
Y = X;
Z = sort(rand(size(X)));
Domain_Center = [mean(X([1 end])) mean(Y([1 end])) mean(Z([1 end]))]
% compute Cylindrical coordinates
[theta,rho,z] = cart2pol(X-Domain_Center(1),Y-Domain_Center(2),Z - Domain_Center(3));
% F = F
댓글 수: 5
Sindar
2020년 1월 24일
The algorithm is on the documentation page https://www.mathworks.com/help/matlab/ref/cart2pol.html#bu5h1tr-1
slices and isosurfaces will treat your r,theta,z coordinates exactly like cartesian ones. For instance, visually, the slices will still be planes but they will be slices along r instead of x, etc.. I'd just try first and see what happens.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!