Can I plot a cone about an arbitrary axis in 3D? [closed]

I'm playing around with Mathematica to try to produce a 3D visualization of something. I need to generate the surface of a cone with a circular base. But the axis of the cone must be the body diagonal of a cube, i.e. the vector <1,1,1>. I want the apex angle theta_a to be 10.6796 degrees (0.186393 radians). I have no idea if it will prove to be helpful but I am able to generate an arbitrary vector that makes this angle with the body diagonal in the following way. First, I found one such vector by specifying its x and y components and finding a z component that satisfies the appropriate dot product relationship. Then I made a function that rotates a vector about an arbitrary axis by an angle. This function in principle generates the cone that I want if you were to continuously vary the rotation angle between -pi and pi. Here is my code:

rotaxis[rotvec_, rotax_, angle_] :=
Module[{}, (*
Rotate a vector rotvec about the vector rotax by radians equal to
angle *)
vecpar = Dot[rotvec, rotax]/Dot[rotax, rotax]*rotax;
vecperp = rotvec - vecpar;
w = Cross[rotax, vecperp];
vecperprot =
Norm[vecperp] (vecperp*Cos[angle]/Norm[vecperp] +
w*Sin[angle]/Norm[w]);
rotated = vecperprot + vecpar
]

mvecs = Table[
rotaxis[{1, 1, 1.46159669020979}*.6, {1, 1, 1}, q], {q, 0,
2 \[Pi], \[Pi]/8}];
Graphics3D[{Thick,
Line[{{-1, -1, -1}, {1, 1, 1}}], Line[{{1, -1, -1}, {-1, 1, 1}}],
Line[{{-1, 1, -1}, {1, -1, 1}}], Line[{{1, 1, -1}, {-1, -1, 1}}],
Red, Line[{{0, 0, 0}, mvecs[[#]]}] & /@ Range[Length@mvecs]},
BoxStyle -> {Thick, Dashed}]


The function rotvec is just taking this and putting it into Mathematica.

The variable mvecs is essentially a list of endpoints that would form the base of the cone that I want. The output of the Graphics3D shows the whole figure I'm trying to make except I'd like the red lines to replaced by a smooth cone.

Hopefully this isn't a stupid question. I'm woefully unfamiliar with making 3D graphics in Mathematica.

Edit: Per a comment from @Jens, this is easily done by using the built-in function Cone. The appropriate cone is created by, for example,

Cone[{{vec},{0,0,0}},Norm[vec]Tan[0.186393]]


where vec is the desired coordinate of the middle of the base.

closed as off-topic by MarcoB, m_goldberg, RunnyKine, Kuba♦, user9660 Apr 25 '16 at 8:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, m_goldberg, RunnyKine, Kuba, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

• Why not use the built-in Cone? – Jens Apr 7 '16 at 17:38
• Oh boy. I didn't know that function existed. That makes life very easy. For what its worth the code I pasted above was made to do some other stuff, I didn't come up with it for the sole purpose of generating a cone! Thanks @Jens. – skratch Apr 7 '16 at 18:18
• If you manage to adapt your code, you could simply post the end result as an answer to your own question. It could still be helpful to people. Otherwise, I would suggest closing the question. – Jens Apr 7 '16 at 18:51
• Just edited my submission. Thanks again. – skratch Apr 7 '16 at 19:06

Just to record an answer to the question, here are two possible ways of defining a cone:

c1 = Cone[{{1, 1, 1}, {0, 0, 0}}, Norm[{1, 1, 1}] Tan[0.186393]];
c2 = {CapForm["Butt"],
Tube[{{1, 1, 1}, {0, 0, 0}}, {Norm[{1, 1, 1}] Tan[0.186393], 0}]};

Table[
Graphics3D[{Thick, Line[{{-1, -1, -1}, {1, 1, 1}}],
Line[{{1, -1, -1}, {-1, 1, 1}}], Line[{{-1, 1, -1}, {1, -1, 1}}],
Line[{{1, 1, -1}, {-1, -1, 1}}], Red, c},
BoxStyle -> {Thick, Dashed}],
{c, {c1, c2}}]


The obvious choice is to use Cone as shown in c1, and an alternative with potentially more flexibility is the method in c2 which uses uses Tube. With Tube you can define for example truncated cones by making the smaller radius (in the second argument list of Tube) different from 0`.