public static Plane3D?GetPlane(IList <Point3D> polygon) { int count = polygon.Count; if (count < 3) { return(new Plane3D?()); } Point3D point = polygon[0]; Vector3D u = polygon[1] - point; for (int index = 2; index < count; ++index) { Vector3D v = polygon[index] - point; Vector3D vector3D = Vector3D.CrossProduct(u, v); if (!Vector3D.AreApproxEqual(vector3D, Vector3D.Zero)) { vector3D.Normalize(); return(new Plane3D?(new Plane3D(vector3D, point))); } } return(new Plane3D?()); }
protected override WW.Math.Point3D ProcessWcsPosition( InteractionContext context, WW.Math.Point3D p) { p = base.ProcessWcsPosition(context, p); p = DxfLine.CreateInteractor.SnapHorizontalOrVertical((DxfEntity.Interactor) this, p, context, this.ControlPointIndexAtFirstMouseDown); if (this.ClickCount > 0 && this.nullable_1.HasValue) { DxfLine entity = (DxfLine)this.Entity; if (this.ControlPointIndexAtFirstMouseDown == 0) { Vector3D u = entity.point3D_1 - p; if (Vector3D.AreApproxEqual(u, Vector3D.Zero)) { u = entity.point3D_1 - entity.point3D_0; } if (!Vector3D.AreApproxEqual(u, Vector3D.Zero)) { p = entity.point3D_1 - this.nullable_1.Value * u.GetUnit(); } } else { Vector3D u = p - entity.point3D_0; if (Vector3D.AreApproxEqual(u, Vector3D.Zero)) { u = entity.point3D_1 - entity.point3D_0; } if (!Vector3D.AreApproxEqual(u, Vector3D.Zero)) { p = entity.point3D_0 + this.nullable_1.Value * u.GetUnit(); } } } return(p); }