$radiansToDegrees (Radians to Degrees)
Last updated: 2026-10-09
$radiansToDegrees (Radians to Degrees)
$radiansToDegrees converts radians to degrees by multiplying by 180/π. The inverse trigonometric operators $asin, $acos, $atan, and $atan2 all return radians, so converting to degrees makes the output more business-friendly. It is used for angle display and directional output. A null or missing argument yields null, and NaN input returns NaN. It is the inverse of $degreesToRadians; 180 degrees equals π radians.
| Category | Math |
|---|---|
| MongoDB Version | 1.0+ |
| Example Language | mongosh (Shell) |
📝 Syntax
{ $radiansToDegrees: <numeric-expression> }
⚙️ Parameters
| radians | A numeric expression in radians. |
|---|
Returns:The degrees equivalent of the input; null when null or missing
▶ Example
Run the commands below in your local mongosh (requires a running mongod):
// $radiansToDegrees: convert radians to degrees
db.trig.aggregate([
{ $project: {
deg: { $radiansToDegrees: '$rad' }
} }
])
Output:
{ '_id': 1, 'deg': 180 }
{ '_id': 2, 'deg': 90 }
📌 Notes
- Equivalent to multiplying by 180/π
- Use it to turn $asin, $acos, $atan, and $atan2 results into degrees
- Inverse of $degreesToRadians
🏷️ Related Tags
💡 Related Cases
More hands-on cases coming soon.
📚 Related Tutorials
❓ FAQ
QWhat is the formula for $radiansToDegrees?
AMultiply the input by 180 and divide by π; π radians equals 180 degrees.
QHow do I convert inverse-trig results to degrees?
AWrap the result, e.g. $radiansToDegrees: { $atan: 1 } gives 45.
QWhat is $radiansToDegrees(π)?
AIt is 180 degrees.