HP Forums

Full Version: Plotting curve f(x,y,z) with HP Prime
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does anyone know is there a way to plot a curve in 3-space with the HP Prime? For example, plot the circular helix defined by the parameterized vector r(t)=[a*sin(t), a*cos(t), c*t].
You can use the parametric app, but you'll have to transform the 3 dimensions down to 2. You do this through the use of rotation matrices - rotate about x, rotate about y, rotate about z (see wiki discussing 3D rotations for instance).

For example, if you rotate about x by -45 degrees, then rotate about z by 30 degrees, your rotation matrix is [[0.7071068, 0.3535534, -0.6123724], [0, 0.8660254, 0.5], [0.7071068, -0.3535534, 0.6123724]]. Your input vector is [a*sin(T), a*cos(T), c*T]. So you'd left multiply your rotation matrix with your input vector, then decide which two components to view.

Suppose you wanted to plot the new x and y projection. Then in the Parametric Symbolic View you'd enter X1(T) = 0.7071*A*SIN(T)+0.3536*A*COS(T)-0.6124*C*T and for Y1(T) = 0.8660*A*COS(T)+0.5*C*T. See screen shots.
[attachment=1222][attachment=1223]
Probably you're going to want a program where you enter the yaw, pitch, and roll angles and the function you want to plot, and the program does the rotation and configures X1(T) and Y1(T) for you.
Here's some code you can modify:

Code:
#cas
PPLOT(a,c,t0,tn,dt):=
BEGIN
  local n:=1,l;
  r(t):=[a*cos(t),a*sin(t),c*t];
  ptdef:=MAKELIST(r(X),X,t0,tn,dt);
  n:=size(ptdef)-1;
  ldef:=MAKELIST({X,X+1},X,1,n);
  l:=LINE_P(ptdef,ldef,
    {
      [[1,0,0,0],[0,1,0,0],[0,0,1,15]], 
      "N",
      {-160,-120,16*15},
      {-a,a,-a,a,c*t0,c*tn} 
    });
  freeze;
  return 0;
END;
#end

The matrix in the code is a 3x4 matrix used for perspective projection. The first three columns correspond to the 3x3 matrix resulting form the product of the three rotation matrices (about each axis). The last column is simply the eyepoint vector <0,0,d>. You'll need to adjust the 15 so that the distance d is larger than the distance from the center of the viewing box to the corner farthest from the center of the viewing box (similarly for the 16*15 value).

Edit: If you need help writing your own program, just post on the forums here and I'm sure someone will help. I've been thinking about creating a 3D parametric plot app but am already buried deep in other projects (also 3D related).
Hi Han,

Copied your program on my Prime but it won't work. There's no error but when I tried to run PPLOT, it won't run but there's a exclamation point (!) displayed on the screen.

Hope you can help me.

Thank you.

Regards,
Reference URL's