# Simple Question, Is this a good practice?

hello guy super newbie here,

i just wanna ask if doing this is a good coding practice:

here in <a href = "http://www.jmonkeyengine.com/wiki/doku.php/starter:hello_lod" >"HelloLevelOfDetail" </a> at simpleUpdate() the author created static temp variables, which i discover that the program can work without it. The temp variables gets the same values assign to the variables that will be used.

and my next question is super noobish,

what does .normalizeLocal do? i tried printing a vector3f with and without .normalizeLocal and i got x=.xxxxvalue y=.xxxxvalue z=.xxxvalue they dont have the same values but they both have the x y and z.

thanks for replyingâ€¦ i just wanna clear those things before i continue.

Often people create static temp objects for performance, to save the need for creating and destroying a lot of objects every frame.

normalizeLocal sets the Vector to length 1.

Normalize means set to length 1, Local means it changes the vector directly instead of returning a new Vector3f.

normalize makes sure every attribute (x, y, z) make 1f in total. So 0.6, 0.2, 0.2 is a good example.

The local simply shows that it's done on the current Vector3f.

``` Vector3f vec1 = new Vector3f().normalizeLocal(); // vec1 is now normalized. Only one instance of Vector3f is present here. Vector3f vec2 = new Vector3f().normalize(); // vec2 is now normalized, only you used two instances (new Vector3f is one, and normalize is the second). As you can guess, this is inefficient. ```

Small correction as it's significant in many areas: normalize won't make the 3 components total 1, it will make the length of the line it represents 1 (a line from 0,0,0).

Alric said:

Small correction as it's significant in many areas: normalize won't make the 3 components total 1, it will make the length of the line it represents 1 (a line from 0,0,0).

Oh excuse me :) Thanks for the correction! :)

thank you very much, thats very clear now!

One late addition: A vector can do two things, it's like an arrow (0,0,0 to x,y,z) pointing at a location, and it also always has a direction. So it still has the same direction, but you lose the info what it originally pointed at, it's a very short but parallel copy of the vector.

On the other hand, a "normal" is a vector that is orthogonal, isn't it? The name of this method confuses me.

no its not, normal has nothing to do with normalize