当前位置:网站首页>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
边栏推荐
- W801 / w800 WiFi socket development (II) - UDP Bluetooth control WiFi connection
- Performance introduction of the first new version of cdr2022
- Sqlserver data transfer to MySQL
- 2022.4.22-----leetcode. three hundred and ninety-six
- 今天终于会写System.out.println()了
- 用TensorFlow实现线性回归(包括过程中出现的问题及解决方法)
- How to classify proxy IP?
- When should I write unit tests? What is TDD?
- ESP32蓝牙Bluetooth Controller API介绍
- 浅析静态代理ip的三大作用。
猜你喜欢

Digital collection platform settled in digital collection platform to develop SaaS platform of digital collection

Nanny level tutorial on building personal home page (II)

Analyze the advantages and disadvantages of tunnel proxy IP.

Basic knowledge of software testing, you can meet the interviewer after reading it

Heap overflow of kernel PWN basic tutorial

浅析一下隧道代理IP的优缺点。

在使用代理IP前需要了解哪些分类?

Leetcode 112 Total path (2022.04.22)

When should I write unit tests? What is TDD?

用TensorFlow实现线性回归(包括过程中出现的问题及解决方法)
随机推荐
Nanny level tutorial on building personal home page (II)
W801 / w800 / w806 unique ID / CPUID / flashid
When should I write unit tests? What is TDD?
About how to import C4d animation into lumion
Esp32 message queue using FreeRTOS
Halo open source project learning (I): project launch
EBS:PO_ EMPLOYEE_ HIERARCHIES_ ALL
Dimension C China helping farmers in rural areas warms people's hearts the third stop is jiabaoguo farm
Heap overflow of kernel PWN basic tutorial
什么是api接口?
What is an API interface?
A simple and open source navigation website source code
教程】如何用GCC“零汇编”白嫖MDK
RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimensio
Realize linear regression with tensorflow (including problems and solutions in the process)
配置iptables实现本地端口转发的方法详解
What is a boolean type?
一些使用代理IP的小技巧。
keil mdk中文乱码,两种解决方法,字体不再难看
Longest common subsequence (record path version)