MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: 3D Arrows

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88132] RE: [mg88114] 3D Arrows
  • From: "Jose Luis Gomez" <jose.luis.gomez at itesm.mx>
  • Date: Sat, 26 Apr 2008 03:41:40 -0400 (EDT)
  • References: <200804250928.FAA08122@smc.vnet.net>

(* The following code defines a very simple command for 3d arrows, *)
(* copy-paste to Mathematica and press Shift-Enter, *)
(* no-output will be generated, but the new arrow3d command *)
(* will be ready to be used, see example below *)

arrow3d[{x1_, y1_, z1_}, {dx_, dy_, dz_}] := 
  arrow3d[{{x1, y1, z1}, {x1 + dx, y1 + dy, z1 + dz}}];
arrow3d[{x1_, y1_, z1_}, d_] := 
  arrow3d[{{x1, y1, z1}, {x1 + d, y1 + d, z1 + d}}];
arrow3d[{{x1_, y1_, z1_}, {x2_, y2_, z2_}}] :=
  Module[{vector, magnitud, normal, vectornormal, cruz, 
    vectorbinormal},
   vector = {x2 - x1, y2 - y1, z2 - z1};
   magnitud = Norm[vector];
   normal = {0, z1 - z2, y2 - y1};
   vectornormal = magnitud*normal/Norm[normal];
   cruz = Cross[vector, vectornormal];
   vectorbinormal = magnitud*cruz/Norm[cruz];
   {Cylinder[{{x1, y1, z1}, {x1, y1, z1} + 0.8 vector}, 
     0.01 magnitud],
    Polygon[{{x1, y1, z1} + 0.8 vector + 
       0.1 vectornormal, {x1, y1, z1} + 0.8 vector - 
       0.1 vectornormal, {x2, y2, z2}}],
    Polygon[{{x1, y1, z1} + 0.8 vector + 
       0.1 vectorbinormal, {x1, y1, z1} + 0.8 vector - 
       0.1 vectorbinormal, {x2, y2, z2}}]}
   ];


(* EXAMPLE: After evaluating (Shift-Enter) the code above, evaluate *)
(* the example below *)

Graphics3D[{Sphere[{1, 1, 1}, 0.2], 
  arrow3d[{{1.5, 1, 1}, {2, 2, 2}}], 
  arrow3d[{{1.5, 0, 1}, {-2, -2, 2}}]}, PlotRange -> All] 

(* hope that helps *)
(* Jose *)
(* Mexico *)

-----Mensaje original-----
De: Robert M. Lurie [mailto:RMLURIE at ALUM.MIT.EDU] 
Enviado el: Viernes, 25 de Abril de 2008 04:28 a.m.
Para: mathgroup at smc.vnet.net
Asunto: [mg88114] 3D Arrows

Apparently Arrows is only a 2D graphic. Is there a way to make an arrow 
in 3D?
Robert M Lurie





  • References:
    • 3D Arrows
      • From: "Robert M. Lurie" <RMLURIE@ALUM.MIT.EDU>
  • Prev by Date: Re: Re: Re: installing Playe rPro killed using
  • Next by Date: Re: 2*m^z - m^z = ?
  • Previous by thread: Re: 3D Arrows
  • Next by thread: Re: 3D Arrows