rotation of items, not using matrix

Open discussion forum. For topics that do not fit anywhere else.

Moderator: POL Developer

Post Reply
guialtran
Adept Poster
Posts: 84
Joined: Wed Jul 30, 2008 12:42 pm

rotation of items, not using matrix

Post by guialtran » Thu Jul 05, 2018 12:53 pm

this function is very similar to TurnBoat (boat, direction), is made to rotate items that are not in an matrix.

Code: Select all

//DIRection 1=right, 2=flip, 3=left

my_RotatePoint( who, struct{"x":=item.x,"y":=item.y} , 1);


function my_RotatePoint( byref pivo, byref ponto , dir)
	var difx;
	var dify;
	if(ponto.y < pivo.y)
		if(ponto.x < pivo.x)//quadrante(<^)
			difx := (pivo.x-ponto.x);
			dify := (pivo.y-ponto.y);
			if(dir == 1)//1=right
				ponto.x := (pivo.x+dify);
				ponto.y := (pivo.y-difx);
			elseif(dir == 2)//2=flip
				ponto.x := (pivo.x+difx);
				ponto.y := (pivo.y+dify);
			else//3=left
				ponto.x := (pivo.x-dify);
				ponto.y := (pivo.y+difx);
			endif
		else//quadrante(^>)
			difx := (ponto.x-pivo.x);
			dify := (pivo.y-ponto.y);
			if(dir == 1)//1=right
				ponto.x := (pivo.x+dify);
				ponto.y := (pivo.y+difx);
			elseif(dir == 2)//2=flip
				ponto.x := (pivo.x-difx);
				ponto.y := (pivo.y+dify);
			else//3=left
				ponto.x := (pivo.x-dify);
				ponto.y := (pivo.y-difx);
			endif
		endif
	else
		if(ponto.x > pivo.x)//quadrante(V>)
			difx := (ponto.x-pivo.x);
			dify := (ponto.y-pivo.y);
			if(dir == 1)//1=right
				ponto.x := (pivo.x-dify);
				ponto.y := (pivo.y+difx);
			elseif(dir == 2)//2=flip
				ponto.x := (pivo.x-difx);
				ponto.y := (pivo.y-dify);
			else//3=left
				ponto.x := (pivo.x+dify);
				ponto.y := (pivo.y-difx);
			endif
		else//quadrante(<V)
			difx := (pivo.x-ponto.x);
			dify := (ponto.y-pivo.y);
			if(dir == 1)//1=right
				ponto.x := (pivo.x-dify);
				ponto.y := (pivo.y-difx);
			elseif(dir == 2)//2=flip
				ponto.x := (pivo.x+difx);
				ponto.y := (pivo.y-dify);
			else//3=left
				ponto.x := (pivo.x+dify);
				ponto.y := (pivo.y+difx);
			endif
		endif
	endif
endfunction
there is only the calculation of mathematics.
you can adapt it to receive 1 object or a list.

guialtran
Adept Poster
Posts: 84
Joined: Wed Jul 30, 2008 12:42 pm

Re: rotation of items, not using matrix

Post by guialtran » Thu Jul 05, 2018 1:11 pm


Post Reply