MathGroup Archive 1998

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

Search the Archive

RE: How draw 3D Arrows?



Here is some code I use.
It also display text. youmight want to take it out.

Clear[Arrow3D];
Arrow3D[start_,end_,colorDir_,s_]:=Module[
		{th,tf,mat,v1,v2,v3},
th=.1;
tf=.05;
		(* Build the matrice that will rotate the arrow into position *)
	v1 = end-start;
	v2 = Cross[{1,0,0},v1];
		If[v2.v2< (v1.v1)/100, v2 = Cross[{0,1,0},v1]];
		
		
	 v2 = Sqrt[v1.v1]/Sqrt[v2.v2] v2;
		v3 = Cross[v1,v2];
		 v3 = Sqrt[v1.v1]/Sqrt[v3.v3] v3;
		mat = Transpose[{v1,v2,v3}];
		
		{colorDir,
		                 Line[{start,start+ mat.{1,0,0}}],
		                     	 EdgeForm[colorDir], 
	                          SurfaceColor[colorDir],
		                  
      Polygon[{start+ mat.{1-th,tf,tf},start+ mat.{1-th,-tf,-tf},
          start+ mat.{1,0,0}}],
		                  
      Polygon[{start+ mat.{1-th,-tf,tf},start+ mat.{1-th,tf,-tf},
          start+ mat.{1,0,0}}],
		colorDir
			 ,
		Text[s,end,{1,-1}] 
		
			}
	];


>-----Original Message-----
>From:	tharter@nswc.navy.mil [SMTP:tharter@nswc.navy.mil]
To: mathgroup@smc.vnet.net
>Sent:	Monday, March 02, 1998 8:12 PM
>To:	mathgroup@smc.vnet.net
>Subject:	[mg11237] How draw 3D Arrows?
>
>Hi All;
>    While I realize that the 'Arrow' package of Mathematica can draw
>*two-dimensional" arrows, the package fails at giving a 3D arrow. 
>Anyone  have any ideas or suggestions?   Say I have  2, distinct 3-dim
>points {a,b,c} and {x,y,z}, how do I then draw a 3-dim arrow from
>{a,b,c} to {x,y,z} with the "head" of the arrow at {x,y,z}?   I could
>find nothing on this in MathSource.  Many thanks in advance! .....Terry
>
>



  • Prev by Date: Re: Simple question
  • Next by Date: THE ANSWERS: how to pull real numbers out of a linear funktion
  • Prev by thread: Re: How draw 3D Arrows?
  • Next by thread: Re: How draw 3D Arrows?