@@ -335,10 +335,6 @@ SkyGrid::render(Renderer& renderer,
335335 int windowWidth,
336336 int windowHeight)
337337{
338- // 90 degree rotation about the x-axis used to transform coordinates
339- // to Celestia's system.
340- Quaterniond xrot90 = XRotation (-celestia::numbers::pi / 2.0 );
341-
342338 auto vfov = static_cast <double >(renderer.getProjectionMode ()->getFOV (observer.getZoom ()));
343339 double viewAspectRatio = static_cast <double >(windowWidth) / static_cast <double >(windowHeight);
344340
@@ -369,7 +365,13 @@ SkyGrid::render(Renderer& renderer,
369365 Vector3d c3 ( w, h, -1.0 );
370366
371367 Quaterniond cameraOrientation = renderer.getCameraOrientation ();
372- Matrix3d r = (cameraOrientation * xrot90 * m_orientation.conjugate () * xrot90.conjugate ()).toRotationMatrix ().transpose ();
368+
369+ // 90 degree rotation about the x-axis used to transform coordinates
370+ // to Celestia's system.
371+ Matrix3d r = (cameraOrientation *
372+ celmath::XRot90Conjugate<double > *
373+ m_orientation.conjugate () *
374+ celmath::XRot90<double >).toRotationMatrix ().transpose ();
373375
374376 // Transform the frustum corners by the camera and grid
375377 // rotations.
@@ -481,13 +483,15 @@ SkyGrid::render(Renderer& renderer,
481483 int endDec = (int ) std::floor (DEG_MIN_SEC_TOTAL * (maxDec * celestia::numbers::inv_pi) / (double ) decIncrement) * decIncrement;
482484
483485 // Get the orientation at single precision
484- Quaterniond q = xrot90 * m_orientation * xrot90. conjugate () ;
486+ Quaterniond q = celmath::XRot90Conjugate< double > * m_orientation * celmath::XRot90< double > ;
485487 Quaternionf orientationf = q.cast <float >();
486488
487489 // Radius of sphere is arbitrary, with the constraint that it shouldn't
488490 // intersect the near or far plane of the view frustum.
489491 Matrix4f m = renderer.getModelViewMatrix () *
490- celmath::rotate ((xrot90 * m_orientation.conjugate () * xrot90.conjugate ()).cast <float >()) *
492+ celmath::rotate ((celmath::XRot90Conjugate<double > *
493+ m_orientation.conjugate () *
494+ celmath::XRot90<double >).cast <float >()) *
491495 celmath::scale (1000 .0f );
492496 Matrices matrices = {&renderer.getProjectionMatrix (), &m};
493497
0 commit comments