本文整理汇总了C#中Point3d.DistanceTo方法的典型用法代码示例。如果您正苦于以下问题:C# Point3d.DistanceTo方法的具体用法?C# Point3d.DistanceTo怎么用?C# Point3d.DistanceTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point3d
的用法示例。
在下文中一共展示了Point3d.DistanceTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: areaTri
public double areaTri(Point3d p1, Point3d p2, Point3d p3)
{
double a = p1.DistanceTo(p2);
double b = p1.DistanceTo(p3);
double c = p2.DistanceTo(p3);
double p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
示例2: ComputeWeight
public double[] ComputeWeight(Point3d p1, Point3d p2, Point3d p3, Vector3d v)
{
Vector3d N = new Plane(p1, p2, p3).Normal;
if (N.IsParallelTo(v) == -1)
{
double[] ds = new Double[3]; return ds;
}
Vector3d y2 = Vector3d.CrossProduct(v, N);
v = Vector3d.CrossProduct(y2, N);
double t = p1.DistanceTo(p2) + p2.DistanceTo(p3) + p3.DistanceTo(p1);
v.Unitize(); v *= t;
Point3d cen = (p1 + p2 + p3) / 3;
Line l1 = new Line(cen - v, cen + v);
Point3d P1 = l1.ClosestPoint(p1, true);
Point3d P2 = l1.ClosestPoint(p2, true);
Point3d P3 = l1.ClosestPoint(p3, true);
double t1 = (P1.DistanceTo(l1.From)) / l1.Length;
double t2 = (P2.DistanceTo(l1.From)) / l1.Length;
double t3 = (P3.DistanceTo(l1.From)) / l1.Length;
if ((t1 < t2) && (t2 < t3))
{
double[] ds = { 0, (t2 - t1) / (t3 - t1), 1 }; return ds;
}
else if (t1 < t3 && t3 < t2)
{
double[] ds = { 0, 1, (t3 - t1) / (t2 - t1) }; return ds;
}
////
else if (t2 < t1 && t1 < t3)
{
double[] ds = { (t1 - t2) / (t3 - t2), 0, 1 }; return ds;
}
else if (t2 < t3 && t3 < t1)
{
double[] ds = { 1, 0, (t3 - t2) / (t1 - t2) }; return ds;
}
////
else if (t3 < t1 && t1 < t2)
{
double[] ds = { (t1 - t3) / (t2 - t3), 1, 0 }; return ds;
}
else if (t3 < t2 && t2 < t1)
{
double[] ds = { 1, (t2 - t3) / (t1 - t3), 0 }; return ds;
}
else
{
double[] ds = new Double[3]; return ds;
}
}
示例3: WeightedCombo
public double WeightedCombo(Point3d Pos, List<Point3d> SizePoints, List<double> Sizes, int Falloff, double BVal, double BWeight)
{
double WeightedSize = 0, WeightSum = 0;
double[] Weighting = new double[SizePoints.Count];
for (int j = 0; j < SizePoints.Count; j++)
{
Weighting[j] = Math.Pow(Pos.DistanceTo(SizePoints[j]), -1.0 * Falloff);
WeightSum += Weighting[j];
}
WeightSum += BWeight;
WeightedSize += BWeight * (1.0 / WeightSum) * BVal;
for (int j = 0; j < SizePoints.Count; j++)
{
WeightedSize += Weighting[j] * (1.0 / WeightSum) * Sizes[j];
}
return WeightedSize;
}
示例4: DistanceTo
/// <summary>
/// Computes the distance of a point to a given geometry. (Brep, Mesh or closed Surface)
/// </summary>
public static double DistanceTo(GeometryBase geometry, Point3d testPoint, int spaceType)
{
double distanceTo = 0;
Point3d closestPoint;
switch (spaceType)
{
// Brep design space
case 1:
closestPoint = ((Brep)geometry).ClosestPoint(testPoint);
distanceTo = testPoint.DistanceTo(closestPoint);
break;
// Mesh design space
case 2:
closestPoint = ((Mesh)geometry).ClosestPoint(testPoint);
distanceTo = testPoint.DistanceTo(closestPoint);
break;
// Solid surface design space (must be converted to brep)
case 3:
closestPoint = ((Surface)geometry).ToBrep().ClosestPoint(testPoint);
distanceTo = testPoint.DistanceTo(closestPoint);
break;
}
return distanceTo;
}
示例5: shoot
public override bool shoot(Point3d Start, Vector3d Dir, int Random, out double u, out double v, out int Srf_ID, out List<Point3d> X_PT, out List<double> t, out List<int> Code)
{
S_Origin = new Point3d(Start);
Srf_ID = 0;
while (true)
{
Point3d[] P = Rhino.Geometry.Intersect.Intersection.RayShoot(new Ray3d(S_Origin, Dir), BrepList, 1);
if (P == null) { X_PT = new List<Point3d> { default(Point3d) }; u = 0; v = 0; t = new List<double> { 0 }; Code = new List<int> { 0 }; return false; }
Voxels.PointIsInVoxel(P[0], ref XVoxel, ref YVoxel, ref ZVoxel);
try
{
SurfaceIndex = Voxels.VoxelList(XVoxel, YVoxel, ZVoxel);
}
catch (Exception)
{
//Rare floating point error on some computers... abandon the ray and start the next...
//Explanation: This would never happen on my IBM T43P laptop, but happened
//consistently millions of function calls into the calculation on my
//ASUS K8N-DL based desktop computer. I believe it has something to do with some quirk of that system.
//This try...catch statement is here in case this ever manifests on any user's computer.
//It is rare enough that this should not affect the accuracy of the calculation.
t = new List<double> { 0.0f };
X_PT = new List<Point3d> { default(Point3d) };
u = 0;
v = 0;
Code = new List<int> { 0 };
return false;
}
Point3d CP;
Vector3d N;
ComponentIndex CI;
double MD = 0.0001;
foreach (int index in SurfaceIndex)
{
if (BrepList[index].ClosestPoint(P[0], out CP, out CI, out u, out v, MD, out N) && (CI.ComponentIndexType == ComponentIndexType.BrepFace))
{
if ((Math.Abs(P[0].X - CP.X) < 0.0001) && (Math.Abs(P[0].Y - CP.Y) < 0.0001) && (Math.Abs(P[0].Z - CP.Z) < 0.0001))
{
Srf_ID = index;
X_PT = new List<Point3d> {P[0]};
t = new List<double> {(double)(S_Origin.DistanceTo(X_PT[0]))};
Code = new List<int>() { 0 };
return true;
}
}
}
S_Origin = new Point3d(P[0]);
}
}
示例6: AddTrimmedStrut
/// <summary>
/// Trims strut with known intersection point, returning the trimmed LineCurve which is inside the space.
/// </summary>
public LineCurve AddTrimmedStrut(LatticeNode node1, LatticeNode node2, Point3d intersectionPt, double minLength, double maxLength)
{
LineCurve testStrut = new LineCurve(new Line(node1.Point3d, node2.Point3d), 0, 1); // set line, with curve parameter domain [0,1]
if (node1.IsInside)
{
double trimmedLength = intersectionPt.DistanceTo(node1.Point3d);
if (trimmedLength > minLength && trimmedLength < maxLength)
{
Nodes.Add(new LatticeNode(intersectionPt, LatticeNodeState.Boundary));
return new LineCurve(node1.Point3d, intersectionPt);
}
else
{
node1.State = LatticeNodeState.Boundary;
}
}
if (node2.IsInside)
{
double trimmedLength = intersectionPt.DistanceTo(node2.Point3d);
if (trimmedLength > minLength && trimmedLength < maxLength)
{
Nodes.Add(new LatticeNode(intersectionPt, LatticeNodeState.Boundary));
return new LineCurve(node2.Point3d, intersectionPt);
}
else
{
node2.State = LatticeNodeState.Boundary;
}
}
return null;
}
示例7: checkIfOnLine
private bool checkIfOnLine(Point3d pt1, Point3d pt2, Point3d pttested)
{
double num = pttested.DistanceTo(pt1);
double num2 = pttested.DistanceTo(pt2);
double num3 = pt1.DistanceTo(pt2);
return ((num + num2) > num3);
}
示例8: Ellipse
/// <summary>
/// Initializes a new ellipse from a center point and the two semiaxes intersections.
/// </summary>
/// <param name="center">A center for the ellipse. The avarage of the foci.</param>
/// <param name="second">The intersection of the ellipse X axis with the ellipse itself.</param>
/// <param name="third">A point that determines the radius along the Y semiaxis.
/// <para>If the point is at right angle with the (center - second point) vector,
/// it will be the intersection of the ellipse Y axis with the ellipse itself.</para>
/// </param>
public Ellipse(Point3d center, Point3d second, Point3d third)
{
m_plane = new Plane(center, second, third);
m_radius1 = center.DistanceTo(second);
m_radius2 = center.DistanceTo(third);
}
示例9: Contains
public override bool Contains(Point3d pt)
{
foreach (Brep[] borderWalls in borderWallsArray)
{
foreach (Brep brep in borderWalls)
{
if (pt.DistanceTo(brep.ClosestPoint(pt)) < Constants.AbsoluteTolerance)
{
return false;
}
}
}
return true;
}
示例10: OnSkeletonFrameReady
public override void OnSkeletonFrameReady(
object sender, SkeletonFrameReadyEventArgs e
)
{
Point3d pt = new Point3d();
if (!Finished)
{
using (SkeletonFrame s = e.OpenSkeletonFrame())
{
if (s != null)
{
Skeleton[] skels = new Skeleton[s.SkeletonArrayLength];
s.CopySkeletonDataTo(skels);
foreach (Skeleton data in skels)
{
if (
data.TrackingState == SkeletonTrackingState.Tracked
)
{
leftHip =
PointFromVector(
data.Joints[JointType.HipLeft].Position, false
);
leftHand =
PointFromVector(
data.Joints[JointType.HandLeft].Position, false
);
Point3d rightHand =
PointFromVector(
data.Joints[JointType.HandRight].Position, false
);
if (
leftHand.DistanceTo(Point3d.Origin) > 0 &&
rightHand.DistanceTo(Point3d.Origin) > 0 &&
leftHand.DistanceTo(rightHand) < 0.03)
{
// Hands are less than 3cm from each other
_drawing = false;
_resizing = false;
_isRotate = false;
_changeaxis = false;
_resizebool = 0;
Finished = true;
}
else
{
// Hands are within 10cm of each other vertically
// and both hands are above the waist, so we resize
// the profile radius
_resizing = (leftHand.Z > leftHip.Z &&
rightHand.Z > leftHip.Z &&
Math.Abs(leftHand.Z - rightHand.Z) < 0.5);
_changeaxis = (leftHand.Z > leftHip.Z &&
rightHand.Z > leftHip.Z &&
Math.Abs(leftHand.Z - rightHand.Z) < 0.5);
// If the left hand is below the waist, we draw
_isRotate = (leftHand.Z < leftHip.Z);
_drawing = false;
}
//_resizing = true;
if (ct == 0)
{
pt = rightHand;
ct = 1;
}
if (_resizing)
{
// If resizing, set some data to help draw
// a sphere where we're resizing
Vector3d vec = (leftHand - rightHand) / 2;
_resizeLocation = pt + vec;
_profSide = vec.Length / (Math.Sqrt(3));
vRot = rightHand.GetVectorTo(leftHand); //new Point3d(-3, 4, 0).GetVectorTo(new Point3d(-3, -4, 0)); //rightHand.GetVectorTo(leftHand);
}
// if (_changeaxis)
// {
// vRot = rightHand.GetVectorTo(leftHand);
// }
//if (_isRotate)
// {
// cube.WorldDraw(draw);
// }
if (_drawing)
{
// If we have at least one prior vertex...
//.........这里部分代码省略.........
示例11: WrapPoint
public override Point3d WrapPoint(Point3d relativePoint, Point3d point)
{
Point3d wrappedPoint = point;
bool wrapped;
wrappedPoint = WrapPoint(point, out wrapped);
if (wrapped)
{
if (relativePoint.DistanceTo(wrappedPoint) < relativePoint.DistanceTo(point))
{
return wrappedPoint;
}
else
{
return point;
}
}
double minDistance = Double.MaxValue;
for (double x = -Width; x <= Width; x += Width)
{
for (double y = -Height; y <= Height; y += Height)
{
for (double z = -Depth; z <= Depth; z += Depth)
{
Point3d potentialPoint = new Point3d(point.X + x, point.Y + y, point.Z + z);
double distance = relativePoint.DistanceTo(potentialPoint);
if (distance < minDistance)
{
minDistance = distance;
wrappedPoint = potentialPoint;
}
}
}
}
return wrappedPoint;
}
示例12: CloseTo
// Are two points within a certain distance?
private static bool CloseTo(
Point3d first, Point3d second, double dist = 0.1
)
{
return first.DistanceTo(second) < dist;
}
示例13: AdjustSjfW
/// <summary>
/// 微调湿接缝宽度--初次布板湿接缝递增或递减,现将其调匀
/// </summary>
private List<Point3d> AdjustSjfW(Point3d start, Point3d end, int segCount, List<double> adjustSjfW)
{
double seglength = start.DistanceTo(end) / segCount;
Vector3d vect = start.GetVectorTo(end).GetNormal();
List<Point3d> res = new List<Point3d>();
double dist = 0;
for (int i = 1; i < segCount; i++)
{
dist += (seglength + adjustSjfW[i - 1]);
res.Add(start + vect.MultiplyBy(dist));
}
return res;
}
示例14: Spherical_Receiver
/// <summary>
/// Constructor which takes Rhino point input.
/// </summary>
/// <param name="Center"></param>
/// <param name="SrcCenter"></param>
/// <param name="room"></param>
/// <param name="RCT"></param>
/// <param name="C_Sound_in"></param>
/// <param name="SampleRate_in"></param>
/// <param name="COTime_in"></param>
public Spherical_Receiver(Point3d Center, Point3d SrcCenter, double[] Attenuation, double C_Sound_in, double rho, int SampleRate_in, double COTime_in)
{
D_Length = Center.DistanceTo(SrcCenter);
Radius = 1;
Radius2 = Radius * Radius;
SampleRate = SampleRate_in;
CO_Time = COTime_in;
H_Origin = new Hare.Geometry.Point(Center.X, Center.Y, Center.Z);
Sound_Speed = C_Sound_in;
Rho_C = C_Sound_in * rho;
Atten = new double[8];
for (int o = 0; o < 8; o++) Atten[o] = Attenuation[o] * 2;
SizeMod = 1 / Math.PI;
Recs = new Directional_Histogram(SampleRate, CO_Time);
}
示例15: IsEatable
public static bool IsEatable(Point3d food)
{
//find closest particle to food
double closest_distance = double.MaxValue;
Particle p_closest = null;
/// GET KEY-ZONES FOR FOOD (0/+/- X,Y,Z)
/// FOR EACH ZONES - IF EXISTS, FIND CLOSEST PARTICLE
List<string> zones = GetZones(food);
foreach (string zone_id in zones)
{
List<Particle> zone;
if (Zones.TryGetValue(zone_id, out zone))
{
for (int i = 0; i < zone.Count(); i++)
{
double actual_distance = food.DistanceTo(zone[i].Position);
if (actual_distance < closest_distance)
{
p_closest = zone[i];
closest_distance = actual_distance;
//if (closest_distance < infuence_distance * 0.2)
//continue;
}
}
}
}
//===: closest particle is particle with index x in the field
/// STORE AS A LINK TO THE PARTICLE - THEN TARGET FOOD
//if food is too close - eat it, otherwise target it
if (closest_distance <= eatable_distance)
return true;
else
{
if (closest_distance <= infuence_distance)
{
p_closest.TargetFood(food, infuence_distance - closest_distance); //(infuence_distance - closest_distance) as factor
Temp.Add(p_closest);
}
//prepare to move
return false;
}
}