Dot implements InnerProduct<Double> { @Override public Vect<Double> rot(final Vect<Double> vect, final Degrees<Double> ang) { final Double angle = ang.resolve(this).doubleValue(); final FixedMatrix<Double> rot = new DblMatrix( 2, 2, Math.cos(angle), Math.sin(angle), -Math.sin(angle), Math.cos(angle) ); return rot.apply(vect); }  @Override Scalar<Double> product(final Vect<Double> foperand, final Vect<Double> soperand); @Override Scalar<Double> norm(final Vect<Double> vect); @Override Degrees<Double> angle(final Vect<Double> first, final Vect<Double> second); @Override Vect<Double> rot(final Vect<Double> vect, final Degrees<Double> ang);  }
@Test public void calculatesRotation() { final Vect<Double> vecta = new DblVect(1., 0.); final Degrees<Double> pifourth = new Degrees.Default<>(Math.PI / 4); final Dot dot = new Dot(); final Decimal field = new Decimal(); final double error = 1.e-6; Scalar<Double>[] image = dot.rot(vecta, pifourth).coords(); MatcherAssert.assertThat( field.actual(image[0]), Matchers.closeTo(Math.sqrt(2) / 2, error) ); MatcherAssert.assertThat( field.actual(image[1]), Matchers.closeTo(Math.sqrt(2) / 2, error) ); image = dot.rot(vecta, new Degrees.Default<>(0)).coords(); MatcherAssert.assertThat( field.actual(image[0]), Matchers.closeTo(1., error) ); MatcherAssert.assertThat( field.actual(image[1]), Matchers.closeTo(0., error) ); image = dot.rot(vecta, new Degrees.Default<>(Math.PI / 2)).coords(); MatcherAssert.assertThat( field.actual(image[0]), Matchers.closeTo(0., error) ); MatcherAssert.assertThat( field.actual(image[1]), Matchers.closeTo(1., error) ); image = dot.rot(vecta, new Degrees.Default<>(Math.PI)).coords(); MatcherAssert.assertThat( field.actual(image[0]), Matchers.closeTo(-1., error) ); MatcherAssert.assertThat( field.actual(image[1]), Matchers.closeTo(0., error) ); }