01-31-2023, 06:15 PM
If I'm understanding the problem correctly, I put this in terms of your code, more or less. It's just a dot product function that checks if the angle projection is greater than the COS of 30 degrees. It worked for the example at least.
Code: (Select All)
TYPE SpinnerType
x AS SINGLE
y AS SINGLE
dx AS SINGLE
dy AS SINGLE
a AS SINGLE
sz AS SINGLE
c AS _UNSIGNED LONG
END TYPE
less30 = COS(_D2R(30))
DIM AS SpinnerType s1, s2, s3
s1.dx = 5
s1.dy = 5
s2.dx = 5
s2.dy = 0
s3.dx = 5
s3.dy = 4
PRINT "s1 & s2"
IF Spinner_Dot(s1, s2) >= less30 THEN
PRINT "same general direction"
ELSE
PRINT "Divergent direction"
END IF
PRINT "s1 & s3"
IF Spinner_Dot(s1, s3) >= less30 THEN
PRINT "same general direction"
ELSE
PRINT "Divergent direction"
END IF
END
FUNCTION Spinner_Dot! (a AS SpinnerType, b AS SpinnerType)
ha! = _HYPOT(a.dx, a.dy)
hb! = _HYPOT(b.dx, b.dy)
Spinner_Dot! = (a.dx / ha!) * (b.dx / hb!) + (a.dy / ha!) * (b.dy / hb!)
END FUNCTION
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
sha_na_na_na_na_na_na_na_na_na: