radians()#

relationalai.std.math
#radians(degrees: Number|Producer) -> Expression

Converts an angle from degrees to radians. If degrees is a Producer, radians() filters out any non-numeric values from the producer. Must be called in a rule or query context.

Parameters#

NameTypeDescription
degreesProducer or Python Number objectThe angle in degrees to convert to radians.

Returns#

An Expression object.

Example#

Use radians() to convert an angle from degrees to radians:

#import relationalai as rai
from relationalai.std import math


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

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

with model.rule():
    Angle.add(id=1).set(degrees=90)
    Angle.add(id=2).set(degrees=180)
    Angle.add(id=3).set(degrees="INVALID")  # Non-numeric value


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

# Set a radians property to the radians equivalent of each angle's degrees value.
with model.rule():
    angle = Angle()
    angle.set(radians=math.radians(angle.degrees))

# Since radians() filters out non-numeric values, the radians property
# is not set for the angle with id=3.
with model.query() as select:
    angle = Angle()
    response = select(angle.id, angle.radians)

print(response.results)
#    id    radians
# 0   1   1.570796
# 1   2   3.141593
# 2   3        NaN

See Also#