0
|
6994 Views
|
3 Replies
|
5 Total Likes
View groups...
Share
GROUPS:

# Finding size of 3d Parametric Plot

Posted 10 years ago
 so I'm new to Mathematica and don't understand how to find the size of my object. I ultimately want to convert it to makerbot and print but I need to make sure the default size on makerbot is the same as the size of the exported object. I tried adding a bounding box with axes but that doesn't really tell me the size of the object since the box is bigger than the object. I also was wondering if once I find the raw numbers, I could figure out what units they are in. This is the code for the object a = 1.06 b = 6 c = 1.5 d = 1 e = 1.2 tr = 0 tmax = 50 ParametricPlot3D[a^ t { Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]])), Sin[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]])), b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]])}, {\[Theta], -Pi, Pi}, {t, -tmax, 0}, PlotStyle -> Directive[Opacity[1 - 0], Lighter[Yellow, .3], Specularity[White, 10], Thickness[.1]], Axes -> True, ViewPoint -> {1, 1, -3}, Boxed -> True, PlotRange -> All, ImageSize -> {400, 450}, Mesh -> None, PlotPoints -> 400, MaxRecursion -> ControlActive[0, Automatic]] 
3 Replies
Sort By:
Posted 10 years ago
 I believe you'll need to find the minimums and maximums for each dimension and then calculate the range for each dimension to get the size of the box that would fit the object. (Unless you're asking for how to calculate the volume?) Also, the units are whatever units you want. If you want the height of the object to be a certain size, then you'll need to multiply each dimension by the ratio of the desired height to the current height. Below is a brute-force approach to getting the dimensions. Note that for one of the dimensions I needed to use FindMinimum rather than Minimize to get the appropriate minimum. You'll need to check to see if all of the other Minimums and Maximums converged properly. a = 1.06; b = 6; c = 1.5; d = 1; e = 1.2; tr = 0; tmax = 50; (* Find maximum and mininum for each dimension *) (* 1st dimension *) max1 = Maximize[{a^ t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), -50 <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, \[Theta]}] min1 = FindMinimum[ a^t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), {t, -0.5}, {\[Theta], 1.5}] (* 2nd dimension *) max2 = Maximize[{a^ t (Sin[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), -50 <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, \[Theta]}] min2 = Minimize[{a^ t (Sin[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), -50 <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, \[Theta]}] (* 3rd dimension *) max3 = Maximize[{a^ t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]])), -50 <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, \[Theta]}] min3 = Minimize[{a^ t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]])), -50 <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, \[Theta]}] (* Construct object *) g = ParametricPlot3D[ a^t {Cos[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]])), Sin[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]])), b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]])}, {\[Theta], -Pi, Pi}, {t, -tmax, 0}, PlotStyle -> Directive[Opacity[0.5], Lighter[Yellow, .3], Specularity[White, 10], Thickness[.1]], Axes -> True, ViewPoint -> {2, 2, -6}, Boxed -> True, PlotRange -> {{-3, 3}, {-3, 3}, {0, 7.5}}, ImageSize -> {400, 450}, Mesh -> None, PlotPoints -> 400, MaxRecursion -> ControlActive[0, Automatic], RotationAction -> "Clip", SphericalRegion -> True]; (* Construct points where minimums and maximums occur *) {max11, max12, max13} = {max1[[1]], a^t (Sin[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), a^t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]]))} /. max1[[2]] {min11, min12, min13} = {min1[[1]], a^t (Sin[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), a^t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]]))} /. min1[[2]] {max21, max22, max23} = {a^ t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), max2[[1]], a^t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]]))} /. max2[[2]] {min21, min22, min23} = {a^ t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), min2[[1]], a^t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]]))} /. min2[[2]] {max31, max32, max33} = {a^ t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), a^t (Sin[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), max3[[1]]} /. max3[[2]] {min31, min32, min33} = {a^ t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), a^t (Sin[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), min3[[1]]} /. min3[[2]] (* Graph object and maximum and minimum points *) p = Graphics3D[{PointSize[0.05], Point[{{max11, max12, max13}, {min11, min12, min13}, {max21, max22, max23}, {min21, min22, min23}, {max31, max32, max33}, {min31, min32, min33}}]}]; Show[{g, p}] (* Object dimensions *) {max1[[1]] - min1[[1]], max2[[1]] - min2[[1]], max3[[1]] - min3[[1]]} 
Posted 10 years ago
 I need to modify the code I included above because Maximize and Minimize did not always find the global maximum and minimum, respectively. Below all of the searches for the minimum and maximum for each dimension use FindMinimum and FindMaximum with starting values generated by evaluating the surface with a 3D grid (i.e., a table).As far as "what units" I think I have something more helpful than what I said earlier: the units must be what the makerbot expects. Hope this helps. (* Set parameter values *) a = 1.06; b = 6; c = 1.5; d = 1; e = 1.2; tr = 0; tmax = 50; (* Construct table of values as a crude check *) v = Flatten[ Table[{t, \[Theta], a^t (Cos[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), a^t (Sin[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), a^t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]]))}, {\[Theta], -Pi, Pi, Pi/200}, {t, -tmax, 0, tmax/200}], 1]; (* Reasonable approximations for minimums and maximums using the \ values from the table *) {t1Max, \[Theta]1Max} = N[Flatten[ v[[Flatten[Position[v[[All, 3]], Max[v[[All, 3]]]]]]]]][[{1, 2}]]; {t1Min, \[Theta]1Min} = N[Flatten[ v[[Flatten[Position[v[[All, 3]], Min[v[[All, 3]]]]]]]]][[{1, 2}]]; {t2Max, \[Theta]2Max} = N[Flatten[ v[[Flatten[Position[v[[All, 4]], Max[v[[All, 4]]]]]]]]][[{1, 2}]]; {t2Min, \[Theta]2Min} = N[Flatten[ v[[Flatten[Position[v[[All, 4]], Min[v[[All, 4]]]]]]]]][[{1, 2}]]; {t3Max, \[Theta]3Max} = N[Flatten[ v[[Flatten[Position[v[[All, 5]], Max[v[[All, 5]]]]]]]]][[{1, 2}]]; {t3Min, \[Theta]3Min} = N[Flatten[ v[[Flatten[Position[v[[All, 5]], Min[v[[All, 5]]]]]]]]][[{1, 2}]]; (* Find maximum and mininum for each dimension using an iterative \ method *) (* 1st dimension *) max1 = FindMaximum[{a^ t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), -tmax <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, t1Max}, {\[Theta], \[Theta]1Max}]; min1 = FindMinimum[{a^ t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), -tmax <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, t1Min}, {\[Theta], \[Theta]1Min}]; (* 2nd dimension *) max2 = FindMaximum[{a^ t (Sin[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), -tmax <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, t2Max}, {\[Theta], \[Theta]2Max}]; min2 = FindMinimum[{a^ t (Sin[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), -tmax <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, t2Min}, {\[Theta], \[Theta]2Min}]; (* 3rd dimension *) max3 = FindMaximum[{a^ t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]])), -tmax <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, t3Max}, {\[Theta], \[Theta]2Max}]; min3 = FindMinimum[{a^ t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]])), -tmax <= t <= 0 && -\[Pi] <= \[Theta] <= \[Pi]}, {t, t3Min}, {\[Theta], \[Theta]2Min}]; (* Construct points where minimums and maximums occur *) {max11, max12, max13} = {max1[[1]], a^t (Sin[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), a^t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]]))} /. max1[[2]]; {min11, min12, min13} = {min1[[1]], a^t (Sin[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), a^t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]]))} /. min1[[2]]; {max21, max22, max23} = {a^ t (Cos[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), max2[[1]], a^t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]]))} /. max2[[2]]; {min21, min22, min23} = {a^ t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), min2[[1]], a^t (b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]]))} /. min2[[2]]; {max31, max32, max33} = {a^ t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), a^t (Sin[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), max3[[1]]} /. max3[[2]]; {min31, min32, min33} = {a^ t (Cos[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), a^t (Sin[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]]))), min3[[1]]} /. min3[[2]]; (* Object dimensions from using tables *) {Max[v[[All, 3]]] - Min[v[[All, 3]]], Max[v[[All, 4]]] - Min[v[[All, 4]]], Max[v[[All, 5]]] - Min[v[[All, 5]]]} (* Object dimensions from using NMaximum and NMinimum *) {max1[[1]] - min1[[1]], max2[[1]] - min2[[1]], max3[[1]] - min3[[1]]} (* Construct object *) g = ParametricPlot3D[ a^t {Cos[ t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]])), Sin[t] (1 + c (Cos[e] Cos[\[Theta]] + d Sin[e] Sin[\[Theta]])), b + c (Cos[\[Theta]] Sin[e] - d Cos[e] Sin[\[Theta]])}, {\[Theta], -Pi, Pi}, {t, -tmax, 0}, PlotStyle -> Directive[Opacity[0.5], Lighter[Yellow, .3], Specularity[White, 10], Thickness[.1]], Axes -> True, ViewPoint -> {2, 2, -6}, Boxed -> True, PlotRange -> {{-3, 3}, {-3, 3}, {0, 7.5}}, ImageSize -> {400, 450}, Mesh -> None, PlotPoints -> 400, MaxRecursion -> ControlActive[0, Automatic], RotationAction -> "Clip", SphericalRegion -> True]; (* Graph object and maximum and minimum points *) p = Graphics3D[{PointSize[0.05], Point[{{max11, max12, max13}, {min11, min12, min13}, {max21, max22, max23}, {min21, min22, min23}, {max31, max32, max33}, {min31, min32, min33}}]}]; Show[{g, p}] 
Posted 10 years ago
 Thanks a bunch for all the help! The step by step will be very useful for getting sizes of shells of different parameters