LengthSegment implements Segment<T> { @Override public Vect<T> start() { return this.seg.start(); } LengthSegment(final Segment<T> seg);  LengthSegment(final Vect<T> start, final Segment<T> seg);  LengthSegment(final Scalar<T> length);  LengthSegment(final Vect<T> start, final Scalar<T> length);  LengthSegment(final Vect<T> strt, final Vect<T> dir, final Scalar<T> length); @Override Vect<T> start(); @Override Vect<T> end();  }
@Test public void createsCongruentSegmentWithStartPoint() { final Segment<Double> ref = new PtVectSegment<>( new RandomPoint<>(), new RandomPoint<>() ); final Vect<Double> start = new RandomPoint<>(); final Segment<Double> seg = new LengthSegment<>(start, ref); final Field<Double> dec = new Decimal(); final double error = 1.e-6; MatcherAssert.assertThat( new SegmentLength<Double>(ref).value(dec), Matchers.closeTo(new SegmentLength<Double>(seg).value(dec), error) ); MatcherAssert.assertThat(seg.start(), Matchers.equalTo(start)); }
@Test public void createsLengthSegmentWithStartPoint() { final Scalar<Double> length = new Random<>(); final Vect<Double> start = new RandomPoint<>(); final Segment<Double> seg = new LengthSegment<>(start, length); final Field<Double> dec = new Decimal(); final double error = 1.e-6; MatcherAssert.assertThat( Math.abs(length.value(dec)), Matchers.closeTo(new SegmentLength<Double>(seg).value(dec), error) ); MatcherAssert.assertThat(seg.start(), Matchers.equalTo(start)); }
@Test public void createsLengthSegmentWithStartPointAndDirection() { final Scalar<Double> length = new Random<>(); final Vect<Double> start = new RandomPoint<>(); final Vect<Double> dir = new RandomPoint<>(); final Segment<Double> seg = new LengthSegment<>(start, dir, length); final Field<Double> dec = new Decimal(); final double error = 1.e-6; MatcherAssert.assertThat( Math.abs(length.value(dec)), Matchers.closeTo(new SegmentLength<Double>(seg).value(dec), error) ); MatcherAssert.assertThat(seg.start(), Matchers.equalTo(start)); MatcherAssert.assertThat( new Parallel<>( new PtVectSegment<>(new RandomPoint<>(), dir), seg ).resolve(dec), Matchers.is(true) ); }