示例#1
0
    bool TestVector2Angles()
    {
        float angle43 = Vec2.AngleBetween(Vec2.FromAngle(0), Vec2.FromAngle(43));
        float angle16 = Vec2.AngleBetween(Vec2.FromAngle(27), Vec2.FromAngle(43));
        float angle74 = Vec2.AngleBetween(Vec2.FromAngle(117), Vec2.FromAngle(43));

        Log.Info($"Vec2.AngleBetween(Vec2.FromAngle(0  ), Vec2.FromAngle(43)): {angle43} - expected 43");
        Log.Info($"Vec2.AngleBetween(Vec2.FromAngle(27 ), Vec2.FromAngle(43)): {angle16} - expected 16");
        Log.Info($"Vec2.AngleBetween(Vec2.FromAngle(117), Vec2.FromAngle(43)): {angle74} - expected -74");

        if (MathF.Abs(angle43 - 43) > tolerance)
        {
            return(false);
        }
        if (MathF.Abs(angle16 - 16) > tolerance)
        {
            return(false);
        }
        if (MathF.Abs(angle74 + 74) > tolerance)
        {
            return(false);
        }
        return(true);
    }