Tag: 距离

用C#计算马哈拉诺比斯距离

我正在尝试用c#计算马哈拉诺比斯距离。 我在网上找不到任何真正好的例子,我是C#的新手。 我特别难以让协方差矩阵运行正常。 任何帮助,将不胜感激。 谢谢! using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MathNet.Numerics.LinearAlgebra.Double; namespace MahalanobisDistance { class Program { static void Main(string[] args) { Program p = new Program(); DenseVector vector1 = new DenseVector(4); DenseVector vector2 = new DenseVector(4); DenseMatrix matrix1 = new DenseMatrix(vector1.Count/2); vector1[0] = 1; vector1[1] = 2; vector1[2] […]

数学计算检索两点之间的角度?

可能重复: 如何计算两点相对于水平轴的角度? 我一直在寻找这个年龄,这真的很烦我,所以我决定只问… 如果我有两个点(即x1,y1和x2,y2),我想计算这两个点之间的角度,假设当y1 == y2且x1> x2时角度为180度…… 我有以下代码,我一直在使用(使用高中的知识),我似乎无法产生预期的结果。 float xDiff = x1 – x2; float yDiff = y1 – y2; return (float)Math.Atan2(yDiff, xDiff) * (float)(180 / Math.PI); 在此先感谢,我变得非常沮丧……

如何测量对角线距离点?

我可以计算水平和垂直点,但我无法弄清楚如何使用对角点计算距离。 有人可以帮我弄这个吗。 这是我的水平和垂直测量的代码: private float ComputeDistance(float point1, float point2) { float sol1 = point1 – point2; float sol2 = (float)Math.Abs(Math.Sqrt(sol1 * sol1)); return sol2; } protected override void OnMouseMove(MouseEventArgs e) { _endPoint.X = eX; _endPoint.Y = eY; if (ComputeDistance(_startPoint.X, _endPoint.X) <= 10) { str = ComputeDistance(_startPoint.Y, _endPoint.Y).ToString(); } else { if (ComputeDistance(_startPoint.Y, _endPoint.Y) <= 10) […]