atan()#

relationalai.std.math
#atan(number: Number|Producer) -> Expression

Calculates the inverse tangent (arctangent) of number, where number is specified in radians. If number is a Producer, atan() filters out any non-number values from the producer. Must be called in a rule or query context.

Parameters#

NameTypeDescription
numberProducer or Python Number objectThe value to calculate the arctangent of.

Returns#

An Expression object.

Example#

Use atan() to calculate the arctangent of a value in radians:

#import relationalai as rai
from relationalai.std import math


# =====
# SETUP
# =====

model = rai.Model("MyModel")
Satellite = model.Type("Satellite")

with model.rule():
    Satellite.add(id=1).set(name="SatA", orientation=0.5)
    Satellite.add(id=2).set(name="SatB", orientation=1.0)
    Satellite.add(id=3).set(name="SatC", orientation="INVALID") # Non-numeric value


# =======
# EXAMPLE
# =======

# Set an orientation_atan property to the arctangent of each satellite's orientation.
with model.rule():
    satellite = Satellite()
    satellite.set(orientation_atan=math.atan(satellite.orientation))

# Since atan() filters out non-numeric values, the orientation_atan property
# is not set for the satellite with ID 3.
with model.query() as select:
    satellite = Satellite()
    response = select(satellite.id, satellite.name, satellite.orientation_atan)

print(response.results)
#    id  name  orientation_atan
# 0   1  SatA          0.463648
# 1   2  SatB          0.785398
# 2   3  SatC               NaN

See Also#