Group Abstract Group Abstract

Message Boards Message Boards

1
|
19.4K Views
|
11 Replies
|
9 Total Likes
View groups...
Share
Share this post:

Use ParametricPlot3D to plot a general circular cylinder?

Posted 7 years ago

Hello everyone, How do I parametrise and use ParametricPlot3D to plot a general circular cylinder with general as axis and radius R?

11 Replies
Posted 6 years ago

There seems to be an easier answer.

ParametricPlot3D[{Cos[u], Sin[u], t}, {u, 0, 2 Pi}, {t,0,5}] (*has radius of 1*}
ParametricPlot3D[{2*Cos[u], 2*Sin[u], t}, {u, 0, 2 Pi}, {t,0,5}] (*has radius of 2*}

It shouldn't be to hard (I think) to figure our how to do Cylinders with different orientations.

POSTED BY: John Guenther
Posted 7 years ago

Another variant of getting the coordinate axes:

getMatrix[axis_ /; Norm[axis] != 0] := Module[
    {v2, v3},
    v2 = {x, y, z} /. First@FindInstance[
        Dot[axis, {x, y, z}] == 0 && Norm@{x, y, z} != 0, {x, y, z}, Reals
    ];
    v3 = Cross[axis, v2];
    Normalize /@ {axis, v2, v3}
]
POSTED BY: Hans Milton
POSTED BY: John McGee

The problem is with my oversimplified Orthogonalize. The other two vectors should be nearly perpendicular to "axis", as in

Orthogonalize[{1,10,0},{0,1,0},{0,0,1}].
POSTED BY: John McGee

Given an axis vector "axis" and a radius "r". You first need to construct an orthonormal set of coordinate axes.

{vz, vx, vy} = Chop@Orthogonalize[{axis, {1, 0, 0}, {0, 1, 0}}]

Now, given a base point "b" and a height "h" the plot can be constructed with:

Show[ParametricPlot3D[b+z*vz+r*Cos[\[Theta]]*vx+r*Sin[\[Theta]]*vy,{z,0,h},{\[Theta],0,2\[Pi]},PlotStyle->Directive[Opacity[0.7],Orange]],
Graphics3D[{Blue,PointSize[0.02],Point[b],Arrow[{b,b+h*vz}], Magenta,Arrow[{b,b+r*vx}],Green,Arrow[{b,b+r*vy]}]]

This will also show the cylinder axis in blue, with the other two axes in Magenta and Green.

POSTED BY: John McGee

Thank you so much John McGee. When I use the axis as {1,10,0) , the base point as {0,0,1} and h=5 I get a blank plot. What could be he reason?

Are you sure you made the coordinate box big enough? I get a cylinder that's cut off by the plot boundary. But I think that John McGee's method just using Orthogonalize[ ] should work as long as the axis and the other two vectors are linearly independent. Otherwise, you'd have to choose different 2nd and 3rd vectors.

enter image description here

Attachments:
Posted 7 years ago
POSTED BY: Hans Milton

Are you new to Mathematica? What have you tried?

POSTED BY: John McGee
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard