本文整理汇总了C#中Point3D.DistanceTo方法的典型用法代码示例。如果您正苦于以下问题:C# Point3D.DistanceTo方法的具体用法?C# Point3D.DistanceTo怎么用?C# Point3D.DistanceTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point3D
的用法示例。
在下文中一共展示了Point3D.DistanceTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTrackerDown
void OnTrackerDown(object sender, NodeTrackerEventArgs e)
{
Point3D pnt = new Point3D(e.DeltaX, e.DeltaY, e.DeltaZ);
for (iHit = 0; iHit < Line.Count; ++iHit)
{
if (pnt.DistanceTo(Line[iHit]) < radius)
{
break;
}
}
if( Line.Count == 0 || iHit == Line.Count)
{
Line.Add(new Point3D(e.DeltaX, e.DeltaY, e.DeltaZ));
}
Update();
}
示例2: ComputeFixedPoints
internal void ComputeFixedPoints()
{
double min = 10000000;
double cur = -10000000;
int iMin = -1;
foreach (double[] FixPoint in FixedPoints) {
min = 10000000;
cur = -10000000;
Point3D RefPt = new Point3D(FixPoint);
for (int i = 0; i < Vertices.Count; i++) {
Point3D CurPt = new Point3D(Vertices[i]);
cur = RefPt.DistanceTo(CurPt);
if (cur < min) {
min = cur;
iMin = i;
}
}
IndiceOfFixedPoints.Add(iMin);
}
IndiceOfFixedPoints = IndiceOfFixedPoints.Distinct().ToList();
OneIndFix = IndiceOfFixedPoints[0];
OnePointFix = new Point3D(new double[] { Vertices[OneIndFix][0], Vertices[OneIndFix][1], Vertices[OneIndFix][2] });
}
示例3: Circle3D
public Circle3D(Point3D p1, Point3D p2, UnitVector3D axis)
{
this.CenterPoint = Point3D.MidPoint(p1, p2);
this.Axis = axis;
this.Radius = p1.DistanceTo(CenterPoint);
}
示例4: solve
public static Vector<double> solve(
List<double[]> Vertices,
List<int[]> TrianglesVertices,
List<double[]> FacetNormals,
Vector<double> X, Point3D oRoot,
UnitVector3D vDir1,
UnitVector3D vDir2, Mesh M)
{
//Method from article -Wang,Smith. Surface flattening based on energy model. Computer-Aided Design (2002) 823-833
//PseudoCode
//Input: P - Set of nodes, in the initial position and N is the number of nodes
//Output: the final positions of P with E(o) minimized
// FOR i = 1 TO n
// mi = p / 3 Sum(Ak), where Ak is the area
// WHILE (Relative Area difference Es > Permissible accuracy or Relative edge length difference Ec > Permissible accuracy)
// AND Variation of E(o) > Permissible percentage €
// AND the number of iterations < Permissible number N
// FOR i = 1 TO n
// Compute Tensile force of Node Pi: Fi = Sum(C * (Dist(PiPj) - Dist(QiQj)))nij where(P - 2D - Q - 3D nij - Vector Pi to Pj)
// Compute new position of Pi qi = qi + dtqi. + dt ^ 2 / 2 qi..where qi.= qi.+ dtqi..and qi..= Fi / mi
// Compute Penalty force and aplly to Fpi
// Compute new position of Pi qi = qi + dtqi. + dt ^ 2 / 2 qi..where qi.= qi.+ dtqi..and qi..= Fpi / mi
// Compute new Es= Sum(TotalAreaNow - TotalAreaBefore) / TotalAreaNow
// Compute new Ec= Sum(TotalLenghtNow - TotalLenghtBefore) / TotalLenghtNow
// Compute new E(o)Sum(E(pi)) where E(pi) = 0.5 * Sum(C * (Dist(PiPj) - Dist(QiQj))) ^ 2
double[] Mass = new double [Vertices.Count];
int[] MassCounter = new int[Vertices.Count];
double Permissible = 0.00000001;
Vector<double> Fi = Vector<double>.Build.Dense(2);
List<Vector<double>> dqi = new List<Vector<double>>();
List<Vector<double>> qi = new List<Vector<double>>();
double LastEc = 0, Ec = 0;
double LastEs = 0, Es = 0;
double LastEo = 0, Eo = 0;
double C = 0.5;
double ro = 1;
double t = 0.01;
int N = 100;
int Iteration = 0;
double Total = 0;
double LastTotal = 0;
foreach (int[] tri in TrianglesVertices) {
double A = getArea(Vertices[tri[0]], Vertices[tri[1]], Vertices[tri[2]]);
double P = getPerimeter(Vertices[tri[0]], Vertices[tri[1]], Vertices[tri[2]]);
Mass[tri[0]] += ((double)1 / (double)3) * A * ro;
Mass[tri[1]] += ((double)1 / (double)3) * A * ro;
Mass[tri[2]] += ((double)1 / (double)3) * A * ro;
MassCounter[tri[0]] += 1;
MassCounter[tri[1]] += 1;
MassCounter[tri[2]] += 1;
LastEc += A;
LastEs += P;
}
for (int i = 0; i < Vertices.Count; i++) {
Mass[i] = Mass[i] / MassCounter[i];
qi.Add(Vector<double>.Build.DenseOfArray(new double[] { X[i * 2], X[i * 2 + 1], 0 }));
dqi.Add(Vector<double>.Build.DenseOfArray(new double[] { 0, 0, 0 }));
}
do {
Iteration += 1;
LastEo = Eo;
Eo = 0;
Total = 0;
for (int i = 0; i < Vertices.Count; i++) {
Point3D Pi = new Point3D(qi[i][0], qi[i][1], qi[i][2]);
Point3D Qi = new Point3D(Vertices[i][0], Vertices[i][1], Vertices[i][2]);
Fi = Vector<double>.Build.Dense(3);
for (int j = i+1; j < Vertices.Count; j++) {
if (i == j) continue;
Point3D Pj = new Point3D(qi[j][0], qi[j][1], qi[j][2]);
Point3D Qj = new Point3D(Vertices[j][0], Vertices[j][1], Vertices[j][2]);
UnitVector3D nij = new UnitVector3D((Pi.ToVector()- Pj.ToVector()).ToArray());
Fi += C * ((Pi.DistanceTo(Pj) - Qi.DistanceTo(Qj)) * nij).ToVector();
Eo += Math.Pow(C * ((Pi.DistanceTo(Pj) - Qi.DistanceTo(Qj))), 2);
}
Vector<double> ddqi = Fi / Mass[i];
Console.WriteLine(Fi);
dqi[i] += t * ddqi;
qi[i] += dqi[i] * t + 0.5 * Math.Pow(t, 2) * ddqi;
Total += Math.Abs(qi[i][0] - X[i * 2]);
Total += Math.Abs(qi[i][1] - X[i * 2] + 1);
}
Console.WriteLine(Total- LastTotal);
LastTotal = Total;
LastEc = Ec;
Ec = 0;
LastEs = Es;
Es = 0;
foreach (int[] tri in TrianglesVertices) {
double A = getArea(Vertices[tri[0]], Vertices[tri[1]], Vertices[tri[2]]);
double P = getPerimeter(Vertices[tri[0]], Vertices[tri[1]], Vertices[tri[2]]);
Ec += A;
Es += P;
}
if (((Ec - LastEc) / Ec < Permissible || (Es - LastEs) / Es < Permissible)
//.........这里部分代码省略.........