Professor Sherwood,
I have a quick question about the mag/mag2 functionality that you
explained where you can explicitly set the variable mag equal to a value.
Does the syntax "v.mag = X" maintain the direction of the vector v, but
setting it's magnitude to X? Say we perform the code:
v = vector(5,10,15) #arbitrary direction & magnitutude
v.mag = 1
Would this make the vector v into a unit vector in the same direction?
Just curious... Thanks a bundle!
-- Will Chase
Sophomore Astro Major
CMU
On Sun, 7 Jul 2002, Bruce Sherwood wrote:
> Thanks to Arthur Siegel for suggesting making the mag2 function available.
> This function for vectors gives the square of the magnitude of a vector:
>
> v = vector(1,2,3) # a vector whose magnitude is 14
> mag(v) or v.mag is sqrt(14)
> mag2(v) or v.mag2 is 14
>
> Not previously documented for mag, and now also available for mag2, is the
> possibility of setting the associated attribute for a vector:
>
> v.mag = 5 # make the magnitude of v be 5
> v.mag2 = 2.7 # make the square of the magnitude of v by 2.7
>
> At http://vpython.org there are new files associated with mag2:
> documentation, the visual folder, source, Windows DLL, and a full Windows
> installer. Haven't yet updated installers for Linux or Macintosh.
>
> Bruce Sherwood
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> We have stuff for geeks like you.
> http://thinkgeek.com/sf
> _______________________________________________
> Visualpython-users mailing list
> Vis...@li...
> https://lists.sourceforge.net/lists/listinfo/visualpython-users
>
|