在Mathematica中绘制一个线环

时间:2011-06-27 15:42:56

标签: wolfram-mathematica

我正在做以下操作在Mathematica中创建一个行循环(圆圈):

(* generate points on a circle *)
pts = Table[{a Cos[t], a Sin[t], 0}, {t, 0, 2 Pi, 0.1}];
(* add last segment *)
pts = Append[pts, {a, 0, 0}];
(* build tr... *)
(* ... *)
(* draw *)
Graphics3D[GeometricTransformation[Line[pts], tr]]

是否有更好的方法来创建表格以便重复第一个点?上面附加[]看起来很糟糕。

我没有使用Circle [],因为我需要在Graphics3D []中转换圆圈。我没有使用ParametricPlot3D,因为据我所知,我不能把它放在GeometricTransformation []中。

感谢您的任何建议。

此致

3 个答案:

答案 0 :(得分:3)

嗯,怎么样

segs=64.;
pts = Table[{a Cos[t], a Sin[t], 0}, {t, 0, 2 Pi, 2 Pi/segs}];

会创建一个包含segs+1段的列表,其中最后一段与第一段相同?

答案 1 :(得分:2)

您可以将曲线绘制为无面多边形:

pts = Table[{a Cos[t], a Sin[t], 0}, {t, 0, 2 Pi, 0.1}];
Graphics3D[GeometricTransformation[{FaceForm[],EdgeForm[Thin],Polygon[pts]}, tr]]

Graphics3D[{FaceForm[],EdgeForm[Thin],GeometricTransformation[Polygon[pts], tr]}]

答案 2 :(得分:1)

如果Append看起来很糟糕,“也许这更美观了?:

pts = {##,#}& @@ pts

或者,如果你是一个更加模糊的说服力,或许:

ArrayPad[pts, {0, 1}, "Periodic"]