当前位置:网站首页>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;
}边栏推荐
- Write some DP
- [cryoEM] Introduction to FSC, Fourier shell correlation
- Solve the problem that the disk is full due to large files
- [freeze electron microscope] analysis of the source code of the subtomogram alignment function of relion4.0 (for self use)
- cs61abc分享会(六)程序的输入输出详解 - 标准输入输出,文件,设备,EOF,命令行参数
- [paper reading] tomoalign: a novel approach to correcting sample motion and 3D CTF in cryoet
- Do you want to meet all the needs of customers
- postman接口测试|js脚本之阻塞休眠和非阻塞休眠
- Processes and threads
- 准备esp32环境
猜你喜欢

NLP introduction + practice: Chapter 5: using the API in pytorch to realize linear regression

Why don't you like it? It's easy to send email in cicd

207.课程表
![[cryoelectron microscope | paper reading] emclarity: software for high-resolution cryoelectron tomography and sub fault averaging](/img/1e/9f05862288261e16a6b04508b9b292.png)
[cryoelectron microscope | paper reading] emclarity: software for high-resolution cryoelectron tomography and sub fault averaging

《nlp入门+实战:第五章:使用pytorch中的API实现线性回归》

Go, how to become a gopher, and find work related to go language in 7 days, Part 1

An optimal buffer management scheme with dynamic thresholds paper summary
![[paper reading | cryoelectron microscope] interpretation of the new subtomogram averaging method in relion 4.0](/img/8d/03e63d651b713f547b090e6e740b06.png)
[paper reading | cryoelectron microscope] interpretation of the new subtomogram averaging method in relion 4.0

Up sampling deconvolution operation
![[WPF] realize language switching through dynamic / static resources](/img/23/1e089ce4a07128323824b25897a8c4.png)
[WPF] realize language switching through dynamic / static resources
随机推荐
[memo] summary of the reasons why SSH failed? Remember to come next time.
[密码学实验] 0x00 安装NTL库
CDM - code division multiplexing (easy to understand)
The database uses PSQL and JDBC to connect remotely and disconnect automatically from time to time
[paper reading] tomoalign: a novel approach to correcting sample motion and 3D CTF in cryoet
Day 014 2D array exercise
Solve the problem that the disk is full due to large files
Credit card shopping points
Mqtt server setup and mqtt.fx testing
佳木斯市场监管局开展防疫防虫害专题食品安全网络培训
MySQL uses date_ FORMAT(date,'%Y-%m')
[flask introduction series] installation and configuration of flask Sqlalchemy
[paper reading | cryoet] gum net: fast and accurate 3D subtomo image alignment and average unsupervised geometric matching
Vmstat memory consumption query
Zero technology is deeply involved in the development of privacy computing financial scenario standards of the ICT Institute
[cryoelectron microscope | paper reading] emclarity: software for high-resolution cryoelectron tomography and sub fault averaging
在一个sql文件中,上面定义一个测试表及数据,下面可以select* from 测试表
Effective learning of medical image segmentation annotation based on noise pseudo tags and adversarial learning
Jump from mapper interface to mapping file XML in idea
[cryoelectron microscope] relion4.0 pipeline command summary (self use)