AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

$sin (표현식 연산자)

$sin

라디안 단위로 측정된 값의 사인을 반환합니다.

$sin 의 구문은 다음과 같습니다:

{ $sin: <expression> }

$sin takes any valid expression that resolves to a number. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the result to radians.

$sin 기본값 double $sin 128으로 <expression> 는 값을 로 반환합니다. 는 128가 비트 십진수 값으로 해석되는 한 값을 비트 십진수로 반환할 수도 있습니다.

표현식에 대한 자세한 내용은 표현식을 참조하세요 .

If the argument resolves to a value of null or refers to a field that is missing, $sin returns null. If the argument resolves to NaN, $sin returns NaN. If the argument resolves to negative or positive infinity, $sin throws an error.

예시
결과

{ $sin: NaN }

NaN

{ $sin: null }

null

{ $sin : Infinity}

or

{ $sin : -Infinity }

다음과 같은 형식의 출력과 유사한 오류 메시지를 표시합니다.

"errmsg" :
"Failed to optimize pipeline :: caused by :: cannot
apply $sin to -inf, value must in (-inf,inf)"

trigonometry 컬렉션에는 빗변과 직각 삼각형의 각 하나를 저장하는 문서가 포함되어 있습니다.

{
"_id" : ObjectId("5c50782193f833234ba90d85"),
"angle_a" : Decimal128("53.13010235415597870314438744090659"),
"hypotenuse" : Decimal128("5")
}

The following aggregation operation uses the $sin expression to calculate the side opposite to angle_a and add it to the input document using the $addFields pipeline stage.

db.trigonometry.aggregate([
{
$addFields : {
"side_b" : {
$multiply : [
{ $sin : {$degreesToRadians : "$angle_a"} },
"$hypotenuse"
]
}
}
}
])

$degreesToRadians 표현식은 angle_a의 각도 값을 라디안 단위의 해당 값으로 변환합니다.

이 명령은 다음 출력을 반환합니다.

{
"_id" : ObjectId("5c50782193f833234ba90d85"),
"angle_a" : Decimal128("53.13010235415597870314438744090659"),
"side_b" : Decimal128("4.000000000000000000000000000000000"),
"hypotenuse" : Decimal128("5"),
}

angle_a 및 는 hypotenuse 128비트 십진수로 저장되므로 $sin 의 출력은 128비트 십진수입니다.

trigonometry 컬렉션에는 빗변과 직각 삼각형의 각 하나를 저장하는 문서가 포함되어 있습니다.

{
"_id" : ObjectId("5c50782193f833234ba90d85"),
"angle_a" : Decimal128("0.9272952180016122324285124629224288"),
"hypotenuse" : Decimal128("5")
}

The following aggregation operation uses the $sin expression to calculate the side opposite to angle_a and add it to the input document using the $addFields pipeline stage.

db.trigonometry.aggregate([
{
$addFields : {
"side_b" : {
$multiply : [
{ $sin : "$angle_a" },
"$hypotenuse"
]
}
}
}
])

이 명령은 다음 출력을 반환합니다.

{
"_id" : ObjectId("5c50782193f833234ba90d85"),
"angle_a" : Decimal128("0.9272952180016122324285124629224288"),
"side_b" : Decimal128("4.000000000000000000000000000000000"),
"hypotenuse" : Decimal128("5"),
}

Since angle_a and hypotenuse are stored as 128-bit decimals, the output of $sin is a 128-bit decimal.

이 페이지 평가하기

이 페이지의 내용