Rotate About Axis 노드
설명
Rotation 값만큼 Axis 축을 중심으로 In 입력 벡터를 회전시킵니다. 회전 각도의 단위는 Unit 파라미터를 사용하여 선택할 수 있습니다.
포트
이름 | 방향 | Type | 바인딩 | 설명 |
---|---|---|---|---|
In | 입력 | 벡터 3 | None | 입력 값 |
축 | 입력 | 벡터 3 | None | 회전할 축 |
Rotation | 입력 | 플로트 | None | 적용할 회전 양 |
Out | 출력 | 벡터 3 | None | 출력 값 |
컨트롤
이름 | Type | 옵션 | 설명 |
---|---|---|---|
Unit | 드롭다운 | Radians, Degrees | Rotation 입력의 단위를 전환합니다. |
생성된 코드 예제
다음 예제 코드는 Unit 모드에 대한 이 노드의 가능한 결과 중 하나입니다.
Radians
void Unity_RotateAboutAxis_Radians_float(float3 In, float3 Axis, float Rotation, out float3 Out)
{
float s = sin(Rotation);
float c = cos(Rotation);
float one_minus_c = 1.0 - c;
Axis = normalize(Axis);
float3x3 rot_mat =
{ one_minus_c * Axis.x * Axis.x + c, one_minus_c * Axis.x * Axis.y - Axis.z * s, one_minus_c * Axis.z * Axis.x + Axis.y * s,
one_minus_c * Axis.x * Axis.y + Axis.z * s, one_minus_c * Axis.y * Axis.y + c, one_minus_c * Axis.y * Axis.z - Axis.x * s,
one_minus_c * Axis.z * Axis.x - Axis.y * s, one_minus_c * Axis.y * Axis.z + Axis.x * s, one_minus_c * Axis.z * Axis.z + c
};
Out = mul(rot_mat, In);
}
Degrees
void Unity_RotateAboutAxis_Degrees_float(float3 In, float3 Axis, float Rotation, out float3 Out)
{
Rotation = radians(Rotation);
float s = sin(Rotation);
float c = cos(Rotation);
float one_minus_c = 1.0 - c;
Axis = normalize(Axis);
float3x3 rot_mat =
{ one_minus_c * Axis.x * Axis.x + c, one_minus_c * Axis.x * Axis.y - Axis.z * s, one_minus_c * Axis.z * Axis.x + Axis.y * s,
one_minus_c * Axis.x * Axis.y + Axis.z * s, one_minus_c * Axis.y * Axis.y + c, one_minus_c * Axis.y * Axis.z - Axis.x * s,
one_minus_c * Axis.z * Axis.x - Axis.y * s, one_minus_c * Axis.y * Axis.z + Axis.x * s, one_minus_c * Axis.z * Axis.z + c
};
Out = mul(rot_mat, In);
}