1
|
8323 Views
|
7 Replies
|
7 Total Likes
View groups...
Share
GROUPS:

# How do I show a cheese (segment) from a flattish 3D cylinder (or tube)

Posted 10 years ago
 For someone this is probably too simple! However I have spent hours trawling through documentation and examples to find my answer, without success. So: Say I want to draw: cylinder[{{0,.1,0},{0,.4,0}} ,2] I then want to cut away or hide the whole volume from 2pi/6 to pi/6 and just leave the wedge showing. This is just one component of an engine in a far larger set, so whatever is done must not interfere with existing objects or later additions. I have also looked high and low to find find a way of doing simple things like drawing a solid hemisphere, so apart from plot regions etc which have global effects, so far zilch! I sure wish there were slice object, twist object and taper object commands (I guess thats a progressive scale),the last one can in fact be done with tubes around BSplinecurves quite well but cannot find a way to do cuboids. Many thanks in advance for any input.
7 Replies
Sort By:
Posted 10 years ago
 Nice animation! I am glad that I could help.
Posted 10 years ago
 Very many thanks Gianluca. I probably would not have got this far without your help.I have now got what I need, it'll now just take some fine tuning of positions to drop it into my larger model. wedge1[turnit_] := With[{\[Theta] = turnit}, (* Set radius, z for thickness and startangle and endangles, extendfactor creates a coneshell, or part of*){Gray, Rotate[Translate[ Rotate[Module[{radius = 1, k = 3, circ, n, twoCircs, cyl, extendfactor = 0, z = .2, startangle = Pi/4, endangle = 3 Pi/4}, circ = Table[{radius Cos[t], radius Sin[t], extendfactor}, {t, startangle, endangle, Pi/(6 k)}]; (* Outside face *) n = Length[circ]; twoCircs = Join[circ, Map[# + {0, 0, z} &, circ]]; cyl = GraphicsComplex[twoCircs, Polygon[Table[{m, m + 1, m + n + 1, m + n}, {m, n - 1}]], VertexNormals -> twoCircs]; N@{Polygon[Join[{{0, 0, 0}}, circ]], Translate[ Polygon[Join[{{0, 0, 0}}, circ]], {0, 0, z}], {EdgeForm[], cyl}, (* Inside faces*) Polygon[{circ[[1]], {0, 0, 0}, {0, 0, z}, circ[[1]] + {0, 0, z}}], Polygon[{circ[[-1]], {0, 0, 0}, {0, 0, z}, circ[[-1]] + {0, 0, z}}]}], Pi/2, {1, 0, 0}], {0, -1.5, 0.5}], \[Theta], {0, 1, 0}]}]; wedge2[turnit_] := With[{\[Theta] = turnit}, (* Set radius, z for thickness and startangle and endangles, extendfactor creates a coneshell, or part of*) {Gray, Rotate[ Translate[ Rotate[Module[{radius = 1, k = 3, circ, n, twoCircs, cyl, extendfactor = 0, z = .2, startangle = Pi/4, endangle = 3 Pi/4}, circ = Table[{radius Cos[t], radius Sin[t], extendfactor}, {t, startangle, endangle, Pi/(6 k)}]; (* Outside face *) n = Length[circ]; twoCircs = Join[circ, Map[# + {0, 0, z} &, circ]]; cyl = GraphicsComplex[twoCircs, Polygon[Table[{m, m + 1, m + n + 1, m + n}, {m, n - 1}]], VertexNormals -> twoCircs]; N@{Gray, Polygon[Join[{{0, 0, 0}}, circ]], Translate[ Polygon[Join[{{0, 0, 0}}, circ]], {0, 0, z}], {EdgeForm[], cyl}, (* Inside faces*) Polygon[{circ[[1]], {0, 0, 0}, {0, 0, z}, circ[[1]] + {0, 0, z}}], Polygon[{circ[[-1]], {0, 0, 0}, {0, 0, z}, circ[[-1]] + {0, 0, z}}]}], -Pi/2, {1, 0, 0}], {0, .3, -.5}], \[Theta], {0, 1, 0}]}]; rods[turnit_] := With[{\[Theta] = turnit}, Rotate[ {{Gray, Cuboid[{-.1, -1.5, -.2}, {.1, -1.7, 1}]}, {Gray, Cuboid[{-.1, .3, .2}, {.1, .5, -1}]}}, \[Theta], {0, 1, 0}]]; shaft = {Gray, Cylinder[{{0, -1.8, 0}, {0, .6, 0}}, .1]}; (end of initialisation cell ) Manipulate[ Graphics3D[{wedge1[turnit], wedge2[turnit], rods[turnit], shaft}, Axes -> True, AxesLabel -> {"x", "y", "z"}, PlotRange -> {{-2.5, 2.5}, {-2.5, 2.5}, {-2.5, 2.5}}], {{turnit, 0, "run engine"}, 0, 2 \[Pi], .01, ControlType -> Animator, AnimationRunning -> False}] File attached Attachments:
Posted 10 years ago
 The radius is implicitly set to 1 in the definition of circ. You can set it to any value r with circ = Table[{r Cos[t], r Sin[t], zscale}, {t, startangle, endangle, Pi/(6 k)}] 
Posted 10 years ago
 Gianluca, one thing can thing can you please point out where the radius is set, but very many thanks, I think you have just invented a new primitive, Wolfram should publish it in their code! You used some functions and techniques that I had never come across before.I have parameterized it as follows: (* a cheesy wedge provided by Gianluca Gorni and parameterised by Ray \ Hill set z= height required, set startangle and endangle, interesting games \ when playing with zscale *) wedge = Module[{k = 3, circ, n, twoCircs, cyl, z = 0.2, startangle = Pi/3, endangle = Pi - Pi/3, zscale = 0}, circ = Table[{Cos[t], Sin[t], zscale}, {t, startangle, endangle, Pi/(6 k)}]; n = Length[circ]; twoCircs = Join[circ, Map[# + {0, 0, z} &, circ]]; cyl = GraphicsComplex[twoCircs, Polygon[Table[{m, m + 1, m + n + 1, m + n}, {m, n - 1}]], VertexNormals -> twoCircs]; N@{Polygon[Join[{{0, 0, 0}}, circ]], Translate[ Polygon[Join[{{0, 0, 0}}, circ]], {0, 0, z}], {EdgeForm[], cyl}, Polygon[{circ[[1]], {0, 0, 0}, {0, 0, z}, circ[[1]] + {0, 0, z}}], Polygon[{circ[[-1]], {0, 0, 0}, {0, 0, z}, circ[[-1]] + {0, 0, z}}]}]; Graphics3D[wedge] 
Posted 10 years ago
 You can do it with Graphics3D primitives this way: myObject = Module[{k = 3, circ, n, twoCircs, cyl}, circ = Table[{Cos[t], Sin[t], 0}, {t, 2 Pi/6, 2 Pi + Pi/6, Pi/(6 k)}]; n = Length[circ]; twoCircs = Join[circ, Map[# + {0, 0, 2} &, circ]]; cyl = GraphicsComplex[twoCircs, Polygon[Table[{m, m + 1, m + n + 1, m + n}, {m, n - 1}]], VertexNormals -> twoCircs]; N@{Polygon[Join[{{0, 0, 0}}, circ]], Translate[Polygon[Join[{{0, 0, 0}}, circ]], {0, 0, 2}], {EdgeForm[], cyl}, Polygon[{circ[[1]], {0, 0, 0}, {0, 0, 2}, circ[[1]] + {0, 0, 2}}], Polygon[{circ[[-1]], {0, 0, 0}, {0, 0, 2}, circ[[-1]] + {0, 0, 2}}]}]; Graphics3D[myObject] You can apply geometric transformations to it.
Posted 10 years ago
 Thanks Sam, that got me a bit closer (file attached), now I need to work on turning that into a full 3D object which I can position with everything else, so I can rotate it as part of the whole Manipulation. I have started to fiddle further and found it incompatible with Graphics3D, so maybe I need a table that combines Graphics3D and RegionPlot commands. Well thats nearly half a day gone, thankfully I am now retired, if I was being paid to develop commercially at this rate I'd have been fired long ago ;(. I guess ideally if I could turn what you have given me into a 3D primitive I think I'd be there.Am trying to get a similarity to the mass balances on this: http://en.wikipedia.org/wiki/Radial_engine#/media/File:TwinWaspConRods.jpg Attachments:
Posted 10 years ago
 Take a look at regions. Probably something like: R = DiscretizeRegion[ RegionProduct[ DiscretizeRegion[Disk[{0, 0}, 1, {0 , 11 Pi/6}], MaxCellMeasure -> .01], Line[{{0.}, {2.}}]]] RegionPlot3D[R]