Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on How to proportionally convert a number in the range of -1 and 1 to a number in the range of 0 and 319

Post

How to proportionally convert a number in the range of -1 and 1 to a number in the range of 0 and 319

+3
−2

I have float noise values, between -1 and 1, for every x,y coordinate in a 2D area and I am trying to convert that to a whole number between 0 and 319 which represents a vertical z coordinate to render.

For example,

-1 = 0 and   
1 = 319 but    
0.12345 = ???

How would I go about implementing this efficiently?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

How many such conversions are required (3 comments)
Not sure if I understood entirely your question, but it seems to boil down to a simple set of equatio... (1 comment)
How many such conversions are required
Alexei‭ wrote almost 2 years ago

How many such points do you have? I guess the answer depends a lot if we are talking about thousands vs. millions.

cuzzo‭ wrote almost 2 years ago

anywhere from 768 to a few/several thousand. It can range based on a render distance value e.g how many chunks to render at one time. chunks being 16x16x320 and having 256 unique 2D x,y values (16x16).

Alexei‭ wrote almost 2 years ago

A few/several thousand should be computed fast enough by "normal" (not involving more specialized hardware) math (i.e. using the CPU), that is solving those two equations mentioned in the other thread: computing a and b from your linear function f(x) = a*x + b.