本文整理汇总了C#中Plane.ClosestPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Plane.ClosestPoint方法的具体用法?C# Plane.ClosestPoint怎么用?C# Plane.ClosestPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plane
的用法示例。
在下文中一共展示了Plane.ClosestPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClosestPointOnPlane
public void ClosestPointOnPlane()
{
Plane p = new Plane(new Vector3(0, 0.5f, 0.8660254f), new Vector3(0.75f, 0.5f, -0.4330128f), new Vector3(-0.75f, 0.5f, -0.4330126f));
//Point below plane
AssertT.AreEqual(new Vector3(0, 0.5f, 0), p.ClosestPoint(new Vector3(0, 0, 0)));
//Point above plane
AssertT.AreEqual(new Vector3(0, 0.5f, 0), p.ClosestPoint(new Vector3(0, 1, 0)));
}
示例2: SolveInstance
protected override void SolveInstance(IGH_DataAccess DA)
{
// --- Input
var mesh = default(Mesh);
var planes = new List<Plane>();
var thickness = default(double);
var deeper = default(double);
DA.GetData(0, ref mesh);
DA.GetDataList(1, planes);
DA.GetData(2, ref thickness);
DA.GetData(3, ref deeper);
// --- Execute
var tolerance = DocumentTolerance();
var slitPlanes = new SlitPlane[planes.Count];
for (int i = 0; i < planes.Count; i++)
slitPlanes[i] = new SlitPlane(mesh, planes[i], tolerance);
var bbox = mesh.GetBoundingBox(false);
var dmax = bbox.Diagonal.Length;
for (int i = 0; i < planes.Count; i++)
{
for (int j = i + 1; j < planes.Count; j++)
{
var a = planes[i];
var b = planes[j];
var origin = default(Vector3d);
var direction = default(Vector3d);
if (a.Normal.IsParallelTo(b.Normal) != 0)
continue;
IntersectPlanes(a, b, out origin, out direction);
var cPlane = new Plane(bbox.Center, direction);
origin = (Vector3d)cPlane.ClosestPoint((Point3d)origin);
var originA = origin.Map2D(a);
var directionA = direction.Map2D(a);
var originB = origin.Map2D(b);
var directionB = direction.Map2D(b);
var line = new LineCurve((Point3d)(origin - dmax * direction), ((Point3d)origin + dmax * direction));
var alpha = Vector3d.VectorAngle(a.Normal, b.Normal);
var t = thickness * Math.Tan(alpha / 2);
slitPlanes[i].AddSlit(line.PointAtStart, line.PointAtEnd, t, deeper);
slitPlanes[j].AddSlit(line.PointAtEnd, line.PointAtStart, t, deeper);
}
}
// --- Output
DA.SetEnum2D(0, slitPlanes.Select(o => o.GetResult()));
}
示例3: Offset3D
public List<Line> Offset3D(List<Polyline> x, double y)
{
List<Line> output = new List<Line>();
if (x.Count < 4) return output;
List<Line> lines = breakPoly(x[0]);
for (int i = 1; i < x.Count; i++)
{
List<Line> ls = breakPoly(x[i]);
//Print(ls.Count.ToString());
for (int ii = 0; ii < ls.Count; ii++)
{
bool sign = true;
for (int j = 0; j < lines.Count; j++)
{
if (isDumpLines(lines[j], ls[ii])) { sign = false; break; }
}
//Print(sign.ToString());
if (sign) lines.Add(ls[ii]);
}
}
Point3d cen = new Point3d();
for (int i = 0; i < lines.Count; i++)
{
cen += lines[i].From; cen += lines[i].To;
}
// B = lines;
cen /= 2 * lines.Count;
HullFrame.box box = new HullFrame.box(lines);
HullFrame.hull hull = new HullFrame.hull(box, cen);
for (int i = 0; i < x.Count; i++)
{
if (x[i].Count < 3)
{//Print("00001");
return output;
}
Plane p = new Plane(x[i][0], x[i][1], x[i][2]);
Vector3d v = cen - p.ClosestPoint(cen);
v.Unitize(); p = new Plane(x[i][0], v);
p.Transform(Transform.Translation(v * y));
hull.intersect(p);
hull.clearnull();
}
for (int i = 0; i < hull.edges.Count; i++)
{
output.Add(new Line(hull.edges[i].p1.pos, hull.edges[i].p2.pos));
}
List<Point3d> pt = new List<Point3d>();
for (int i = 0; i < hull.pts.Count; i++)
{
pt.Add(hull.pts[i].pos);
}
return output;
}