@@ -101,5 +101,47 @@ public void AtDate()
101101 Assert . Equal ( TimeSystem . Time . J2000TDB . AddSeconds ( 10 ) , res . Epoch ) ;
102102 Assert . Equal ( Frames . Frame . ECLIPTIC_J2000 , res . ReferenceFrame ) ;
103103 }
104+
105+ [ Fact ]
106+ public void Interpolate_SameReferenceFrame_ReturnsInterpolatedState ( )
107+ {
108+ // Arrange
109+ var initialOrientation = new StateOrientation ( new Quaternion ( 1 , 0 , 0 , 0 ) , new Vector3 ( 10 , 20 , 30 ) , TimeSystem . Time . J2000TDB , Frames . Frame . ICRF ) ;
110+ var finalOrientation = new StateOrientation ( new Quaternion ( 0 , 1 , 0 , 0 ) , new Vector3 ( 20 , 30 , 40 ) , TimeSystem . Time . J2000TDB . AddSeconds ( 10 ) , Frames . Frame . ICRF ) ;
111+ var date = TimeSystem . Time . J2000TDB . AddSeconds ( 5 ) ;
112+
113+ // Act
114+ var result = initialOrientation . Interpolate ( finalOrientation , date ) ;
115+
116+ // Assert
117+ Assert . Equal ( new Quaternion ( 0.7071067811865476 , 0.7071067811865476 , 0 , 0 ) , result . Rotation , TestHelpers . QuaternionComparer ) ;
118+ Assert . Equal ( new Vector3 ( 15 , 25 , 35 ) , result . AngularVelocity ) ;
119+ Assert . Equal ( date , result . Epoch ) ;
120+ Assert . Equal ( Frames . Frame . ICRF , result . ReferenceFrame ) ;
121+ }
122+
123+ [ Fact ]
124+ public void Interpolate_DifferentReferenceFrames_ThrowsArgumentException ( )
125+ {
126+ // Arrange
127+ var initialOrientation = new StateOrientation ( new Quaternion ( 1 , 0 , 0 , 0 ) , new Vector3 ( 0 , 0 , 0 ) , TimeSystem . Time . J2000TDB , Frames . Frame . ICRF ) ;
128+ var finalOrientation = new StateOrientation ( new Quaternion ( 0 , 1 , 0 , 0 ) , new Vector3 ( 0 , 0 , 0 ) , TimeSystem . Time . J2000TDB . AddSeconds ( 10 ) , Frames . Frame . ECLIPTIC_J2000 ) ;
129+ var date = TimeSystem . Time . J2000TDB . AddSeconds ( 5 ) ;
130+
131+ // Act & Assert
132+ Assert . Throws < ArgumentException > ( ( ) => initialOrientation . Interpolate ( finalOrientation , date ) ) ;
133+ }
134+
135+ [ Fact ]
136+ public void Interpolate_DateOutOfRange_ThrowsArgumentException ( )
137+ {
138+ // Arrange
139+ var initialOrientation = new StateOrientation ( new Quaternion ( 1 , 0 , 0 , 0 ) , new Vector3 ( 0 , 0 , 0 ) , TimeSystem . Time . J2000TDB , Frames . Frame . ICRF ) ;
140+ var finalOrientation = new StateOrientation ( new Quaternion ( 0 , 1 , 0 , 0 ) , new Vector3 ( 0 , 0 , 0 ) , TimeSystem . Time . J2000TDB . AddSeconds ( 10 ) , Frames . Frame . ICRF ) ;
141+ var date = TimeSystem . Time . J2000TDB . AddSeconds ( 15 ) ;
142+
143+ // Act & Assert
144+ Assert . Throws < ArgumentException > ( ( ) => initialOrientation . Interpolate ( finalOrientation , date ) ) ;
145+ }
104146 }
105147}
0 commit comments