c#

时间:2016-05-28 01:16:43

标签: c# distance angle

我正在研究我在C#中的第一个程序,并且我在计算距离和角度方程时遇到了问题。我的目的是提示X1,Y1值,X2,Y2值,并计算两点之间的距离和角度。我将在下面粘贴我的(非常可怕的)代码。在此先感谢您的帮助!

        //prompt and store the x and y for two points
        Console.WriteLine("Please enter X1:");
        float point1X = float.Parse(Console.ReadLine());
        Console.WriteLine("Please enter Y1:");
        float point1Y = float.Parse(Console.ReadLine());
        Console.WriteLine("Please enter X2:");
        float point2X = float.Parse(Console.ReadLine());
        Console.WriteLine("Please enter Y2:");
        float point2Y = float.Parse(Console.ReadLine());
        Console.WriteLine("");

        //calculate the distance
        double deltaX= Math.Pow(point2X - point1X, 2);
        double deltaY= Math.Pow(point2Y - point1Y, 2);
        Console.WriteLine("double deltaX, double deltaY");
        Console.WriteLine("");

        //calculate the angle
        double angle = Math.Atan2(deltaX, deltaY);
        Console.WriteLine("double angle");
        Console.WriteLine("");

1 个答案:

答案 0 :(得分:0)

如果您搜索的是这样的,那就是数学,而不是C#;-):

function format(icon) {
    var originalOption = icon.element;
    return '<i class="fa ' + $(originalOption).data('icon') + '"></i> ' + icon.text;
}
$('.wpmse_select2').select2({
    width: "100%",
    formatResult: format
});