can some help me conver this snipped please?

BlitzMax Forums/BlitzMax Programming/can some help me conver this snipped please?

NoOdle(Posted 2009) [#1]
It tests wether a polygon is convex or concave..


*/
Int Convex(XY *p,Int n)
{
Int i,j,k;
Int flag = 0;
double z;

If (n < 3)
Return(0);





For (i=0;i<n;i++) {
j = (i + 1) % n;
k = (i + 2) % n;
z = (p[j].x - p[i].x) * (p[k].y - p[j].y);
z -= (p[j].y - p[i].y) * (p[k].x - p[j].x);
If (z < 0)
flag |= 1;
Else If (z > 0)
flag |= 2;
If (flag == 3)
Return(CONCAVE);
}
If (flag != 0)
Return(CONVEX);
Else
Return(0);
}



Most of it is easy to convert, its the bitwise OR stuff that I get stuck on..

Thanks in advance :D


Jesse(Posted 2009) [#2]
Function Convex(p:XY[],n:Int)

	Local i:Int,j:Int,k:Int
	Local flag:Int = 0;
	Local z:Double
	
	If (n < 3) Return 0
		
	For i=0 Until n
		j = (i + 1) Mod n
		k = (i + 2) Mod n
		z = (p[j].x - p[i].x) * (p[k].y - p[j].y)
		z :- (p[j].y - p[i].y) * (p[k].x - p[j].x)
		If (z < 0)
			flag :| 1;
		Else 
			If (z > 0) flag :| 2
		EndIf
		If (flag = 3) Return(CONCAVE);
	Next
	If (flag <> 0)Return(CONVEX) Else Return 0
End Function

I hope you got the xy type, and the CONCAVE CONVEX constants defined somewhere because it is not going to do you any good as it is.

[edited] minor error in the For line


NoOdle(Posted 2009) [#3]
cheers Jesse! Yes I have the rest of the code to make it work ready, I just didn't know the syntax for the the bitwise OR in BM.

Thanks for the conversion :)