AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

$degreesToRadians(式演算子)

$degreesToRadians

度単位で測定された入力値をラジアンに変換します。

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

{ $degreesToRadians: <expression> }

$degreesToRadians takes any valid expression that resolves to a number.

$degreesToRadiansデフォルトでは、 は値をdouble として返します。$degreesToRadians 128<expression>は、 が128 ビットの 10 進数値に解決される限り、 ビットの 10 進数として値を返すこともできます。

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

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

結果

{ $degreesToRadians: NaN }

NaN

{ $degreesToRadians: null }

null

{ $degreesToRadians : Infinity}

Infinity

{ $degreesToRadians : -Infinity }

-Infinity

trigonometryコレクションには、度単位で測定された 3 つの角度を含むドキュメントが含まれています。

{
"angle_a" : Decimal128("53.13010235415597870314438744090659"),
"angle_b" : Decimal128("36.86989764584402129685561255909341"),
"angle_c" : Decimal128("90")
}

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

db.trigonometry.aggregate([
{
$addFields: {
"angle_a_rad" : { $degreesToRadians : "$angle_a"},
"angle_b_rad" : { $degreesToRadians : "$angle_b"},
"angle_c_rad" : { $degreesToRadians : "$angle_c"}
}
}
])

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

{
"_id" : ObjectId("5c50aec71c75c59232b3ede4"),
"angle_a" : Decimal128("53.13010235415597870314438744090660"),
"angle_b" : Decimal128("36.86989764584402129685561255909341"),
"angle_c" : Decimal128("90"),
"angle_a_rad" : Decimal128("0.9272952180016122324285124629224290"),
"angle_b_rad" : Decimal128("0.6435011087932843868028092287173227"),
"angle_c_rad" : Decimal128("1.570796326794896619231321691639752")
}

angle_a angle_b、 はangle_c 128ビットの 10 $degreesToRadians進数として保存されているため、 の出力は128 ビットの 10 進数になります。

このページを評価

項目一覧