1 |
not going to lie it took me a hot minute to realize you do need a midpoint to invert height. would sea level be a good mid point? im not sure how i can assist in this project but if you can point me in the right direction i will help however i can.
|
1 |
not going to lie it took me a hot minute to realize you do need a midpoint to invert height. would sea level be a good mid point? im not sure how i can assist in this project but if you can point me in the right direction i will help however i can.
|
2 |
\n
|
2 |
\n
|
3 |
chat gpt said you could use this other option:
|
3 |
chat gpt said you could use this other option:
|
4 |
\n
|
4 |
\n
|
5 |
[spoiler]
|
5 |
[spoiler]
|
6 |
\n
|
6 |
\n
|
7 |
{{{
|
7 |
{{{
|
8 |
\n
|
8 |
\n
|
9 |
give me algerbraic logic for inverting a height map simmilar to this:
|
9 |
give me algerbraic logic for inverting a height map simmilar to this:
|
10 |
\n
|
10 |
\n
|
11 |
upper bounds: 99
|
11 |
upper bounds: 99
|
12 |
lower bounds:-44
|
12 |
lower bounds:-44
|
13 |
ChatGPT said:
|
13 |
ChatGPT said:
|
14 |
ChatGPT
|
14 |
ChatGPT
|
15 |
\n
|
15 |
\n
|
16 |
To invert a height map with specified upper and lower bounds algebraically, you can express the relationship between the original value and its mapped output. Let's say you want to map a height value hh from the range defined by:
|
16 |
To invert a height map with specified upper and lower bounds algebraically, you can express the relationship between the original value and its mapped output. Let's say you want to map a height value hh from the range defined by:
|
17 |
\n
|
17 |
\n
|
18 |
Upper bound U=99U=99
|
18 |
Upper bound U=99U=99
|
19 |
Lower bound L=−44L=−44
|
19 |
Lower bound L=−44L=−44
|
20 |
\n
|
20 |
\n
|
21 |
Step 1: Normalizing the Height Value
|
21 |
Step 1: Normalizing the Height Value
|
22 |
\n
|
22 |
\n
|
23 |
First, you need to normalize the height value to a range between 0 and 1:
|
23 |
First, you need to normalize the height value to a range between 0 and 1:
|
24 |
n=h−LU−L
|
24 |
n=h−LU−L
|
25 |
n=U−Lh−L
|
25 |
n=U−Lh−L
|
26 |
\n
|
26 |
\n
|
27 |
Where nn is the normalized value.
|
27 |
Where nn is the normalized value.
|
28 |
Step 2: Inverting the Normalized Value
|
28 |
Step 2: Inverting the Normalized Value
|
29 |
\n
|
29 |
\n
|
30 |
To invert the mapping, you need to derive hh from nn. If you have a normalized value n′n′ that you want to invert back to height h′h′:
|
30 |
To invert the mapping, you need to derive hh from nn. If you have a normalized value n′n′ that you want to invert back to height h′h′:
|
31 |
h′=n′⋅(U−L)+L
|
31 |
h′=n′⋅(U−L)+L
|
32 |
h′=n′⋅(U−L)+L
|
32 |
h′=n′⋅(U−L)+L
|
33 |
Example
|
33 |
Example
|
34 |
\n
|
34 |
\n
|
35 |
If you have a normalized value n′=0.5n′=0.5, you can find the original height:
|
35 |
If you have a normalized value n′=0.5n′=0.5, you can find the original height:
|
36 |
h′=0.5⋅(99−(−44))+(−44)
|
36 |
h′=0.5⋅(99−(−44))+(−44)
|
37 |
h′=0.5⋅(99−(−44))+(−44)
|
37 |
h′=0.5⋅(99−(−44))+(−44)
|
38 |
\n
|
38 |
\n
|
39 |
Calculating it:
|
39 |
Calculating it:
|
40 |
h′=0.5⋅(143)−44=71.5−44=27.5
|
40 |
h′=0.5⋅(143)−44=71.5−44=27.5
|
41 |
h′=0.5⋅(143)−44=71.5−44=27.5
|
41 |
h′=0.5⋅(143)−44=71.5−44=27.5
|
42 |
Summary
|
42 |
Summary
|
43 |
\n
|
43 |
\n
|
44 |
Normalize: n=h−LU−Ln=U−Lh−L
|
44 |
Normalize: n=h−LU−Ln=U−Lh−L
|
45 |
Invert: h′=n′⋅(U−L)+Lh′=n′⋅(U−L)+L
|
45 |
Invert: h′=n′⋅(U−L)+Lh′=n′⋅(U−L)+L
|
46 |
\n
|
46 |
\n
|
47 |
This approach will let you invert any height value within the bounds you've specified. If you have specific values or cases you'd like to explore, feel free to share!
|
47 |
This approach will let you invert any height value within the bounds you've specified. If you have specific values or cases you'd like to explore, feel free to share!
|
48 |
\n
|
48 |
\n
|
49 |
}}}
|
49 |
}}}
|
50 |
\n
|
50 |
\n
|
51 |
[/spoiler]
|
51 |
[/spoiler]
|
52 |
\n
|
52 |
\n
|
53 |
edit:
|
53 |
edit:
|
54 |
sea level is sometimes way bellow groundlevel. so maybe an average height might be a good midpoint but that might not be possible.
|
54 |
sea level is sometimes way bellow groundlevel. so maybe an average height might be a good midpoint but that might not be possible.
|
55 |
\n
|
55 |
\n
|
56 |
some old code i made that inverts speed:
|
56 |
some old code i made that inverts speed:
|
57 |
[spoiler]
|
57 |
[spoiler]
|
58 |
\n
|
58 |
\n
|
59 |
{{{
|
59 |
{{{
|
60 |
\n
|
60 |
\n
|
61 |
if ud.speed then
|
61 |
if ud.speed then
|
62 |
if ud.speed > highestspeed then
|
62 |
if ud.speed > highestspeed then
|
63 |
highestspeed = ud.speed
|
63 |
highestspeed = ud.speed
|
64 |
end
|
64 |
end
|
65 |
if ud.speed < lowestspeed then
|
65 |
if ud.speed < lowestspeed then
|
66 |
lowestspeed = ud.speed
|
66 |
lowestspeed = ud.speed
|
67 |
end
|
67 |
end
|
68 |
end
|
68 |
end
|
69 |
\n
|
69 |
\n
|
70 |
if ud.speed then
|
70 |
if ud.speed then
|
71 |
local distance_speed_midpoint = ud.speed - lowestspeed
|
71 |
local distance_speed_midpoint = ud.speed - lowestspeed
|
72 |
ud.speed = highestspeed - distance_speed_midpoint
|
72 |
ud.speed = highestspeed - distance_speed_midpoint
|
73 |
end
|
73 |
end
|
74 |
\n
|
74 |
\n
|
75 |
}}}
|
75 |
}}}
|
76 |
\n
|
76 |
\n
|
77 |
[/spoiler]
|
77 |
[/spoiler]
|
78 |
\n
|
78 |
\n
|
79 |
ofc you wont need any of this because your a code wizzard and far above my level =D
|
79 |
ofc you wont need any of this because your a code wizzard and far above my level =D
|
|
|
80 |
i would write it myself but im not sure how to even begin.
|