3D geometry plot in Mathematica
In planar geometry plot question, I asked how to draw planar geometr开发者_开发问答ic constructs. Now I want to extend it to 3D. Not only those geometry packages are not doing well, I am also facing quite a few obstacles in Mathematica.
Locator
is not usable in 3d, as far as i know.Manipulate
does not seem to work in 3d too.
Let me give a concrete example. I have a right circular cone with a height h
and an aperture 2 theta
. Its circular base is on the horizontal plane. Given a cone element, draw a circle with a diameter d
in the tangent plane to this cone passing the cone element. Then draw the horizontal diameter of this circle. Thank you for your help.
This is really not that hard. First we define a 3D circle, given by a position of its center, and two vectors which span the plane it is in:
Circle3D[{x_, y_, z_}, {v1 : {_, _, _}, v2 : {_, _, _}}, r_] :=
Line[Table[{x, y, z} + {r Cos[2 Pi t], r Sin[2 Pi t]}.{v1, v2}, {t,
0, 1, 1/120}]]
Then given a point {x,y,z}
on a cone with tip at {0,0,h}
tangents are {x,y,z-h}
and {-y,x,0}
. The rest is just drawing:
ConeQuestion[h_, theta_, pt : {x_, y_, z_},
d_] /; (x^2 + y^2) Cos[theta]^2 == Sin[theta]^2 (z - h)^2 :=
Module[{tangents},
tangents = {Normalize[{0, 0, h} - pt], Normalize[{-y, x, 0}]};
{{Opacity[0.8, Yellow], Cone[{{0, 0, 0}, {0, 0, h}}, h*Tan[theta]]},
{Thick, Dashed, Circle3D[pt, tangents, d]},
{Red, Sphere[pt, 1/10]},
{Orange,
Line[{pt - d Normalize[{-y, x, 0}],
pt + d Normalize[{-y, x, 0}]}]}}
]
精彩评论