	program wtest
#
# testet die Winkel-Berechnungen von PRIMEX.
#
# Version 1.0	21.07.84
#
logical	first
integer	dx,dy		# Koord'inkremente
integer	p1x,p1y,p2x,p2y	# Anfangs- und Endpunkt der term.Strecke
integer	winkl1,winkl2	# absolute Winkel zur x-Achse
integer	dwinkl		# Differenzwinkel
integer	awinkl		# function; liefert absoluten Winkel
integer	wsum		# Winkelsumme
#
#
write(1,1)
1 format('0WTEST - von ')
read(1,2) p2x,p2y
2 format(2i4)
winkl2=0
wsum=180
first=.true.
repeat
[
p1x=p2x ; p1y=p2y
write(1,4) p1x,p1y
4 format('0WTEST - von ',2i4)
write(1,10)
10 format(' nach ')
read(1,2) p2x,p2y
#
winkl1=winkl2
winkl2=awinkl(p2x-p1x,p2y-p1y)
dwinkl = mod(winkl2-winkl1+540,360)
if (first) first=.false.
else wsum = wsum+(dwinkl-180)
#
write(1,20) winkl1,winkl2
20 format(' winkl1,2 = ',2i4)
write(1,30) dwinkl
30 format(' dwinkl = ',i4)
write(1,40) wsum
40 format(' Wsum = ',i4)
] until (p2x==0 && p2y==0)
write(1,90)
90 format('0*** WTEST - Ende ***')
end


	integer function awinkl(dx,dy)
#
# liefert den Winkel zur x-Achse, der durch die Steigungsinkremente dx und dy 
# gegeben ist. 0 <= awinkl < 360 Grad.
#
integer	dx,dy
real	a,c
data	c/57.29577/	# Umrechnungkonstante 180/pi
#
if (dx==0)
[	if (dy<<0) awinkl=270
	else	if (dy==0) awinkl=0
		else awinkl=90
]
else
[	a=c*atan(float(dy)/float(dx))	# atan liefert -pi/2 < a < +pi/2
	if (a<<0) awinkl=ifix(a-0.5)
	else awinkl=ifix(a+0.5)
	if (dx<<0) awinkl=awinkl+180
	else	if (dy<<0) awinkl=awinkl+360
]
return
end
