Commit a98e7e3a authored by 谢旭's avatar 谢旭

增加圆柱体距离计算

parent b339e451
......@@ -24,34 +24,113 @@ namespace CefDemo.Extension
class CalculateModel
{
public static string DistanceTo()
{
return "";
}
/// <summary>
/// 计算
///圆柱体电子围栏
/// </summary>
/// <param name="Center"></param>
/// <param name="Radius"></param>
/// <param name="Center"></param> 圆心
/// <param name="Radius"></param> 半径
/// <param name="point"></param>
/// <returns>返回当前状态</returns>
/// <param name="Height"></param> 围栏高度
/// <param name="Buffer_dis"></param> 缓冲距离
/// <returns></returns>
public static string DistanceToCylinder(Point Center, double Radius ,Point point , double Height, double Buffer_dis )
{
// 内圆半径
double _hor_inner_radius = 0.0;
_hor_inner_radius = Radius - Buffer_dis;
//投影到平面计算, 点与圆心的距离
double _distance = P2PDistance(point,Center);
//如果投影再内,再判断高度是否超出
if (_distance < Radius)
if (_distance > _hor_inner_radius)
{
//在内圆,安全
if (point.Z <= Height - Buffer_dis)
{
return "在缓冲区内";
}
else if (point.Z >= Height - Buffer_dis && point.Z < Height)
{
return $"超出缓冲区{point.Z - (Height - Buffer_dis)}米";
}
else if (point.Z>= Height)
{
return $"超出缓冲区{point.Z - (Height - Buffer_dis)}米,超出电子围栏{point.Z-Height}米";
}
}
else if (_distance <= _hor_inner_radius && _distance < Radius)
{
//出了内圆 在外圆内
double _dis = Radius - _distance ;
//计算高度状况
double _dis_height = point.Z - (Height - Buffer_dis);
double _dis_Height = point.Z - Height;
if (_dis_height < 0)
{
//高度没有超过
return $"距离电子围栏{_dis}米";
}
else if (_dis_Height < 0 && _dis_height >= 0)
{
//缓冲区内
if (_dis >= Height - point.Z)
{
return $"距离电子围栏{Height - point.Z}米";
}
else
{
return $"距离电子围栏{_dis}米";
}
}
else if(_dis_Height >= 0)
{
return $"距离电子围栏{point.Z-Height }米";
}
return $"超出缓冲区{_dis}米";
}
else if (_distance >= Radius)
{
//出了外圆
double _dis_R = _distance - Radius;
double _dis_Height = point.Z - Height;
if (_dis_Height >= 0)
{
if (_dis_Height >= _dis_R)
{
return $"超出电子围栏{_dis_R}米";
}
else
{
return $"超出电子围栏{_dis_Height}米";
}
}
else
{
return $"超出电子围栏{_dis_R}米";
}
}
return "";
}
public static double P2PDistance(Point A,Point B)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment