TFormNormal not working?

Blitz3D Forums/Blitz3D Programming/TFormNormal not working?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

big10p - the only difference between TFormNormal and TFormVector is that the length of the vector returned by TFormNormal is '1'.

Don't know if you already know this but this is how it works (beginning at the beginning)

A vector quantity represents a magnitude (or size) and a direction. A scalar quantity represents just a magnitude (or size).

TFormVector returns a vector.
TFormNormal returns a normalised vector, or a vector which has had its length scaled to '1' (also known as a unit vector). This is useful as it allows us to consider only the 'directional' quality of the vector.
To go from a vector to a normalised vector all you have to do is divide the components (x,y,z) by the length of the vector. In practice this looks something like this:

;components of a vector x,y,z
x#=123.0
y#=456.0
z#=789.0

;length of vector
magnitude#=sqr(x*x+y*y+z*z)
;if magnitude is zero then it does not make sense to talk of a direction for the vector, so should check that before performing division below.
;components of unit vector/normalised vector 
unit_x#=x/magnitude
unit_y#=y/magnitude
unit_z#=z/magnitude





Hope that helps somewhat.