TEST_F(PluginCompatibilityTest, PreBorel) { serialization::Multivector message; Vector<Length, Barycentric> const v({ -1 * Metre, 2 * Metre, 3 * Metre }); v.WriteToMessage(&message); message.mutable_frame()->set_tag(serialization::Frame::PRE_BOREL_BARYCENTRIC); Vector<Length, Barycentric> const w = Vector<Length, Barycentric>::ReadFromMessage(message); Vector<Length, Barycentric> const expected_w( { -1 * Metre, 3 * Metre, 2 * Metre }); EXPECT_EQ(expected_w, w); Bivector<Length, Barycentric> const b({ 4 * Metre, 5 * Metre, -6 * Metre }); b.WriteToMessage(&message); message.mutable_frame()->set_tag(serialization::Frame::PRE_BOREL_BARYCENTRIC); Bivector<Length, Barycentric> const c = Bivector<Length, Barycentric>::ReadFromMessage(message); Bivector<Length, Barycentric> const expected_c( { -4 * Metre, 6 * Metre, -5 * Metre }); EXPECT_EQ(expected_c, c); Trivector<Length, Barycentric> const t(-7 * Metre); t.WriteToMessage(&message); message.mutable_frame()->set_tag(serialization::Frame::PRE_BOREL_BARYCENTRIC); Trivector<Length, Barycentric> const u = Trivector<Length, Barycentric>::ReadFromMessage(message); Trivector<Length, Barycentric> const expected_u(7 * Metre); EXPECT_EQ(expected_u, u); }
Rotation<Frame, Frame> Exp(Bivector<quantities::Angle, Frame> const& exponent) { quantities::Angle const angle = exponent.Norm(); if (angle == quantities::Angle()) { return Rotation<Frame, Frame>::Identity(); } else { return Rotation<Frame, Frame>(angle, exponent); } }
Rotation<Frenet<ThisFrame>, ThisFrame> DynamicFrame<InertialFrame, ThisFrame>::FrenetFrame( Instant const& t, DegreesOfFreedom<ThisFrame> const& degrees_of_freedom) const { Velocity<ThisFrame> const& velocity = degrees_of_freedom.velocity(); Vector<Acceleration, ThisFrame> const acceleration = GeometricAcceleration(t, degrees_of_freedom); Vector<Acceleration, ThisFrame> normal_acceleration = acceleration; velocity.template Orthogonalize<Acceleration>(&normal_acceleration); Vector<double, ThisFrame> tangent = Normalize(velocity); Vector<double, ThisFrame> normal = Normalize(normal_acceleration); Bivector<double, ThisFrame> binormal = Wedge(tangent, normal); // Maps |tangent| to {1, 0, 0}, |normal| to {0, 1, 0}, and |binormal| to // {0, 0, 1}. return Rotation<Frenet<ThisFrame>, ThisFrame>( R3x3Matrix(tangent.coordinates(), normal.coordinates(), binormal.coordinates()).Transpose()); }
Bivector<Scalar, ToFrame> Identity<FromFrame, ToFrame>::operator()( Bivector<Scalar, FromFrame> const& bivector) const { return Bivector<Scalar, ToFrame>(bivector.coordinates()); }
Vector<quantities::Product<LScalar, RScalar>, Frame> operator*( Trivector<LScalar, Frame> const& left, Bivector<RScalar, Frame> const& right) { return Vector<quantities::Product<LScalar, RScalar>, Frame>( left.coordinates() * right.coordinates()); }
quantities::Angle AngleBetween(Bivector<LScalar, Frame> const& v, Bivector<RScalar, Frame> const& w) { auto const v_norm_w = v * w.Norm(); auto const w_norm_v = w * v.Norm(); return 2 * ArcTan((v_norm_w - w_norm_v).Norm(), (v_norm_w + w_norm_v).Norm()); }
Bivector<quantities::Product<LScalar, RScalar>, Frame> Commutator( Bivector<LScalar, Frame> const& left, Bivector<RScalar, Frame> const& right) { return Bivector<quantities::Product<LScalar, RScalar>, Frame>( Cross(left.coordinates(), right.coordinates())); }
Trivector<quantities::Product<LScalar, RScalar>, Frame> Wedge( Vector<LScalar, Frame> const& left, Bivector<RScalar, Frame> const& right) { return Trivector<quantities::Product<LScalar, RScalar>, Frame>( Dot(left.coordinates(), right.coordinates())); }
quantities::Product<LScalar, RScalar> InnerProduct( Bivector<LScalar, Frame> const& left, Bivector<RScalar, Frame> const& right) { return Dot(left.coordinates(), right.coordinates()); }
Bivector operator*(const BaseTransformation &transformation, const Bivector &bivector) { return Bivector(transformation * bivector.u(), transformation * bivector.v()); }
Rotation<Frame, Frame> Exp(Bivector<quantities::Angle, Frame> const& exponent) { return Rotation<Frame, Frame>(exponent.Norm(), exponent); }
inline Vector<quantities::Product<LScalar, RScalar>, Frame> operator*( Bivector<LScalar, Frame> const& left, Vector<RScalar, Frame> const& right) { return Vector<quantities::Product<LScalar, RScalar>, Frame>( Cross(left.coordinates(), right.coordinates())); }
Bivector<Scalar, ToFrame> Permutation<FromFrame, ToFrame>::operator()( Bivector<Scalar, FromFrame> const& bivector) const { return Bivector<Scalar, ToFrame>( Determinant() * (*this)(bivector.coordinates())); }