Reputation: 5237
I am doing the following to create a line loop (circle) in 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]]
Is there a better way to create a table so that the first point is repeated? Append[] above looks bad.
I am not using Circle[] because I need to transform the circle in a Graphics3D[]. I am not using ParametricPlot3D because to my knowledge I can't put that inside a GeometricTransformation[].
Thanks for any suggestions.
Regards
Upvotes: 0
Views: 848
Reputation: 24336
If Append
"looks bad," perhaps this is more aesthetic?:
pts = {##,#}& @@ pts
Or, if you are of a more obscure persuation, perhaps:
ArrayPad[pts, {0, 1}, "Periodic"]
Upvotes: 1
Reputation: 6520
Well, how about
segs=64.;
pts = Table[{a Cos[t], a Sin[t], 0}, {t, 0, 2 Pi, 2 Pi/segs}];
which creates a list with segs+1
segments, the last of which is the same as the first?
Upvotes: 3
Reputation: 8577
You could draw the curve as a faceless polygon:
pts = Table[{a Cos[t], a Sin[t], 0}, {t, 0, 2 Pi, 0.1}];
Graphics3D[GeometricTransformation[{FaceForm[],EdgeForm[Thin],Polygon[pts]}, tr]]
or
Graphics3D[{FaceForm[],EdgeForm[Thin],GeometricTransformation[Polygon[pts], tr]}]
Upvotes: 2