Could someone convert a little c maths code for me

Miscellaneous Forums/General Discussion/Could someone convert a little c maths code for me

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.

switch(trans)
	{
		case 0:	for(i=1;i<nRows-1;i++)
					for(j=1;j<nCols-1;j++)
					{
						dis->SetDisplacement(j,i,cosf(t*10+(i+j)/2)*5,sinf(t*10+(i+j)/2)*5,HGEDISP_NODE);
					}
				break;

		case 1:	for(i=0;i<nRows;i++)
					for(j=1;j<nCols-1;j++)
					{
						dis->SetDisplacement(j,i,cosf(t*5+j/2)*15,0,HGEDISP_NODE);
						col=int((cosf(t*5+(i+j)/2)+1)*35);
						dis->SetColor(j,i,0xFF<<24 | col<<16 | col<<8 | col);
					}
				break;

		case 2:	for(i=0;i<nRows;i++)
					for(j=0;j<nCols;j++)
					{
						r=sqrtf(powf(j-(float)nCols/2,2)+powf(i-(float)nRows/2,2));
						a=r*cosf(t*2)*0.1f;
						dx=sinf(a)*(i*cellh-256)+cosf(a)*(j*cellw-256);
						dy=cosf(a)*(i*cellh-256)-sinf(a)*(j*cellw-256);
						dis->SetDisplacement(j,i,dx,dy,HGEDISP_CENTER);
						col=int((cos(r+t*4)+1)*40);
						dis->SetColor(j,i,0xFF<<24 | col<<16 | (col/2)<<8);
					}
					break;
	}



I know switch is synonymous with select, and I have a type to match the class. That's not the problem. I think i've just messed up converting the maths.

I have the following, but I think it's wrong :

'// Calculate New displacements And coloring For one of the three effects
	Select trans
	
		Case 0
			For i=1 To nRows-1
				For j=1 To nCols-1
				
					dis.SetDisplacement(j,i,Cos(t*10+(i+j)/2)*5,Sin(t*10+(i+j)/2)*5,HGEDISP_NODE)
					
				Next
			Next

		Case 1
			For i=0 To nRows
					For j=1 To nCols-1
					
						dis.SetDisplacement(j,i,Cos(t*5+j/2)*15,0,HGEDISP_NODE)
						col=Int((Cos(t*5+(i+j)/2)+1)*35)
						dis.SetColor(j,i,$FF Shl 24 | col Shl 16 | col Shl 8 | col)
						
					Next
			Next
			

		Case 2
			For i=0 To nRows
				For j=0 To nCols
					
					r=Sqr(((j-nCols/2.0)^2)+((i-nRows/2.0)^2))
					a=r*Cos(t*2)*0.1
					dx=Sin(a)*(i*cellh-256)+Cos(a)*(j*cellw-256)
					dy=Cos(a)*(i*cellh-256)-Sin(a)*(j*cellw-256)
					Dis.SetDisplacement(j,i,dx,dy,HGEDISP_CENTER)
					col=Int((Cos(r+t*4)+1)*40)
					dis.SetColor(j,i,$FF Shl 24 | col Shl 16 | (col/2) Shl 8)
						
				Next
			Next
			
	End Select