Home
Products
Community
Manuals
Contact
Login or Signup

Code archives/3D Graphics - Maths/TForm Vector

This code has been declared by its author to be Public Domain code.

Download source code

TForm Vector by Bobysait(Posted 1+ years ago)
It makes the same as the original TFormVector function
It's just here for purpose and to explain how blitz3d matrix works with transformation

I won't replace the TFormNormal as it is the same except it use a VectorMag to normalize the vector.


For eg: juste use TFormVector_ Vx,Vy,Vz,Source,Dest
Vx# = TFormedX_()
Vy# = TFormedY_()
Vz# = TFormedZ_()
Global TFormedX_#=0.0
Global TFormedY_#=0.0
Global TFormedZ_#=0.0

Function TFormedX_#() Return TFormedX_ End Function
Function TFormedY_#() Return TFormedY_ End Function
Function TFormedZ_#() Return TFormedZ_ End Function

Function TFormVector_(vx#,vy#,vz#, FromEntity%,ToEntity%=0)

	Local vx_#,vy_#,vz_#
	If FromEntity<>0
		vx_= vx* GetMatElement(FromEntity,0,0) + vy * GetMatElement(FromEntity,1,0)+ vz* GetMatElement(FromEntity,2,0)
		vy_= vx* GetMatElement(FromEntity,0,1) + vy * GetMatElement(FromEntity,1,1)+ vz* GetMatElement(FromEntity,2,1)
		vz_= vx* GetMatElement(FromEntity,0,2) + vy * GetMatElement(FromEntity,1,2)+ vz* GetMatElement(FromEntity,2,2)
		vx = vx_
		vy = vy_
		vz = vz_
	EndIf
	If ToEntity<>0
		vx_= vx* GetMatElement(ToEntity,0,0) + vy * GetMatElement(ToEntity,0,1)+ vz* GetMatElement(ToEntity,0,2)
		vy_= vx* GetMatElement(ToEntity,1,0) + vy * GetMatElement(ToEntity,1,1)+ vz* GetMatElement(ToEntity,1,2)
		vz_= vx* GetMatElement(ToEntity,2,0) + vy * GetMatElement(ToEntity,2,1)+ vz* GetMatElement(ToEntity,2,2)
		vx = vx_
		vy = vy_
		vz = vz_
	EndIf

	TFormedX_=vx
	TFormedY_=vy
	TFormedZ_=vz

End Function

Comments

DareDevil(Posted 1+ years ago)
is faster than the original?


bye


Bobysait(Posted 1+ years ago)
absolutely not
the original probably runs 4 or 5 times faster as it performs the same kind of operations .

As mentionned, it's for purpose only, not really for use.


Code Archives Forum