Transform the unit spherical coordinates into ellipsoid matlab in three-dimensional space

The procedure is as follows:

function xyz_trans()
c_num = 51;
[x, y, z]=sphere(c_num);
xyz = [x(:)'; y(:)'; z(:)'];

sx = normrnd(1,1,1);        %正态分布 均值1 标准差1 生成1个 Normal
sy = normrnd(1,1,1);        %正态分布 均值1 标准差1 生成1个 Normal
sz = normrnd(1,1,1);        %正态分布 均值1 标准差1 生成1个 Normal

alpha = rand(1) * 2 * pi;   %均匀分布Uniform
beta = rand(1) * 2 * pi;    %均匀分布Uniform

% 文献中应该给错了 在根号下的范围必须是[-1, 1]
rho1 = rand(1) * 2 - 1;     %均匀分布Uniform
rho2 = rand(1) * 2 - 1;     %均匀分布Uniform
rho3 = rand(1) * 2 - 1;     %均匀分布Uniform

theta1 = rand(1) * 2 * pi;  %均匀分布Uniform
theta2 = rand(1) * 2 * pi;  %均匀分布Uniform
theta3 = rand(1) * 2 * pi;  %均匀分布Uniform

Scale = diag([sx,sy,sz]);

Rotation = [    cos(alpha) * cos(beta), -sin(alpha), cos(alpha) * sin(beta)
    sin(alpha) * cos(beta), cos(alpha), sin(alpha) * sin(beta)
    -sin(beta),  0, cos(beta)
    ];

Skew = [sqrt(1-rho1^2), rho2* sin(theta2), rho3 * cos(theta3)
    rho1 * cos(theta1), sqrt(1-rho2^3),  rho3 * sin(theta3)
    rho1 * sin(theta1),   rho2 * cos(theta2),  sqrt(1-rho3^2)
    ];

bubble = Scale * Rotation * Skew ./ (nthroot(det(Skew), 3)) * xyz;
bubble_x = reshape(bubble(1, :), c_num + 1, c_num + 1);
bubble_y = reshape(bubble(2, :), c_num + 1, c_num + 1);
bubble_z = reshape(bubble(3, :), c_num + 1, c_num + 1);
% bubble_x = reshape(bubble(1, :), 26, []);
% bubble_y = reshape(bubble(2, :), 26, []);
% bubble_z = reshape(bubble(3, :), 26, []);
subplot(2,2,1)
surf(bubble_x, bubble_y, bubble_z)
title('3D')
axis vis3d;
view(45,30)

subplot(2,2,2)
surf(bubble_x, bubble_y, bubble_z)
title('Front view')
axis square
view(0, 0)

subplot(2,2,3)
surf(bubble_x, bubble_y, bubble_z)
title('Side view')
axis square
view(-90, 0)

subplot(2,2,4)
surf(bubble_x, bubble_y, bubble_z)
title('Top view')
axis square
view(0, 90)
end

 references

[1]GONG C, SONG Y, HUANG G, et al. BubDepth: A neural network approach to three-dimensional reconstruction of bubble geometry from single-view images[J/OL]. International Journal of Multiphase Flow, 2022, 152: 104100. DOI:10.1016/j.ijmultiphaseflow.2022.104100.

Guess you like

Origin blog.csdn.net/weixin_41467446/article/details/126866444