blob: 1a28f8e0cc4586d2c95dd1fb800f816e444067bc [file] [log] [blame]
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Trigonometric Functions &mdash; Apache AGE master documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/custom.css" type="text/css" />
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="String Functions" href="string_functions.html" />
<link rel="prev" title="Logarithmic Functions" href="logarithmic_functions.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home"> Apache AGE
<img src="../_static/logo.png" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption" role="heading"><span class="caption-text">Introduction</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../intro/overview.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/setup.html">Setup</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/graphs.html">Graphs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/cypher.html">The AGE Cypher Query Format</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/types.html">Data Types - An Introduction to agtype</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/comparability.html">Comparability, Equality, Orderability and Equivalence</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/operators.html">Operators</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/aggregation.html">Aggregation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/agload.html">Importing graph from files</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Clauses</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../clauses/match.html">MATCH</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/with.html">WITH</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/return.html">RETURN</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/order_by.html">ORDER BY</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/skip.html">SKIP</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/limit.html">LIMIT</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/create.html">CREATE</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/delete.html">DELETE</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/set.html">SET</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/remove.html">REMOVE</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/merge.html">MERGE</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Functions</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="predicate_functions.html">Predicate Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="scalar_functions.html">Scalar Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="list_functions.html">List Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="numeric_functions.html">Numeric Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="logarithmic_functions.html">Logarithmic Functions</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Trigonometric Functions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#degrees">degrees</a></li>
<li class="toctree-l2"><a class="reference internal" href="#radians">radians</a></li>
<li class="toctree-l2"><a class="reference internal" href="#pi">pi</a></li>
<li class="toctree-l2"><a class="reference internal" href="#sin">sin</a></li>
<li class="toctree-l2"><a class="reference internal" href="#cos">cos</a></li>
<li class="toctree-l2"><a class="reference internal" href="#tan">tan</a></li>
<li class="toctree-l2"><a class="reference internal" href="#asin">asin</a></li>
<li class="toctree-l2"><a class="reference internal" href="#acos">acos</a></li>
<li class="toctree-l2"><a class="reference internal" href="#atan">atan</a></li>
<li class="toctree-l2"><a class="reference internal" href="#atan2">atan2</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="string_functions.html">String Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="aggregate_functions.html">Aggregation Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="user_functions.html">User defined functions</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">AGE Beyond Cypher</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../advanced/advanced_overview.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/advanced.html">Using Cypher in a CTE Expression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/advanced.html#using-cypher-in-a-join-expression">Using Cypher in a Join expression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/advanced.html#cypher-in-sql-expressions">Cypher in SQL expressions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/prepared_statements.html">Prepared Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/plpgsql.html">PL/pgSQL Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/sql_in_cypher.html">SQL In Cypher</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Contributing</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../contributing/run_tests.html">Run the test suite</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">Apache AGE</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li>Trigonometric Functions</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/apache/incubator-age-website/blob/master/docs/functions/trigonometric_functions.md" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="tex2jax_ignore mathjax_ignore section" id="trigonometric-functions">
<h1>Trigonometric Functions<a class="headerlink" href="#trigonometric-functions" title="Permalink to this headline"></a></h1>
<div class="section" id="degrees">
<h2>degrees<a class="headerlink" href="#degrees" title="Permalink to this headline"></a></h2>
<p>degrees() converts radians to degrees.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">degrees(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">Float</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An agtype number expression that represents the angle in radians.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>degrees(null) returns null.</p></li>
</ul>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN degrees(3.14159)
$$) as (deg agtype);
</pre></div>
</div>
<p>The number of degrees in something close to pi is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>deg
</td>
</tr>
<tr>
<td>179.99984796050427
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="radians">
<h2>radians<a class="headerlink" href="#radians" title="Permalink to this headline"></a></h2>
<p>radians() converts radians to degrees.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">radians(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">Float</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An agtype number expression that represents the angle in degrees.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>radians(null) returns null.</p></li>
</ul>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN radians(180)
$$) as (rad agtype);
</pre></div>
</div>
<p>The number of degrees in something close to pi is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>rad
</td>
</tr>
<tr>
<td>3.14159265358979
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="pi">
<h2>pi<a class="headerlink" href="#pi" title="Permalink to this headline"></a></h2>
<p>pi() returns the mathematical constant pi.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">pi()</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">agtype</span> <span class="nb">float</span><span class="o">.</span>
</pre></div>
</div>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN pi()
$$) as (p agtype);
</pre></div>
</div>
<p>The constant pi is returned.</p>
<p>Result:</p>
<table>
<tr>
<td>p
</td>
</tr>
<tr>
<td>3.141592653589793
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="sin">
<h2>sin<a class="headerlink" href="#sin" title="Permalink to this headline"></a></h2>
<p>sin() returns the sine of a number.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">sin(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">Float</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An agtype number expression that represents the angle in radians.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>sin(null) returns null.</p></li>
</ul>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN sin(0.5)
$$) as (s agtype);
</pre></div>
</div>
<p>The sine of 0.5 is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>s
</td>
</tr>
<tr>
<td>0.479425538604203
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="cos">
<h2>cos<a class="headerlink" href="#cos" title="Permalink to this headline"></a></h2>
<p>cos() returns the cosine of a number.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">cos(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">Float</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An agtype expression that represents the angle in radians.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>cos(null) returns null.</p></li>
</ul>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN cosin(0.5)
$$) as (c agtype);
</pre></div>
</div>
<p>The cosine of 0.5 is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>c
</td>
</tr>
<tr>
<td>0.8775825618903728
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="tan">
<h2>tan<a class="headerlink" href="#tan" title="Permalink to this headline"></a></h2>
<p>tan() returns the tangent of a number.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">tan(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">Float</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An agtype number expression that represents the angle in radians.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>tan(null) returns null.</p></li>
</ul>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN tan(0.5)
$$) as (t agtype);
</pre></div>
</div>
<p>The tangent of 0.5 is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>t
</td>
</tr>
<tr>
<td>0.5463024898437905
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="asin">
<h2>asin<a class="headerlink" href="#asin" title="Permalink to this headline"></a></h2>
<p>asin() returns the arcsine of a number.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">asin(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">Float</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An agtype number expression that represents the angle in radians.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>asin(null) returns null.</p></li>
<li><p>If (expression &lt; -1) or (expression &gt; 1), then (asin(expression)) returns null.</p></li>
</ul>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN asin(0.5)
$$) as (s agtype);
</pre></div>
</div>
<p>The arcsine of 0.5 is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>s
</td>
</tr>
<tr>
<td>0.523598775598299
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="acos">
<h2>acos<a class="headerlink" href="#acos" title="Permalink to this headline"></a></h2>
<p>acos() returns the arccosine of a number.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">acos(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">Float</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An agtype number expression that represents the angle in radians.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>acos(null) returns null.</p></li>
<li><p>If (expression &lt; -1) or (expression &gt; 1), then (acos(expression)) returns null.</p></li>
</ul>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN acos(0.5)
$$) as (arc_c agtype);
</pre></div>
</div>
<p>The arccosine of 0.5 is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>arc_c
</td>
</tr>
<tr>
<td>1.0471975511965979
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="atan">
<h2>atan<a class="headerlink" href="#atan" title="Permalink to this headline"></a></h2>
<p>atan() returns the arctangent of a number.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">atan(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">Float</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An agtype number expression that represents the angle in radians.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>atan(null) returns null.</p></li>
</ul>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN atan(0.5)
$$) as (arc_t agtype);
</pre></div>
</div>
<p>The arccosine of 0.5 is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>arc_t
</td>
</tr>
<tr>
<td>0.463647609000806
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="atan2">
<h2>atan2<a class="headerlink" href="#atan2" title="Permalink to this headline"></a></h2>
<p>atan2() returns the arctangent2 of a set of coordinates in radians.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">atan2(expression1,</span> <span class="pre">expression2)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">Float</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression1
</td>
<td>An agtype number expression for y that represents the angle in radians.
</td>
</tr>
<tr>
<td>expression2
</td>
<td>An agtype number expression for x that represents the angle in radians.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>atan2(null, null), atan2(null, expression2) and atan(expression1, null) all return null.</p></li>
</ul>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN atan2(0.5, 0.6)
$$) as (arc_t2 agtype);
</pre></div>
</div>
<p>The arctangent2 of 0.5 and 0.6 is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>arc_t2
</td>
</tr>
<tr>
<td>0.694738276196703
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="string_functions.html" class="btn btn-neutral float-right" title="String Functions" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="logarithmic_functions.html" class="btn btn-neutral float-left" title="Logarithmic Functions" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&#169; Copyright 2021, Apache AGE.
</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> Other Versions</span>
v: manual-link
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>Versions</dt>
<dd><a href="../../documentation-staging/index.html">documentation-staging</a></dd>
<dd><a href="trigonometric_functions.html">manual-link</a></dd>
<dd><a href="../../master/index.html">master</a></dd>
<dd><a href="../../v0.6.0/index.html">v0.6.0</a></dd>
</dl>
</div>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>