i think thats what your after isn't it?
function VectorNormalize( Vec as dword )
`{
local length as double integer
local i as integer
local dim v(3) as float
v(0)=x vector3(Vec) : v(1)=y vector3(Vec) : v(2)=z vector3(Vec)
length = 0
for i=0 to 2
length = length+(v(i)*v(i))
next i
length = sqrt(length)
for i=0 to 2
v(i) = v(i)/length
next i
set vector3 Vec3,v(0),v(1),v(2)
undim v(3)
endfunction length
`} double integer | Vector3
function DotProduct( Vec1 as dword, Vec2 as dword )
`{
local result as float
result = (x vector3(Vec1)*x vector3(Vec2)) + (y vector3(Vec1)*y vector3(Vec2)) + (z vector3(Vec1)*z vector3(Vec2))
endfunction result
`} float
function LightSourceNormalize( lightVec as dword, matVec as dword )
`{
local i as integer
local dp as float
local dim v1(3) as float
local dim v2(3) as float
local length as double integer = VectorNormalize( matVec )
v1(0)=x vector3(lightVec) : v1(1)=y vector3(lightVec) : v1(2)=z vector3(lightVec)
v2(0)=x vector3(matVec) : v2(1)=y vector3(matVec) : v2(2)=z vector3(matVec)
dp = DotProduct( matVec, lightVec )
v2(2) = sin( v1(1) ) * length
v2(1) = ( cos( dp ) * length ) * cos( v1(2) )
v2(3) = ( sin( dp ) * length ) * cos( v1(2) )
undim v1(3)
undim v2(3)
endfunction
`} void | Vector3
Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?