1
1
import { Graph , positiveRange } from './Graph.js' ;
2
+ import { drawPolygon } from '../jsxgraphUtils.js' ;
2
3
3
4
export const defaults = [
4
5
{
@@ -101,6 +102,10 @@ const eq3 = function(a, b, c, d) {
101
102
return ( a - c ) / ( b + d ) ;
102
103
} ;
103
104
105
+ const embmarket3 = function ( a , b , c , d , f , g ) {
106
+ return f - g * eq3 ( a , b , c , d ) ;
107
+ } ;
108
+
104
109
const epoint3 = function ( a , b , c , d ) {
105
110
return [ eq3 ( a , b , c , d ) , ep3 ( a , b , c , d ) ] ;
106
111
} ;
@@ -115,28 +120,86 @@ const evint3 = function(a, b, c, d) {
115
120
116
121
export class PositiveExternalityIndustryGraph extends Graph {
117
122
static getGraphPane ( gFunctionChoice , gA1 , gA2 , gA3 , gA4 , gA5 , gA6 ) {
118
- return [
119
- {
120
- label : 'Unregulated Output Q*' ,
121
- color : 'red' ,
122
- value : eq3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
123
- } ,
124
- {
125
- label : 'Unregulated Price P*' ,
126
- color : 'red' ,
127
- value : ep3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
128
- } ,
129
- {
130
- label : 'Socially Desirable Output q<sup>soc</sup>' ,
131
- color : 'orange' ,
132
- value : sq3 ( gA1 , gA2 , gA3 , gA4 , gA5 , gA6 ) . toFixed ( 2 )
133
- } ,
134
- {
135
- label : 'Socially Desirable Price P<sup>soc</sup>' ,
136
- color : 'orange' ,
137
- value : sp3 ( gA1 , gA2 , gA3 , gA4 , gA5 , gA6 ) . toFixed ( 2 )
138
- } ,
139
- ] ;
123
+ if ( gFunctionChoice === 0 ) {
124
+ return [
125
+ {
126
+ label : 'Unregulated Output Q*' ,
127
+ color : 'red' ,
128
+ value : eq3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
129
+ } ,
130
+ {
131
+ label : 'Unregulated Price P*' ,
132
+ color : 'red' ,
133
+ value : ep3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
134
+ } ,
135
+ {
136
+ label : 'Socially Desirable Output q<sup>soc</sup>' ,
137
+ color : 'orange' ,
138
+ value : sq3 ( gA1 , gA2 , gA3 , gA4 , gA5 , gA6 ) . toFixed ( 2 )
139
+ } ,
140
+ {
141
+ label : 'Socially Desirable Price P<sup>soc</sup>' ,
142
+ color : 'orange' ,
143
+ value : sp3 ( gA1 , gA2 , gA3 , gA4 , gA5 , gA6 ) . toFixed ( 2 )
144
+ } ,
145
+ ] ;
146
+ } else if ( gFunctionChoice === 1 ) {
147
+ return [
148
+ {
149
+ label : 'Unregulated Output Q*' ,
150
+ color : 'red' ,
151
+ value : eq3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
152
+ } ,
153
+ {
154
+ label : 'P*' ,
155
+ color : 'red' ,
156
+ value : eq3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
157
+ } ,
158
+ {
159
+ label : 'External Total Benefit' ,
160
+ color : 'green' ,
161
+ value : ep3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
162
+ }
163
+ ] ;
164
+ } else if ( gFunctionChoice === 2 ) {
165
+ return [
166
+ {
167
+ label : 'Unregulated Output Q*' ,
168
+ color : 'red' ,
169
+ value : eq3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
170
+ } ,
171
+ {
172
+ label : 'Unregulated Price P*' ,
173
+ color : 'red' ,
174
+ value : eq3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
175
+ } ,
176
+ {
177
+ label : 'Socially Desirable Output Q<sup>soc</sup>' ,
178
+ color : 'orange' ,
179
+ value : eq3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
180
+ } ,
181
+ {
182
+ label : 'Socially Desirable Price P<sup>soc</sup>' ,
183
+ color : 'orange' ,
184
+ value : eq3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
185
+ } ,
186
+ {
187
+ label : 'External Total Benefit' ,
188
+ color : 'green' ,
189
+ value : ep3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
190
+ } ,
191
+ {
192
+ label : 'External Gain' ,
193
+ color : 'green' ,
194
+ value : ep3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
195
+ } ,
196
+ {
197
+ label : 'Market Loss' ,
198
+ color : 'red' ,
199
+ value : ep3 ( gA1 , gA2 , gA3 , gA4 ) . toFixed ( 2 )
200
+ }
201
+ ] ;
202
+ }
140
203
}
141
204
142
205
make ( ) {
@@ -225,25 +288,27 @@ export class PositiveExternalityIndustryGraph extends Graph {
225
288
this . options . gA1 , this . options . gA2 , this . options . gA3 ,
226
289
this . options . gA4 , this . options . gA5 , this . options . gA6 ) ;
227
290
228
- this . showIntersection (
229
- this . board . create ( 'line' , [
230
- shint3 (
231
- this . options . gA1 , this . options . gA2 , this . options . gA3 ,
232
- this . options . gA4 , this . options . gA5 , this . options . gA6 ) ,
233
- spointEvaluated
234
- ] , {
235
- visible : false
236
- } ) ,
237
- this . board . create ( 'line' , [
238
- svint3 (
239
- this . options . gA1 , this . options . gA2 , this . options . gA3 ,
240
- this . options . gA4 , this . options . gA5 , this . options . gA6 ) ,
241
- spointEvaluated
242
- ] , {
243
- visible : false
244
- } ) ,
245
- false , 'Social' , null , 'Q<sup>soc</sup>' ,
246
- false , false , this . l1Color ) ;
291
+ if ( this . options . gFunctionChoice !== 1 ) {
292
+ this . showIntersection (
293
+ this . board . create ( 'line' , [
294
+ shint3 (
295
+ this . options . gA1 , this . options . gA2 , this . options . gA3 ,
296
+ this . options . gA4 , this . options . gA5 , this . options . gA6 ) ,
297
+ spointEvaluated
298
+ ] , {
299
+ visible : false
300
+ } ) ,
301
+ this . board . create ( 'line' , [
302
+ svint3 (
303
+ this . options . gA1 , this . options . gA2 , this . options . gA3 ,
304
+ this . options . gA4 , this . options . gA5 , this . options . gA6 ) ,
305
+ spointEvaluated
306
+ ] , {
307
+ visible : false
308
+ } ) ,
309
+ false , 'Social' , null , 'Q<sup>soc</sup>' ,
310
+ false , false , this . l1Color ) ;
311
+ }
247
312
248
313
const epointEvaluated = epoint3 (
249
314
this . options . gA1 , this . options . gA2 , this . options . gA3 ,
@@ -269,6 +334,24 @@ export class PositiveExternalityIndustryGraph extends Graph {
269
334
false , 'Market' , null , 'Q' ,
270
335
false , false , this . l4Color ) ;
271
336
}
337
+
338
+ if ( this . options . gFunctionChoice >= 1 ) {
339
+ const eq3Evaluated = eq3 (
340
+ this . options . gA1 , this . options . gA2 ,
341
+ this . options . gA3 , this . options . gA4 ) ;
342
+ drawPolygon (
343
+ this . board , [
344
+ [ eq3Evaluated , embmarket3 (
345
+ this . options . gA1 , this . options . gA2 ,
346
+ this . options . gA3 , this . options . gA4 ,
347
+ this . options . gA5 , this . options . gA6
348
+ ) ] ,
349
+ [ eq3Evaluated , 0 ] ,
350
+ [ 0 , 0 ] ,
351
+ [ 0 , this . options . gA5 ]
352
+ ] , null , 'green'
353
+ ) ;
354
+ }
272
355
}
273
356
}
274
357
0 commit comments