Creating Sphere using Cuboids of varying size

3 ビュー (過去 30 日間)
RAHUL JAISWAL
RAHUL JAISWAL 2021 年 2 月 22 日
コメント済み: Walter Roberson 2021 年 3 月 7 日
I want to make a sphere using cuboids. The radius of the sphere is 60 mm and I want to divide this whole radius in 12 units so that a single unit has a fixed size of 5mm (a single unit represents a cuboid of size, 5 mm x 5mm x 5mm). Each cuboid unit has its center fixed at some point along the radius. Now, within this unit, the size of the cuboid is varied according to value of b having the same center as previous cuboid (but the current size will be less because of varying cuboid size so that no overlapping between two cuboids). The size of the cuboid (b) is governed by the equation as;
b=5.698-16457*exp(-a/0.11)-8.373*exp(-a/1.092),
where the values of a is varied from 1 to 2 with a step of 0.1. I need a MATLAB code for this problem statement. What appraoch should be used? Thanks in advance.
  2 件のコメント
darova
darova 2021 年 2 月 22 日
Did you figure out how to plot a cuboid?
RAHUL JAISWAL
RAHUL JAISWAL 2021 年 2 月 23 日
I have used patch function to make cube, which use vertices and faces information to make cube. However, I need to make a cube using its center and sidelength. Plotcube function was used to make the cube using these two variable, but it is not working. Any suggestion?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2021 年 3 月 3 日
%assume center at xc, yc, zc
dx = sidelength/2;
%Left/Right, Front/Back, Down/Up
vertices = [
-1, -1, -1 %LFD 1
-1, -1, +1 %LFU 2
-1, +1, -1 %LBD 3
-1, +1, +1 %LBU 4
+1, -1, -1 %RFD 5
+1, -1, +1 %RFU 6
+1, +1, -1 %RBD 7
+1, +1, +1 %RBU 8
]
faces = [
1 5 7 3 %bottom
and so on to list the other faces
]
This describes a cuboid centered at 0 0 0 and sidelength 1.
Now multiply vertices by sidelength/2 and add xc to the first column, yc to the second column, zc to the third column, and the resulting set of vertices will describe a cube centered at xc, yc, zc, with the desired side length.
You can then patch() it with 'Faces', faces, 'Vertices', vertices
  2 件のコメント
RAHUL JAISWAL
RAHUL JAISWAL 2021 年 3 月 7 日
Thank you Walter for your reply. I will try to make cubes with the method provided by you. Thank you for your effort and help.
Walter Roberson
Walter Roberson 2021 年 3 月 7 日
I just realized the above cube has side lengths 2 rather than 1 like I said, but the scale factor I said earlier should still be correct

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by