Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
279f4039
Commit
279f4039
authored
Feb 25, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some goniometric matching functions.
parent
98445a0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
4 deletions
+37
-4
src/rules/__init__.py
src/rules/__init__.py
+4
-3
src/rules/goniometry.py
src/rules/goniometry.py
+33
-1
No files found.
src/rules/__init__.py
View file @
279f4039
...
@@ -12,7 +12,8 @@ from .fractions import match_constant_division, match_add_constant_fractions, \
...
@@ -12,7 +12,8 @@ from .fractions import match_constant_division, match_add_constant_fractions, \
from
.negation
import
match_negated_factor
,
match_negate_polynome
,
\
from
.negation
import
match_negated_factor
,
match_negate_polynome
,
\
match_negated_division
match_negated_division
from
.sort
import
match_sort_multiplicants
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
=
{
RULES
=
{
OP_ADD
:
[
match_add_numerics
,
match_add_constant_fractions
,
OP_ADD
:
[
match_add_numerics
,
match_add_constant_fractions
,
...
@@ -27,6 +28,6 @@ RULES = {
...
@@ -27,6 +28,6 @@ RULES = {
match_remove_negative_exponent
,
match_exponent_to_root
,
match_remove_negative_exponent
,
match_exponent_to_root
,
match_extend_exponent
,
match_constant_exponent
],
match_extend_exponent
,
match_constant_exponent
],
OP_NEG
:
[
match_negate_polynome
],
OP_NEG
:
[
match_negate_polynome
],
OP_SIN
:
[
match_negated_parameter
],
OP_SIN
:
[
match_negated_parameter
,
match_half_pi_subtraction
],
OP_COS
:
[
match_negated_parameter
],
OP_COS
:
[
match_negated_parameter
,
match_half_pi_subtraction
],
}
}
src/rules/goniometry.py
View file @
279f4039
from
.utils
import
is_fraction
from
..node
import
ExpressionNode
as
N
,
ExpressionLeaf
as
L
,
Scope
,
OP_ADD
,
\
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
..possibilities
import
Possibility
as
P
,
MESSAGES
from
..translate
import
_
from
..translate
import
_
...
@@ -82,3 +83,34 @@ def negated_cosinus_parameter(root, args):
...
@@ -82,3 +83,34 @@ def negated_cosinus_parameter(root, args):
MESSAGES
[
negated_cosinus_parameter
]
=
\
MESSAGES
[
negated_cosinus_parameter
]
=
\
_
(
'Remove the negation from the cosinus parameter {1}.'
)
_
(
'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
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