Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
cassiopee
jalhyd
Commits
1ff170bf
Commit
1ff170bf
authored
Nov 13, 2019
by
Mathias Chouet
🍝
Browse files
Trigo: adjust definition domains on operation change
parent
89d34483
Changes
2
Hide whitespace changes
Inline
Side-by-side
spec/trigo.spec.ts
View file @
1ff170bf
...
...
@@ -173,4 +173,33 @@ describe("Class Trigo: ", () => {
expect
(
trig
.
calculatedParam
.
symbol
).
toBe
(
"
Y
"
);
});
it
(
"
definition domains depending on operation
"
,
()
=>
{
const
nub
=
new
Trigo
(
new
TrigoParams
(
1.5
,
1
));
nub
.
calculatedParam
=
nub
.
prms
.
Y
;
nub
.
unit
=
TrigoUnit
.
RAD
;
// RAD / COS (COS is default operation)
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
min
).
toBe
(
-
1
);
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
max
).
toBe
(
1
);
// RAD / TAN
nub
.
operation
=
TrigoOperation
.
TAN
;
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
min
).
toBe
(
-
Infinity
);
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
max
).
toBe
(
Infinity
);
// RAD / SIN
nub
.
operation
=
TrigoOperation
.
SIN
;
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
min
).
toBe
(
-
1
);
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
max
).
toBe
(
1
);
// RAD / SINH
nub
.
operation
=
TrigoOperation
.
SINH
;
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
min
).
toBe
(
-
Infinity
);
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
max
).
toBe
(
Infinity
);
// RAD / TANH
nub
.
operation
=
TrigoOperation
.
TANH
;
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
min
).
toBe
(
-
0.99999999
);
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
max
).
toBe
(
0.99999999
);
// RAD / COSH
nub
.
operation
=
TrigoOperation
.
COSH
;
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
min
).
toBe
(
1
);
expect
(
nub
.
prms
.
Y
.
domain
.
interval
.
max
).
toBe
(
Infinity
);
});
});
src/trigo.ts
View file @
1ff170bf
import
{
CalculatorType
}
from
"
./compute-node
"
;
import
{
Nub
}
from
"
./nub
"
;
import
{
ParamCalculability
}
from
"
./param/param-definition
"
;
import
{
ParamDomainValue
}
from
"
./param/param-domain
"
;
import
{
ParamDomain
,
ParamDomainValue
}
from
"
./param/param-domain
"
;
import
{
TrigoParams
}
from
"
./trigo_params
"
;
import
{
Interval
}
from
"
./util/interval
"
;
import
{
Observer
}
from
"
./util/observer
"
;
import
{
Result
}
from
"
./util/result
"
;
...
...
@@ -132,19 +131,18 @@ export class Trigo extends Nub implements Observer {
if
(
data
.
action
===
"
propertyChange
"
)
{
switch
(
data
.
name
)
{
case
"
trigoOperation
"
:
case
"
trigoUnit
"
:
// adjust definition domains
const
un
=
this
.
unit
;
switch
(
this
.
operation
)
{
case
TrigoOperation
.
COS
:
case
TrigoOperation
.
SIN
:
// [-1,1]
this
.
prms
.
Y
.
d
omain
.
interval
.
setInterval
(
new
Interval
(
-
1
,
1
));
this
.
prms
.
Y
.
setD
omain
(
new
ParamDomain
(
ParamDomainValue
.
INTERVAL
,
-
1
,
1
));
break
;
case
TrigoOperation
.
TANH
:
// ]-1,1[
// @TODO manage boundaries exclusion in Interval
this
.
prms
.
Y
.
d
omain
.
interval
.
setInterval
(
new
Interval
(
-
0.99999999
,
0.99999999
));
this
.
prms
.
Y
.
setD
omain
(
new
ParamDomain
(
ParamDomainValue
.
INTERVAL
,
-
0.99999999
,
0.99999999
));
break
;
case
TrigoOperation
.
TAN
:
case
TrigoOperation
.
SINH
:
...
...
@@ -153,7 +151,7 @@ export class Trigo extends Nub implements Observer {
break
;
case
TrigoOperation
.
COSH
:
// [1,+∞[
this
.
prms
.
Y
.
d
omain
.
interval
.
setInterval
(
new
Interval
(
1
,
Infinity
));
this
.
prms
.
Y
.
setD
omain
(
new
ParamDomain
(
ParamDomainValue
.
INTERVAL
,
1
,
Infinity
));
break
;
}
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment