当前位置:网站首页>Numerical remapping method (remap)
Numerical remapping method (remap)
2022-04-23 02:02:00 【Small transparent】
Although numerical remapping does not belong to the system api, But it is indispensable in our daily work .
0~1 It's actually very simple
-1,1 -> 0,1 when , Namely x * 0.5 + 0.5 = y
0,1 -> -1,1 when , Namely y * 2 - 1 = x
x and y Is reversible
In addition to certain values like the above , For example, if my scope is not fixed, what should I do ?
Don't panic. , There is also a formula to use , Or the world of mathematics is magical ~
float Remap(float x, float t1, float t2, float s1, float s2)
{
return (s2 - s1) / (t2 - t1) * (x - t1) + s1;
return (x - t1) / (t2 - t1) * (s2 - s1) + s1;
}
The above 2 This formula is equivalent , How to use it , It depends on how you organize .
among x = The input values , t1 = The minimum value of the input value , t2 = The maximum value of the input value , s1 = Minimum value of output value , s2 = The maximum value of the output value
Take up a :
set up t1=0, t2=1, s1=-1, s2=1 when ,
When x=0 when , Function output value =-1
When x=1 when , Function output value =1
When x=0.5 when , Function output value =0
What about? , Smart, you should understand how to use it
The above is generally written in the logic script , If you change to shader here , for example hlsl Words , Because of the blessing of vector register , It's written like this
void Remap(float4 In, float2 InMinMax, float2 OutMinMax, out float4 Out)
{
Out = (In - InMinMax.x) * (OutMinMax.y - OutMinMax.x) / (InMinMax.y - InMinMax.x) + OutMinMax.x;
}
image unity If you want to c# If you can write that in the , It needs a new database com.unity.mathematics Talent , It has SIMD The blessing of function , Of course, there are a lot of people who don't really adapt hlsl It's written in this way ~
版权声明
本文为[Small transparent]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220843451746.html
边栏推荐
- 《维C中国》乡村助农暖人心第三站嘉宝果农场
- Heap overflow of kernel PWN basic tutorial
- 揭秘被Arm编译器所隐藏的浮点运算
- . net unit test Part 1: common Net unit test framework?
- Today will finally write system out. Println()
- Makefile文件是什麼?
- 拨号服务器是什么,有什么用处?
- 用TensorFlow实现线性回归(包括过程中出现的问题及解决方法)
- RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimensio
- Basic knowledge of software testing, you can meet the interviewer after reading it
猜你喜欢
C语言中如何“指名道姓”的进行初始化
【动手学深度学习V2】循环神经网络-1.序列模型
RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimensio
W801 / w800 WiFi socket development (II) - UDP Bluetooth control WiFi connection
BGP服务器在什么业务场景会被用到?
2022第六季完美童模 IPA國民賽領跑元宇宙賽道
Problem solving: dpkg DEB: error: package name has characters that are't lowercase alphanums or '- +‘
ThinkPHP kernel development blind box mall source code v2 0 docking easy payment / Alibaba cloud SMS / qiniu cloud storage
Realize linear regression with tensorflow (including problems and solutions in the process)
【dpdk】10. Dpdk DNS learning notes
随机推荐
Realize linear regression with tensorflow (including problems and solutions in the process)
搭建个人主页保姆级教程(二)
mb_ substr()、mb_ Strpos() function (story)
What categories do you need to know before using proxy IP?
Virtual serial port function of j-link V9 using skills
什么是代理IP池,如何构建?
2022 Saison 6 perfect Kid Model IPA national race Leading the Meta - Universe Track
拨号vps会遇到什么问题?
Shardingsphere sub database and sub table
[Leetcode每日一题]396. 旋转函数
JDBC cannot connect to MySQL, and the error is access denied for user 'root' @ '* * *' (using password: Yes)
RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimensio
89 logistic回归用户画像用户响应度预测
42. Use k3det in mmrotate for rotating target detection, MNN deployment and ncnn deployment
一些使用代理IP的小技巧。
What is an API interface?
Introduction to micro build low code zero Foundation (lesson 2)
How to install mysql-5.7.9 in RPM mode under Linux system
Shardingsphere introduction and sub table usage
Introduction to esp32 Bluetooth controller API