Angle difference
#3
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:
Reply


Messages In This Thread
Angle difference - by bplus - 01-31-2023, 05:04 PM
RE: Angle difference - by MasterGy - 01-31-2023, 05:50 PM
RE: Angle difference - by OldMoses - 01-31-2023, 06:15 PM
RE: Angle difference - by bplus - 01-31-2023, 06:44 PM
RE: Angle difference - by OldMoses - 01-31-2023, 07:33 PM
RE: Angle difference - by bplus - 01-31-2023, 08:12 PM
RE: Angle difference - by OldMoses - 01-31-2023, 10:32 PM
RE: Angle difference - by SMcNeill - 01-31-2023, 09:29 PM
RE: Angle difference - by bplus - 01-31-2023, 10:03 PM



Users browsing this thread: 4 Guest(s)