Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a function, r[t], which is a piecewise function that generates a 3D vector. It looks like this:

r[t_] = Piecewise[{{{5 t, 0, 3 (1 + Cos[t])}, 0 <= t <= π}, 
{{5 Cos[t - 3  π/2] + 5*π, 5 Sin[t - 3 π/2] + 5, 0},  π < t <= 2 π}, 
{{5*π + 3*Cos[t - 3 π/2], 2*5 - 3 + 3*Sin[t - 3 π/2],  1/(2 π) (t - 2 π)^2}, 
 2 π < t <= 4 π}, 
{{-3 (t - 17 π/3), 10, -1/π t^2 + 10 t - 22 π},   4 π < t <= 5 π}, 
{{-3 t + 17 π, 10, -972 π + 540 t - (99 t^2)/π + (6 t^3)/π^2}, 
  5 π < t <= 6 π}, 
{{-π - 3 Sin[t], 9/40 (1/3 (20 + 18 π) - t)^2, 3 Cos[t] - 3}, 6 π < t <= 8 π}, 
{{-25 π + 25 t - (19 t^2)/(4 π) + t^3/(4 π^2),  -(25/2) (140 - 132 π + 27 π^2) + 
(15 (80 - 74 π + 15 π^2) t)/(2 π) -  (3 (180 - 164 π + 33 π^2) t^2)/(8 π^2) - 
((-50 + 45 π - 9 π^2) t^3)/(20 π^3), 1056 - (360 t)/π + (81 t^2)/(2 π^2) - (3 t^3)/(2 π^3)},
   8 π < t <= 10 π}}];

I am very new to Mathematica (this is my first day using it), and I am unsure of how to plot this function in a 3D space. I have tried Plot3D and VectorPlot3D, but neither seems to offer a good way to do this (that I can think of). How might I go about plotting the function?

share|improve this question
1  
Have you looked at ParametricPlot3D? That's the function you need... i.stack.imgur.com/WC16T.png –  rm -rf Sep 13 '12 at 1:43
    
@R.M That, sir, is the answer I was looking for. I feel really stupid now, I guess knew it was parametric really, but... I don't know, there's no excuse for a brain fart of that proportion. –  Ben7005 Sep 13 '12 at 1:48
1  
No worries; to brain fart is human, after all :) You can write down the answer yourself, explain it and include a picture... Would be a good way to start out :) –  rm -rf Sep 13 '12 at 1:50
    
How would I add points to my plot? Is that an option in ParametricPlot3D or do you feed the produced graph to another function? –  Ben7005 Sep 13 '12 at 1:54
1  
See this question and its answers... I would suggest using a sphere for 3D (see JM's answer) –  rm -rf Sep 13 '12 at 2:02

1 Answer 1

up vote 4 down vote accepted
r[t_] := Piecewise[
   {{{5 t, 0, 3 (1 + Cos[t])}, 0 <= t <= Pi},
   {{5 Cos[t - 3 Pi/2] + 5*Pi, 5 Sin[t - 3 Pi/2] + 5, 0}, Pi < t <= 2 Pi},
   {{5*Pi + 3*Cos[t - 3 Pi/2], 2*5 - 3 + 3*Sin[t - 3 Pi/2], 1/(2 Pi) (t - 2 Pi)^2}, 2 Pi < t <= 4 Pi},
   {{-3 (t - 17 Pi/3), 10, -1/Pi t^2 + 10 t - 22 Pi}, 4 Pi < t <= 5 Pi}, 
   {{-3 t + 17 Pi, 10, -972 Pi + 540 t - (99 t^2)/Pi + (6 t^3)/Pi^2}, 5 Pi < t <= 6 Pi}, 
   {{-Pi - 3 Sin[t], 9/40 (1/3 (20 + 18 Pi) - t)^2, 3 Cos[t] - 3}, 6 Pi < t <= 8 Pi},
   {{-25 Pi + 25 t - (19 t^2)/(4 Pi) + t^3/(4 Pi^2), -(25/2) (140 - 132 Pi + 27 Pi^2) + (15 (80 - 74 Pi + 15 Pi^2) t)/(2 Pi) - (3 (180 - 164 Pi + 33 Pi^2) t^2)/(8 Pi^2) - ((-50 + 45 Pi - 9 Pi^2) t^3)/(20 Pi^3), 1056 - (360 t)/Pi + (81 t^2)/(2 Pi^2) - (3 t^3)/(2 Pi^3)}, 8 Pi < t <= 10 Pi}}];

Show[ParametricPlot3D[r[t], {t, 0, 10 Pi}, PlotStyle -> Directive[Purple, Thick], PlotRange -> Full, 
  Boxed -> False, Axes -> False], 
    ListPointPlot3D[Table[r[x], {x, 0, 10 Pi, Pi/5}], PlotStyle -> {PointSize[Large], Red}]]

Mathematica graphics

share|improve this answer
    
Thanks, I already had the solution from R.M, but this made it easier to see how to plot points on it. –  Ben7005 Sep 13 '12 at 2:20
2  
@Ben7005 another way to add points to the plot is to use the Mesh option in ParametricPlot3D. There are some examples in the Examples > Options > Mesh section of the documentation of ParametricPlot3D. –  Heike Sep 13 '12 at 6:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.