Docs Menu

$radiansToDegrees (aggregation)

項目一覧

$radiansToDegrees

Converts an input value measured in radians to degrees.

$radiansToDegreesの構文は次のとおりです。

{ $radiansToDegrees: <expression> }

$radiansToDegreesは、数値に変換される有効なであればどれでもかまいません。

By default $radiansToDegrees returns values as a double. $radiansToDegrees can also return values as a 128-bit decimal as long as the <expression> resolves to a 128-bit decimal value.

式の詳細については、「式 」を参照してください。

If the argument resolves to a value of null or refers to a field that is missing, $radiansToDegrees returns null. If the argument resolves to NaN, $radiansToDegrees returns NaN. If the argument resolves to negative or positive infinity, $radiansToDegrees negative or positive infinity respectively.

結果

{ $radiansToDegrees: NaN }

NaN

{ $radiansToDegrees: null }

null

{ $radiansToDegrees : Infinity}

Infinity

{ $radiansToDegrees : -Infinity }

-Infinity

The trigonometry collection contains a document that contains three angles measured in radians:

{
"angle_a" : NumberDecimal("0.9272952180016122324285124629224290"),
"angle_b" : NumberDecimal("0.6435011087932843868028092287173227"),
"angle_c" : NumberDecimal("1.570796326794896619231321691639752")
}

The following aggregation operation uses the $radiansToDegrees expression to convert each value to its degree equivalent and add them to the input document using the $addFields pipeline stage.

db.trigangles.aggregate([
{
$addFields: {
"angle_a_deg" : { $radiansToDegrees : "$angle_a"},
"angle_b_deg" : { $radiansToDegrees : "$angle_b"},
"angle_c_deg" : { $radiansToDegrees : "$angle_c"}
}
}
])

この操作を実行すると次のドキュメントが返されます。

{
"_id" : ObjectId("5c50aec71c75c59232b3ede4"),
"angle_a" : NumberDecimal("0.9272952180016122324285124629224290"),
"angle_b" : NumberDecimal("0.6435011087932843868028092287173227"),
"angle_c" : NumberDecimal("1.570796326794896619231321691639752"),
"angle_a_deg" : NumberDecimal("53.13010235415597870314438744090659"),
"angle_b_deg" : NumberDecimal("36.86989764584402129685561255909341"),
"angle_c_deg" : NumberDecimal("90.00000000000000000000000000000000")
}

Since angle_a, angle_b, and angle_c are stored as 128-bit decimals, the output of $radiansToDegrees is a 128-bit decimal.

項目一覧