/// <summary> /// Overrides <see cref="CADability.GeoObject.ISurfaceImpl.SameGeometry (BoundingRect, ISurface, BoundingRect, double, out ModOp2D)"/> /// </summary> /// <param name="thisBounds"></param> /// <param name="other"></param> /// <param name="otherBounds"></param> /// <param name="precision"></param> /// <param name="firstToSecond"></param> /// <returns></returns> public override bool SameGeometry(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, double precision, out ModOp2D firstToSecond) { firstToSecond = ModOp2D.Null; if (other is PlaneSurface) { PlaneSurface second = other as PlaneSurface; GeoPoint p = PointAt(thisBounds.GetCenter()); if (Math.Abs(second.Plane.Distance(p)) > precision) { return(false); } p = second.PointAt(otherBounds.GetCenter()); if (Math.Abs(Plane.Distance(p)) > precision) { return(false); } if (Precision.SameDirection(Normal, second.Normal, false)) { GeoPoint2D[] src = new GeoPoint2D[] { GeoPoint2D.Origin, new GeoPoint2D(1, 0), new GeoPoint2D(0, 1) }; GeoPoint2D[] dst = new GeoPoint2D[3]; for (int i = 0; i < 3; ++i) { dst[i] = second.PositionOf(PointAt(src[i])); } firstToSecond = ModOp2D.Fit(src, dst, true); return(true); } else { return(false); } } return(base.SameGeometry(thisBounds, other, otherBounds, precision, out firstToSecond)); }
public static EllipseArc2D Create(GeoPoint2D center, GeoVector2D majorAxis, GeoVector2D minorAxis, GeoPoint2D startPoint, GeoPoint2D endPoint, bool counterClock) { // bestimme die beiden Winkel GeoVector2D majAx; GeoVector2D minAx; GeoPoint2D left, right, bottom, top; Geometry.PrincipalAxis(center, majorAxis, minorAxis, out majAx, out minAx, out left, out right, out bottom, out top, false); ModOp2D toUnit = ModOp2D.Fit(new GeoPoint2D[] { center, center + majAx, center + minAx }, new GeoPoint2D[] { GeoPoint2D.Origin, GeoPoint2D.Origin + GeoVector2D.XAxis, GeoPoint2D.Origin + GeoVector2D.YAxis }, true); GeoPoint2D p = toUnit * startPoint; double sa = p.ToVector().Angle.Radian; p = toUnit * endPoint; double ea = p.ToVector().Angle.Radian; double sw; if (counterClock) { sw = ea - sa; if (sw <= 0.0) { sw += Math.PI * 2.0; // geändert auf <= bzw. >=, da sonst aus Vollkreisen Leerkreise werden } } else { sw = ea - sa; if (sw >= 0.0) { sw -= Math.PI * 2.0; } } return(new EllipseArc2D(center, majAx, minAx, sa, sw, left, right, bottom, top)); }
public PlanePolygon(GeoPoint2D uv, GeoPoint loc, GeoVector diru, GeoVector dirv, GeoPoint edgeStart, GeoPoint edgeEnd, Tangulation tangulation) { // TODO: Complete member initialization plane = new Plane(loc, diru, dirv); toUV = ModOp2D.Translate(uv.x, uv.y) * ModOp2D.Fit(new GeoVector2D[] { GeoVector2D.XAxis, GeoVector2D.YAxis }, new GeoVector2D[] { plane.Project(diru), plane.Project(dirv) }); polygon = new List <GeoPoint2D>(); polygon.Add(plane.Project(edgeStart)); // die beiden Punkte geben die Linie an, die die Ebene begrenzt polygon.Add(plane.Project(edgeEnd)); isOpen = true; // die Linie "halbiert" die Ebene, links davon ist innerhalb extend = BoundingCube.EmptyBoundingCube; }
public override ModOp2D ReverseOrientation() { GeoPoint2D[] from = new GeoPoint2D[3]; from[0] = new GeoPoint2D(0.5, 0.5); from[1] = new GeoPoint2D(0.5, 0.7); from[2] = new GeoPoint2D(0.7, 0.5); GeoPoint[] from3d = new GeoPoint[3]; for (int i = 0; i < 3; i++) { from3d[i] = PointAt(from[i]); } periodicSurface.ReverseOrientation(); Init(periodicSurface.IsUPeriodic); //toNonPeriodicBounds = toNonPeriodicBounds * ModOp2D.Scale(-1, 1); //toPeriodicBounds = toNonPeriodicBounds.GetInverse(); GeoPoint2D[] to = new GeoPoint2D[3]; for (int i = 0; i < 3; i++) { to[i] = PositionOf(from3d[i]); } return(ModOp2D.Fit(from, to, true)); }
public override bool SameGeometry(BoundingRect thisBounds, ISurface other, BoundingRect otherBounds, double precision, out ModOp2D firstToSecond) { if (other is RuledSurface) { RuledSurface rsother = other as RuledSurface; if ((firstCurve.SameGeometry(rsother.firstCurve, precision) && secondCurve.SameGeometry(rsother.secondCurve, precision)) || (firstCurve.SameGeometry(rsother.secondCurve, precision) && secondCurve.SameGeometry(rsother.firstCurve, precision))) { GeoPoint2D[] srcPoints = new GeoPoint2D[] { GeoPoint2D.Origin, new GeoPoint2D(1, 0), new GeoPoint2D(0, 1) }; GeoPoint2D[] dstPoints = new GeoPoint2D[3]; for (int i = 0; i < dstPoints.Length; i++) { dstPoints[i] = rsother.PositionOf(this.PointAt(srcPoints[i])); } firstToSecond = ModOp2D.Fit(srcPoints, dstPoints, true); return(true); } firstToSecond = ModOp2D.Null; return(false); } return(base.SameGeometry(thisBounds, other, otherBounds, precision, out firstToSecond)); }
/// <summary> /// Overrides IGeoObjectImpl.<see cref="IGeoObjectImpl.Modify"/> and implements IGeoObject.<see cref="IGeoObject.Modify"/>. /// </summary> /// <param name="m">see <see cref="IGeoObject.Modify"/></param> public override void Modify(ModOp m) { using (new Changing(this, "ModifyInverse", m)) { // die ModOp wird in zwei Komponente aufgeteilt: // eine Skalierungsfreie, die auf die Ebene angewendet wird // und eine Skalierung, die nochmal auf die compoundShape wirkt try { Plane newPlane = new Plane(m * plane.Location, m * plane.DirectionX, m * plane.DirectionY); // die Ebene verändert sich gemäß der Matrix m, wie verändert sich die Umrandung im 2D? // Die brutale Methode: aus den bekannten Veränderungen von 3 Punkten die Matrix bestimmen // das funktioniert, alles andere hat bislang nicht geklappt GeoPoint2D[] src = new GeoPoint2D[3]; GeoPoint2D[] dst = new GeoPoint2D[3]; src[0] = GeoPoint2D.Origin; src[1] = GeoPoint2D.Origin + GeoVector2D.XAxis; src[2] = GeoPoint2D.Origin + GeoVector2D.YAxis; dst[0] = newPlane.Project(m * plane.ToGlobal(src[0])); dst[1] = newPlane.Project(m * plane.ToGlobal(src[1])); dst[2] = newPlane.Project(m * plane.ToGlobal(src[2])); ModOp2D m2d = ModOp2D.Fit(src, dst, true); compoundShape = compoundShape.GetModified(m2d); plane = newPlane; if (m.Mode == ModOp.ModificationMode.Translation && base.Count > 0) { containedObjects.Modify(m); } else { needsRecalc = true; } } catch (PlaneException) { } // neue Ebene enthält Nullvector } }