我需要根据圆柱形物体的许多表面测量值找到圆心。
我目前使用基于三个点的简化算法(用 C# 编写)来找到中心(取自如何在仅知道三个非共线点时确定圆的半径和中心?):
private Point CircleCenter(List<Point> points, double p1Skip, double p2Skip, double p3Skip)
{
var p1 = points.Skip((int)(points.Count * p1Skip)).First();
var p2 = points.Skip((int)(points.Count * p2Skip)).First();
var p3 = points.Skip((int)(points.Count * p3Skip)).First();
double mr = (p2.Y - p1.Y) / (p2.X - p1.X);
double mt = (p3.Y - p2.Y) / (p3.X - p2.X);
double centerX = (mr * mt * (p3.Y - p1.Y) + mr * (p2.X + p3.X) - mt * (p1.X + p2.X)) / (2 * …Run Code Online (Sandbox Code Playgroud) 我的问题是我有一组RadioButtons,我想根据选择的RadioButton禁用另一个控件.
重要的是,如果选择了几个 RadioButton中的一个,我可以禁用控制.
例如
[] Enabled one
[] Enabled two
[] Disabled one
[] Disabled two
Run Code Online (Sandbox Code Playgroud)
如果选择了最后两个按钮之一,则应禁用该控件.
注意
可能我会错过使用HashSet和HashCode的东西,但我不知道为什么这不能像我想的那样工作.我有一个覆盖HashCode的对象.我将对象添加到HashSet,然后我更改了一个属性(用于计算HashCode),然后我无法删除该对象.
public class Test
{
public string Code { get; set; }
public override int GetHashCode()
{
return (Code==null)?0: Code.GetHashCode();
}
}
public void TestFunction()
{
var test = new Test();
System.Collections.Generic.HashSet<Test> hashSet = new System.Collections.Generic.HashSet<Test>();
hashSet.Add(test);
test.Code = "Change";
hashSet.Remove(test); //this doesn´t remove from the hashset
}
Run Code Online (Sandbox Code Playgroud) 我正在研究MVC5.我刚刚在WebApiConfig中添加了API控制器和面临的错误.错误是模糊的参考系统web http routeparameter.我不明白Ambiguity在哪里创造.任何人都可以解释一下吗?
MyCode是:
using System.Web.Http;
namespace MyProject
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
Run Code Online (Sandbox Code Playgroud)