Exemple #1
0
        public void TestAngle()
        {
            Vec2 a = new Vec2(1, 0);
            Vec2 b = new Vec2(0, 1);
            Vec2 c = new Vec2(-1, 0);

            Assert.AreEqual(0, Vec2.Angle(a, a));
            Assert.AreEqual(Math.PI, Vec2.Angle(a, c));     //180deg
            Assert.AreEqual(Math.PI / 2, Vec2.Angle(a, b)); // 90 deg
        }
Exemple #2
0
    static bool TestAngles()
    {
        /// :CodeSample: Vec2.Angle
        Vec2  point  = new Vec2(1, 0);
        float angle0 = point.Angle();

        point = new Vec2(0, 1);
        float angle90 = point.Angle();

        point = new Vec2(-1, 0);
        float angle180 = point.Angle();

        point = new Vec2(0, -1);
        float angle270 = point.Angle();

        /// :End:

        point = new Vec2(2.75f, 2.75f);
        float angle45 = point.Angle();

        Log.Info($"Angles 0 == {angle0}, Angles 45 == {angle45}, 90 == {angle90}, 180 == {angle180}, 270 == {angle270}");
        return(angle0 == 0 && angle90 == 90 && angle180 == 180 && angle270 == 270);
    }