Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
trs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
trs
Commits
279f4039
Commit
279f4039
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Added some goniometric matching functions.
parent
98445a0e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/rules/__init__.py
+4
-3
4 additions, 3 deletions
src/rules/__init__.py
src/rules/goniometry.py
+33
-1
33 additions, 1 deletion
src/rules/goniometry.py
with
37 additions
and
4 deletions
src/rules/__init__.py
+
4
−
3
View file @
279f4039
...
...
@@ -12,7 +12,8 @@ from .fractions import match_constant_division, match_add_constant_fractions, \
from
.negation
import
match_negated_factor
,
match_negate_polynome
,
\
match_negated_division
from
.sort
import
match_sort_multiplicants
from
.goniometry
import
match_add_quadrants
,
match_negated_parameter
from
.goniometry
import
match_add_quadrants
,
match_negated_parameter
,
\
match_half_pi_subtraction
RULES
=
{
OP_ADD
:
[
match_add_numerics
,
match_add_constant_fractions
,
...
...
@@ -27,6 +28,6 @@ RULES = {
match_remove_negative_exponent
,
match_exponent_to_root
,
match_extend_exponent
,
match_constant_exponent
],
OP_NEG
:
[
match_negate_polynome
],
OP_SIN
:
[
match_negated_parameter
],
OP_COS
:
[
match_negated_parameter
],
OP_SIN
:
[
match_negated_parameter
,
match_half_pi_subtraction
],
OP_COS
:
[
match_negated_parameter
,
match_half_pi_subtraction
],
}
This diff is collapsed.
Click to expand it.
src/rules/goniometry.py
+
33
−
1
View file @
279f4039
from
.utils
import
is_fraction
from
..node
import
ExpressionNode
as
N
,
ExpressionLeaf
as
L
,
Scope
,
OP_ADD
,
\
OP_POW
,
OP_MUL
,
OP_SIN
,
OP_COS
,
OP_TAN
OP_POW
,
OP_MUL
,
OP_SIN
,
OP_COS
,
OP_TAN
,
PI
from
..possibilities
import
Possibility
as
P
,
MESSAGES
from
..translate
import
_
...
...
@@ -82,3 +83,34 @@ def negated_cosinus_parameter(root, args):
MESSAGES
[
negated_cosinus_parameter
]
=
\
_
(
'
Remove the negation from the cosinus parameter {1}.
'
)
def
match_half_pi_subtraction
(
node
):
"""
sin(pi / 2 - t) -> cos(t)
cos(pi / 2 - t) -> sin(t)
"""
assert
node
.
is_op
(
OP_SIN
)
or
node
.
is_op
(
OP_COS
)
if
node
[
0
].
is_op
(
OP_ADD
):
half_pi
,
t
=
node
[
0
]
if
half_pi
==
L
(
PI
)
/
2
:
if
node
.
op
==
OP_SIN
:
return
[
P
(
node
,
half_pi_subtraction_sinus
,
(
t
,))]
return
[]
def
match_standard_radian
(
node
):
"""
Apply a direct constant calculation from the following table.
| 0 | pi / 6 | pi / 4 | pi / 3 | pi / 2
----+---+-----------+-----------+-----------+-------
sin | 0 | 1/2 | sqrt(2)/2 | sqrt(3)/2 | 1
cos | 1 | sqrt(3)/2 | sqrt(2)/2 | 1/2 | 0
tan | 0 | sqrt(3)/3 | 1 | sqrt(3) | -
"""
# TODO: implement
pass
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment