public BoundingBox2d GetEnvelope(double d, double estacion1, double estacion2) { double t0 = this.t0; double t1 = this.t1; Vector2d v = this.dirN.PerpRight.Mul(d); if (estacion1.EpsilonEquals(this.t0) && estacion2.EpsilonEquals(this.t1)) { return(BoundingBox2d.Union(this.p0.Add(v), this.p1.Add(v))); } if (this.t0.EpsilonEquals(this.t1)) { return(BoundingBox2d.Union(this.p0.Add(v), this.p0.Add(v))); } // Se normaliza la estacion. double t01_0 = (estacion1 - this.t0) / (this.t1 - this.t0); double t01_1 = (estacion2 - this.t0) / (this.t1 - this.t0); return(BoundingBox2d.Union( this.Evaluate01(t01_0).Add(v), this.Evaluate01(t01_1).Add(v))); }
public BoundingBox2d GetEnvelope(double t0, double t1) { if (t0.EpsilonEquals(this.t0) && t1.EpsilonEquals(this.t1)) { return(BoundingBox2d.Union(this.p0, this.p1)); } if (this.t0.EpsilonEquals(this.t1)) { return(BoundingBox2d.Union(this.p0, this.p0)); } // Se normaliza la estacion. double t01_0 = (t0 - this.t0) / (this.t1 - this.t0); double t01_1 = (t1 - this.t0) / (this.t1 - this.t0); return(BoundingBox2d.Union( this.Evaluate01(t01_0), this.Evaluate01(t01_1))); }
public void TestUnion() { { BoundingBox2d bbox1 = new BoundingBox2d(0, 10, 0, 10); BoundingBox2d bbox2 = new BoundingBox2d(5, 15, 5, 15); Assert.IsTrue(bbox1.Union(bbox2).EpsilonEquals(new BoundingBox2d(0, 15, 0, 15))); } { BoundingBox2d bbox1 = new BoundingBox2d(0, 10, 0, 10); BoundingBox2d bbox2 = new BoundingBox2d(5, 7, 5, 7); Assert.IsTrue(bbox1.Union(bbox2).EpsilonEquals(new BoundingBox2d(0, 10, 0, 10))); } { BoundingBox2d bbox1 = new BoundingBox2d(0, 10, 0, 10); BoundingBox2d bbox2 = new BoundingBox2d(0, 10, 0, 10); Assert.IsTrue(bbox1.Union(bbox2).EpsilonEquals(new BoundingBox2d(0, 10, 0, 10))); } { BoundingBox2d bbox1 = new BoundingBox2d(0, 10, 0, 10); BoundingBox2d bbox2 = new BoundingBox2d(10, 20, 10, 20); Assert.IsTrue(bbox1.Union(bbox2).EpsilonEquals(new BoundingBox2d(0, 20, 0, 20))); } { BoundingBox2d bbox1 = new BoundingBox2d(0, 10, 0, 10); BoundingBox2d bbox2 = BoundingBox2d.Empty; Assert.IsTrue(bbox1.Union(bbox2).EpsilonEquals(new BoundingBox2d(0, 10, 0, 10))); } { BoundingBox2d bbox1 = BoundingBox2d.Empty; BoundingBox2d bbox2 = BoundingBox2d.Empty; Assert.IsTrue(bbox1.Union(bbox2).IsEmpty); } { BoundingBox2d bbox1 = new BoundingBox2d(0, double.MaxValue, 0, double.MaxValue); BoundingBox2d bbox2 = new BoundingBox2d(-double.MaxValue, 10, -double.MaxValue, 10); Assert.IsTrue(bbox1.Union(bbox2).EpsilonEquals(new BoundingBox2d(-double.MaxValue, double.MaxValue, -double.MaxValue, double.MaxValue))); } }