Skip to content

Commit c240715

Browse files
committed
ST6RI-906 Implemented functions from TrigFunctions library package.
1 parent 5a95437 commit c240715

12 files changed

Lines changed: 462 additions & 1 deletion

File tree

org.omg.sysml.execution/src/org/omg/sysml/execution/expressions/LibraryFunctionFactory.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.omg.sysml.execution.expressions.functions.numerical.*;
2727
import org.omg.sysml.execution.expressions.functions.sequence.*;
2828
import org.omg.sysml.execution.expressions.functions.string.*;
29+
import org.omg.sysml.execution.expressions.functions.trig.*;
2930

3031
public class LibraryFunctionFactory extends org.omg.sysml.expressions.ModelLevelLibraryFunctionFactory {
3132

@@ -75,6 +76,17 @@ protected void initializeFunctionMap() {
7576
// StringFunctions
7677
put(new StringLengthFunction());
7778
put(new StringSubstringFunction());
79+
80+
// TrigFunctions
81+
put(new ACosFunction());
82+
put(new AsinFunction());
83+
put(new AtanFunction());
84+
put(new CosFunction());
85+
put(new CotFunction());
86+
put(new DegFunction());
87+
put(new RadFunction());
88+
put(new SinFunction());
89+
put(new TanFunction());
7890
}
7991

8092
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of theGNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.sysml.execution.expressions.functions.trig;
23+
24+
import java.lang.Math;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.omg.sysml.lang.sysml.Element;
28+
import org.omg.sysml.util.EvaluationUtil;
29+
30+
public class ACosFunction extends TrigFunction {
31+
32+
@Override
33+
public String getOperatorName() {
34+
return "arccos";
35+
}
36+
37+
@Override
38+
protected EList<Element> realFunction(double x) {
39+
return EvaluationUtil.realResult(Math.acos(x));
40+
}
41+
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of theGNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.sysml.execution.expressions.functions.trig;
23+
24+
import java.lang.Math;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.omg.sysml.lang.sysml.Element;
28+
import org.omg.sysml.util.EvaluationUtil;
29+
30+
public class AsinFunction extends TrigFunction {
31+
32+
@Override
33+
public String getOperatorName() {
34+
return "arcsin";
35+
}
36+
37+
@Override
38+
protected EList<Element> realFunction(double x) {
39+
return EvaluationUtil.realResult(Math.asin(x));
40+
}
41+
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of theGNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.sysml.execution.expressions.functions.trig;
23+
24+
import java.lang.Math;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.omg.sysml.lang.sysml.Element;
28+
import org.omg.sysml.util.EvaluationUtil;
29+
30+
public class AtanFunction extends TrigFunction {
31+
32+
@Override
33+
public String getOperatorName() {
34+
return "arctan";
35+
}
36+
37+
@Override
38+
protected EList<Element> realFunction(double x) {
39+
return EvaluationUtil.realResult(Math.atan(x));
40+
}
41+
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of theGNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.sysml.execution.expressions.functions.trig;
23+
24+
import java.lang.Math;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.omg.sysml.lang.sysml.Element;
28+
import org.omg.sysml.util.EvaluationUtil;
29+
30+
public class CosFunction extends TrigFunction {
31+
32+
@Override
33+
public String getOperatorName() {
34+
return "cos";
35+
}
36+
37+
@Override
38+
protected EList<Element> realFunction(double x) {
39+
return EvaluationUtil.realResult(Math.cos(x));
40+
}
41+
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of theGNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.sysml.execution.expressions.functions.trig;
23+
24+
import java.lang.Math;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.omg.sysml.lang.sysml.Element;
28+
import org.omg.sysml.util.EvaluationUtil;
29+
30+
public class CotFunction extends TrigFunction {
31+
32+
@Override
33+
public String getOperatorName() {
34+
return "cot";
35+
}
36+
37+
@Override
38+
protected EList<Element> realFunction(double x) {
39+
return EvaluationUtil.realResult(1.0/Math.tan(x));
40+
}
41+
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of theGNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.sysml.execution.expressions.functions.trig;
23+
24+
import java.lang.Math;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.omg.sysml.lang.sysml.Element;
28+
import org.omg.sysml.util.EvaluationUtil;
29+
30+
public class DegFunction extends TrigFunction {
31+
32+
@Override
33+
public String getOperatorName() {
34+
return "deg";
35+
}
36+
37+
@Override
38+
protected EList<Element> realFunction(double x) {
39+
return EvaluationUtil.realResult(Math.toDegrees(x));
40+
}
41+
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of theGNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.sysml.execution.expressions.functions.trig;
23+
24+
import java.lang.Math;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.omg.sysml.lang.sysml.Element;
28+
import org.omg.sysml.util.EvaluationUtil;
29+
30+
public class RadFunction extends TrigFunction {
31+
32+
@Override
33+
public String getOperatorName() {
34+
return "rad";
35+
}
36+
37+
@Override
38+
protected EList<Element> realFunction(double x) {
39+
return EvaluationUtil.realResult(Math.toRadians(x));
40+
}
41+
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*******************************************************************************
2+
* SysML 2 Pilot Implementation
3+
* Copyright (c) 2026 Model Driven Solutions, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of theGNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*
20+
*******************************************************************************/
21+
22+
package org.omg.sysml.execution.expressions.functions.trig;
23+
24+
import java.lang.Math;
25+
26+
import org.eclipse.emf.common.util.EList;
27+
import org.omg.sysml.lang.sysml.Element;
28+
import org.omg.sysml.util.EvaluationUtil;
29+
30+
public class SinFunction extends TrigFunction {
31+
32+
@Override
33+
public String getOperatorName() {
34+
return "sin";
35+
}
36+
37+
@Override
38+
protected EList<Element> realFunction(double x) {
39+
return EvaluationUtil.realResult(Math.sin(x));
40+
}
41+
42+
}

0 commit comments

Comments
 (0)