I am working on a class of vectors in JSL. I would like to have a method that would return a normalized version of the vector. Below is my script and error message. Thanks!
Clear Log();
Clear Globals();
Define Class(
"vector",
x = 0;
y = 0;
z = 0;
_init_ = Method( {a, b, c = 0},
x = a;
y = b;
z = c;
);
_show_ = Method( {},
Return( x, y, z )
);
mag = Method( {},
magnitude = Sqrt( x ^ 2 + y ^ 2 + z ^ 2 )
);
normalize = Method( {},
nv = vector(0,0,0);
length = Sqrt( x ^ 2 + y ^ 2 + z ^ 2 );
show(length);
nv:x = x / length;
nv:y = y / length;
nv:z = z / length;
nv;
);
);
bob = New Object( vector( 4, 2 ) );
Show( bob );
bob<<normalize();Name Unresolved: vector in access or evaluation of 'vector' , vector( 0, 0, 0 )