如果声明包含无限数学方程式

Sam*_*rai 2 c#

我正在尝试执行代码,以使特定的无限数学条件成立.条件为真,使得值= 90 + 360X.其中X是整数.所以我正在使用单位圆,只想要等于正Y轴的度数.这是一张高亮橙色轴的图片.

在此输入图像描述

例如,角度90,450,810等将使条件成立.我已尝试在代码中使用%,如您所见:

else if (DegreeValue == 90 || ManyRotations90(DegreeValue, 90) == true)
        {
            Console.WriteLine("Angle(" + DegreeValue + ") lies between the 1st and 2nd quadrant. In other words, it doesn't belong to a specfic section.");
        }




static public bool ManyRotations90(double num01, double num02)
    {

        if (num01 % num02 == 0);
        {
            return true;
        }
        return false;

    }
Run Code Online (Sandbox Code Playgroud)

即使条件对于这些数字也会返回,但对于我不想要的数字也是如此.//这很好540%90 == 0.但是270%90 == 0 //这很糟糕.有没有这样的方式,它只适用于90 + 360X?

Mur*_*nik 6

你误用了%操作员.您需要将度数除以360(完整圆圈),并检查余数是否为90:

return DegreeValue % 360 == 90;
Run Code Online (Sandbox Code Playgroud)