5
$\begingroup$

Helo All

I have some Question.

i just have this shape with ParametricPlot3D.

enter image description here

how can I calculate this shape with RegionCentroid Function? here my code

r = 10;
scc = 1;
zx = 5;
ppp = {x[1], y[1], z[1]} = {r*Sin[u], scc*v, r*Cos[u]};
sp = 116*Cot[\[Pi]/180*72];
pcg1 = {};
For[i = 1, i <= zx, i++,
 \[CurlyPhi] = (\[Pi]/2)/zx*i;
 {xi, yi, zi, dummy} = ( {
     {Cos[\[CurlyPhi]], -Sin[\[CurlyPhi]], 0, 0},
     {Sin[\[CurlyPhi]], Cos[\[CurlyPhi]], 0, 0},
     {0, 0, 1, sp*\[CurlyPhi]},
     {0, 0, 0, 1}
    } ).( {
     {1, 0, 0, 0},
     {0, 1, 0, 6 r},
     {0, 0, 1, 0},
     {0, 0, 0, 1}
    } ).Insert[ppp, 1, 4];
 AppendTo[pcg1, {xi, yi, zi}]
 ]
ParametricPlot3D[pcg1, {u, 0, 2 \[Pi]}, {v, 0, 10}, 
 AxesLabel -> {x, y, z}, PlotRange -> Full]

enter image description here

Thank you

$\endgroup$

2 Answers 2

6
$\begingroup$

Method-1

Using the code by author.

RegionCentroid@*DiscretizeGraphics@
 ParametricPlot3D[pcg1, {u, 0, 2 π}, {v, 0, 10}, 
  AxesLabel -> {x, y, z}, PlotRange -> Full]

{-47.5395, 34.5392, 35.5237}

Method-2

We rewrite the code,replace For by Table etc.

Clear["Global`*"];
r = 10;
scc = 1;
zx = 5;
ppp = {r*Sin[u], scc*v, r*Cos[u]};
sp = 116*Cot[π/180*72];
pcg1 = Table[Block[{φ = (π/2)/zx*i},
    ({{Cos[φ], -Sin[φ], 0, 0}, {Sin[φ], 
        Cos[φ], 0, 0}, {0, 0, 1, sp*φ}, {0, 0, 0, 
        1}}) . ({{1, 0, 0, 0}, {0, 1, 0, 6 r}, {0, 0, 1, 0}, {0, 0, 0,
         1}}) . PadRight[ppp, 4, 1]], {i, 1, zx}];
pcg1 = pcg1[[;; , 1 ;; 3]];
ParametricPlot3D[pcg1, {u, 0, 2 π}, {v, 0, 10}, 
   AxesLabel -> {x, y, z}, PlotRange -> All] // 
  DiscretizeGraphics // RegionCentroid

enter image description here

{-47.5395, 34.5392, 35.5237}

Method-3

Rewrite all the code,replace the matrix product by geometric transformation and using TransformedRegion.

Clear["Global`*"];
r = 10;
scc = 1;
zx = 5;
ppp = {r*Sin[u], scc*v, r*Cos[u]};
sp = 116*Cot[π/180*72];
reg = ParametricRegion[ppp, {{u, 0, 2 π}, {v, 0, 10}}];
Table[Block[{φ = (π/2)/zx*i}, 
     TransformedRegion[reg, 
      RotationTransform[φ, {0, 0, 1}]@*
       TranslationTransform[sp*φ {0, 0, 1}]@*
       TranslationTransform[6 r {0, 1, 0}]]], {i, 1, zx}] // 
   Map@DiscretizeRegion // RegionUnion
% // RegionCentroid

enter image description here

{-47.538, 34.543, 35.5203}

$\endgroup$
4
  • $\begingroup$ Thank you, I will try this method! $\endgroup$
    – 葉柏樂
    Feb 22, 2023 at 4:02
  • $\begingroup$ I start to use your first method, but its not work, am I wrong? here is my picture of code drive.google.com/file/d/1clmvYILo5VgfcsSn7AAFWw4m-MByrYZC/… $\endgroup$
    – 葉柏樂
    Feb 22, 2023 at 5:51
  • $\begingroup$ @葉柏樂AbdullahSyafiq We need to use new version 11,12 or 13 $\endgroup$
    – cvgmt
    Feb 22, 2023 at 5:59
  • $\begingroup$ i got it, because i still use version 10. thank you $\endgroup$
    – 葉柏樂
    Feb 22, 2023 at 6:15
6
$\begingroup$
$Version

(* "13.2.1 for Mac OS X ARM (64-bit) (January 27, 2023)" *)

ClearAll["Global`*"]

r = 10;
scc = 1;
zx = 5;
ppp = {x[1], y[1], z[1]} = {r*Sin[u], scc*v, r*Cos[u]};
sp = 116*Cot[π/180*72];
pcg1 = {};
For[i = 1, i <= zx, i++, φ = (π/2)/zx*i;
 {xi, yi, zi, 
   dummy} = ({{Cos[φ], -Sin[φ], 0, 0}, {Sin[φ], 
      Cos[φ], 0, 0}, {0, 0, 1, sp*φ}, {0, 0, 0, 
      1}}) . ({{1, 0, 0, 0}, {0, 1, 0, 6 r}, {0, 0, 1, 0}, {0, 0, 0, 1}}) . 
   Insert[ppp, 1, 4];
 AppendTo[pcg1, {xi, yi, zi}]]

pcg1 = pcg1 // Simplify;

The individual regions are

paraRgns = ParametricRegion[#, {{u, 0, 2 π}, {v, 0, 10}}] & /@ pcg1;

All of the regions are the same size

SameQ @@ (RegionMeasure /@ paraRgns)

(* True *)

Average the individual centroids

centroid = Mean[RegionCentroid /@ paraRgns] //
  FullSimplify

(* {-(13/2) (2 + Sqrt[5] + Sqrt[5 + 2 Sqrt[5]]), 
 13/2 (Sqrt[5] + Sqrt[5 + 2 Sqrt[5]]), 174/5 Sqrt[1 - 2/Sqrt[5]] π} *)

centroid // N

(* {-47.5394, 34.5394, 35.5226} *)

Show[
 ParametricPlot3D[pcg1, {u, 0, 2 π}, {v, 0, 10},
  AxesLabel -> {x, y, z}, PlotRange -> Full],
 Graphics3D[{Red, AbsolutePointSize[8], Point[centroid]}]]

enter image description here

$\endgroup$
2
  • 2
    $\begingroup$ (+1) Good, Mean work for the geometric center. $\endgroup$
    – cvgmt
    Feb 20, 2023 at 15:36
  • $\begingroup$ thank you! i will try this $\endgroup$
    – 葉柏樂
    Feb 22, 2023 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.