Declaring variables mid-function changes results

BlitzMax Forums/BlitzMax Programming/Declaring variables mid-function changes results


Don't see how he could have removed anything that would not mean his code is broken for Strict/SuperStrict. If x is not defined before the first if chain starts where it is used.



Did you not read what I wrote? That code is COMMENTED OUT.

Here is his code with all the commented out stuff removed:

Method Rotation:TQuat()

	Local fourWSquaredMinus1:Float = +ix+jy+kz
	Local fourXSquaredMinus1:Float = +ix-jy-kz
	Local fourYSquaredMinus1:Float = +jy-ix-kz
	Local fourZSquaredMinus1:Float = +kz-ix-jy
	Local biggestIndex=0
	Local fourBiggestSquaredMinus1:Float=fourWSquaredMinus1

	If fourXSquaredMinus1 > fourBiggestSquaredMinus1
		fourBiggestSquaredMinus1 = fourXSquaredMinus1 
		biggestIndex=1
	EndIf

	If fourYSquaredMinus1 > fourBiggestSquaredMinus1
		fourBiggestSquaredMinus1 = fourYSquaredMinus1 
		biggestIndex=2
	EndIf

	If fourZSquaredMinus1 > fourBiggestSquaredMinus1
		fourBiggestSquaredMinus1 = fourZSquaredMinus1 
		biggestIndex=3
	EndIf

	Local biggestValue:Float=Sqr(fourBiggestSquaredMinus1+1.0)*0.5
	Local mult:Float=0.25/biggestValue
	Local x#,y#,z#,w#

	Select BiggestIndex

		Case 0
			w#=BiggestValue
			x#=(jz-ky)*mult
			y#=-(kx-iz)*mult
			z#=-(iy-jx)*mult

		Case 1
			x#=-BiggestValue
			w#=-( jz - ky )*mult
			y#=( iy + jx )*mult
			z#=( kx + iz )*mult

		Case 2
			y#=BiggestValue
			w#=-(kx-iz)*mult
			x#=-(iy+jx)*mult
			z#=(jz+ky)*mult

		Case 3
			z#=-BiggestValue
			w#=(iy-jx)*mult
			x#=(kx+iz)*mult
			y#=-(jz+ky)*mult
	EndSelect

	Return quat(-x,y,z,w)

EndMethod


You show me where he's using x,y,z, or w before he declares them.