@@ -14,6 +14,7 @@ import {
1414} from "../../util/commons.js" ;
1515import BodePlot from "../../view/plots/bodePlot.js" ;
1616import NyquistPlot from "../../view/plots/nyquistPlot.js" ;
17+ import TimeDomainPlot from "../../view/plots/timeDomainPlot.js" ;
1718
1819const bodeSteps = ( numeratorTermsArray , denominatorTermsArray ) => {
1920 const { magnitudeCurvePoints, phaseCurvePoints, characteristicNumbers } =
@@ -38,13 +39,31 @@ const nyquistSteps = (numeratorTermsArray, denominatorTermsArray) => {
3839 return [ curvePoints , stability ] ;
3940} ;
4041
42+ const timeDomainSteps = ( numeratorTermsArray , denominatorTermsArray ) => {
43+ const { timeResponseCurvePoints, trajectoryCurvePoints } = new TimeDomainPlot (
44+ null ,
45+ numeratorTermsArray ,
46+ denominatorTermsArray ,
47+ findComplexRootsOfPolynomial ( numeratorTermsArray ) ,
48+ findComplexRootsOfPolynomial ( denominatorTermsArray )
49+ ) ;
50+ return [ timeResponseCurvePoints , trajectoryCurvePoints ] ;
51+ } ;
52+
4153const bodeAndNyquistSteps = ( numeratorTermsArray , denominatorTermsArray ) => {
4254 return [
4355 ...bodeSteps ( numeratorTermsArray , denominatorTermsArray ) ,
4456 ...nyquistSteps ( numeratorTermsArray , denominatorTermsArray ) ,
4557 ] ;
4658} ;
4759
60+ const bodeAndTimeDomainSteps = ( numeratorTermsArray , denominatorTermsArray ) => {
61+ return [
62+ ...bodeSteps ( numeratorTermsArray , denominatorTermsArray ) ,
63+ ...timeDomainSteps ( numeratorTermsArray , denominatorTermsArray ) ,
64+ ] ;
65+ } ;
66+
4867export const plotsTests = {
4968 test1 : {
5069 description : "test1: tf([1, 0, 0, 0], [1])" ,
@@ -158,11 +177,13 @@ export const plotsTests = {
158177 description : "test4: tf([1], [1, 0, 1])" ,
159178 numeratorTermsArray : [ 1 ] ,
160179 denominatorTermsArray : [ 1 , 0 , 1 ] ,
161- steps : bodeSteps ,
180+ steps : bodeAndTimeDomainSteps ,
162181 assertions : (
163182 magnitudeCurvePoints ,
164183 phaseCurvePoints ,
165- characteristicNumbers
184+ characteristicNumbers ,
185+ timeResponseCurvePoints ,
186+ trajectoryCurvePoints
166187 ) => [
167188 [
168189 "Roll-off" ,
@@ -176,6 +197,18 @@ export const plotsTests = {
176197 "-180" ,
177198 toleranceTestsSmall ,
178199 ] ,
200+ [
201+ "Max f(t)" ,
202+ Math . max ( ...timeResponseCurvePoints . map ( ( x ) => x [ 1 ] ) ) ,
203+ 1 ,
204+ toleranceTestsSmall ,
205+ ] ,
206+ [
207+ "Min f(t)" ,
208+ Math . min ( ...timeResponseCurvePoints . map ( ( x ) => x [ 1 ] ) ) ,
209+ - 1 ,
210+ toleranceTestsSmall ,
211+ ] ,
179212 ] ,
180213 } ,
181214
0 commit comments