星鸿阁

 找回密码
 立即注册
搜索
热搜: 活动 交友 动画
查看: 948|回复: 1

Rotate About Axis Node

[复制链接]

2249

主题

2759

帖子

9603

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9603
发表于 2022-1-7 13:01:29 | 显示全部楼层 |阅读模式
Rotate About Axis NodeDescription
Rotates the input vector In around the axis Axis by the value of Rotation. The unit for rotation angle can be selected by the parameter Unit.
Ports[td]
Name
Direction
Type
Binding
Description
InInputVector 3NoneInput value
AxisInputVector 3NoneAxis to rotate around
RotationInputVector 1NoneAmount of rotation to apply
OutOutputVector 3NoneOutput value
Controls[td]
Name
Type
Options
Description
UnitDropdownRadians, DegreesSwitches the unit for input Rotation
Generated Code Example
The following example code represents one possible outcome of this node per Unit mode.
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);}

原文链接


回复

使用道具 举报

2249

主题

2759

帖子

9603

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9603
 楼主| 发表于 2022-1-7 13:02:50 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|starfluidga

GMT+8, 2024-12-21 00:45 , Processed in 0.015122 second(s), 20 queries .

Made by Liga 星鸿阁

Copyright © 2020-2048, LigaStudio.

快速回复 返回顶部 返回列表