当前位置:网站首页>Rotation in model space and rotation in world space
Rotation in model space and rotation in world space
2022-07-29 07:57:00 【TingQiaoQiao】
Transform the vertices of the model in the vertex shader , Then follow the teacher's train of thought , The pointer of the following model should follow x Axis rotation ,unity Middle is left-handed coordinates , So its z Axis up ,y Axis right

void Rotation(float mask, inout float3 vertex, float offset, float angle) {
vertex.y -= offset * mask; // Translate the clock with mask
float radx = radians(angle * mask);
float sinx, cosx = 0;
sincos(radx, sinx, cosx);
vertex.yz = float2(vertex.y * cosx - vertex.z * sinx, vertex.y * sinx + vertex.z * cosx);
vertex.y += offset * mask;
}
void ClockRotation(float3 color , inout float3 vertex ) {
Rotation( color.r, vertex, _MoveOffect, _HourAngle);
Rotation( color.g, vertex, _MoveOffect, _MinuteAngle);
Rotation( color.b, vertex, _MoveOffect, _SecondAngle);
}
// Input structure >>> The vertices Shader>>> Output structure
VertexOutput vert(VertexInput v) {
VertexOutput o = (VertexOutput)0;
// Perform vertex transformation on the time needle
ClockRotation(v.color.rgb, v.vertex.xyz);
}Later, I found that the effect picture is :

It can be clearly seen around z The shaft is turning , instead of x Axis

Later, it was found that it was in Transform It's adjusted inside y Rotating shaft of shaft , The vertex coordinate is the coordinate in model space , At the beginning, by default, the coordinates of model space and time space are consistent , Instead, it revolves around x The shaft rotates . However, the coordinates of the model in world space are discussed later y Axis 90 Degree rotation , So that the coordinates in the model space also follow y Axis progress 90 Degrees of rotation , This leads to the effect that the pointer surrounds z Axis rotation .
In this case, it is best not to transform the model in space , First deal with the vertex in the existing situation, and then convert its world space .

void Rotation( float mask, inout float3 vertex, float offset, float angle ) {
vertex.y -= offset * mask; // Translate the clock with mask
float radz = radians(angle * mask);
float sinz, cosz = 0;
sincos(radz, sinz, cosz);
// At present, the vertex is still the vertex data in object space , There is no vertex data converted to world space , So the coordinate system used is still the object coordinate system , The coordinate system of the component is the coordinate system in world space , At the beginning, by default, the coordinate system in object space is the same as that in world space , But it will be different if we change again
// Here we should pay attention to , You need to initialize all the rotation parameters of the model to 0, Then use the current code to adjust the parameters , Finally, change the overall rotation of the model
vertex.xy = float2(vertex.x * cosz - vertex.y * sinz, vertex.x * sinz + vertex.y * cosz); // The order of rotation parameter adjustment is : The code rotates using the original default coordinate system , Then rotate the model according to the components , Because when the component rotates, the spatial coordinate axis of the object itself will also be rotated accordingly
vertex.y += offset * mask;
}边栏推荐
- [lecture notes] how to do in-depth learning in poor data?
- [paper reading | cryoelectron microscope] interpretation of the new subtomogram averaging method in relion 4.0
- [freeze electron microscope] analysis of the source code of the subtomogram alignment function of relion4.0 (for self use)
- 智慧城市的应用挑战,昇腾AI给出了新解法
- 关于pip升级损坏导致的问题记录
- Jiamusi Market Supervision Bureau carried out special food safety network training on epidemic and insect prevention
- String class
- String类
- Sqlmap (SQL injection automation tool)
- Dynamic Thresholds Buffer Management in a Shared Buffer Packet Switch论文总结
猜你喜欢
![[paper reading | cryoet] gum net: fast and accurate 3D subtomo image alignment and average unsupervised geometric matching](/img/dc/255bf122d5243f2a08ca0e03b53137.png)
[paper reading | cryoet] gum net: fast and accurate 3D subtomo image alignment and average unsupervised geometric matching

My entrepreneurial neighbors

cs61abc分享会(六)程序的输入输出详解 - 标准输入输出,文件,设备,EOF,命令行参数
![[paper reading] tomoalign: a novel approach to correcting sample motion and 3D CTF in cryoet](/img/3a/75c211f21758ca2d9bb1a40d739d80.png)
[paper reading] tomoalign: a novel approach to correcting sample motion and 3D CTF in cryoet

The software package is set to - > Yum source

JVM garbage collection mechanism (GC)

The smallest positive number that a subset of an array cannot accumulate

Mutationobserver document learning
![[introduction to cryoelectron microscopy] Caltech open class course notes part 3:image formation](/img/7b/cbd9e3b6d72155613e53ffdd06c5cd.png)
[introduction to cryoelectron microscopy] Caltech open class course notes part 3:image formation
![[cryptography experiment] 0x00 install NTL Library](/img/2a/03d95082a2a63238b475b3f7f3e13d.png)
[cryptography experiment] 0x00 install NTL Library
随机推荐
Detailed explanation of two modes of FTP
How to get to the deep-water area when the industrial Internet goes?
Popular cow G
Monitor the bottom button of page scrolling position positioning (including the solution that page initialization positioning does not take effect on mouse sliding)
Matlab simulation of LDPC minimum sum decoding based on high-order six ring free
What is the use of chat robots? What type? After reading these, you will understand!
Sort out the two NFT pricing paradigms and four solutions on the market
Embroidery of little D
Up sampling deconvolution operation
Shell script - global variables, local variables, environment variables
Analyze the roadmap of 25 major DFI protocols and predict the seven major trends in the future of DFI
Compare three clock circuit schemes of single chip microcomputer
MapReduce各阶段步骤
[lecture notes] how to do in-depth learning in poor data?
An optimal buffer management scheme with dynamic thresholds paper summary
《nlp入门+实战:第五章:使用pytorch中的API实现线性回归》
RoBERTa:A Robustly Optimized BERT Pretraining Approach
[paper reading | cryoelectron microscope] interpretation of the new subtomogram averaging method in relion 4.0
在一个sql文件中,上面定义一个测试表及数据,下面可以select* from 测试表
What are the common error types and solutions of black box testing?