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.

Post History

55%
+3 −2
Q&A How to proportionally convert a number in the range of -1 and 1 to a number in the range of 0 and 319

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 re...

3 answers  ·  posted 2y ago by cuzzo‭  ·  last activity 2y ago by Dirk Herrmann‭

Question java 3d math
#6: Post edited by user avatar cuzzo‭ · 2022-12-13T19:36:40Z (about 2 years ago)
  • I have float noise values, between -1 and 1, for every x,y coordinate in a 3D 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?
  • 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?
#5: Post edited by user avatar cuzzo‭ · 2022-12-13T19:32:32Z (about 2 years ago)
  • How to proportionally convert a number in the range of -1 and 1 to a number between 0 and 319
  • How to proportionally convert a number in the range of -1 and 1 to a number in the range of 0 and 319
#4: Post edited by user avatar cuzzo‭ · 2022-12-13T18:46:05Z (about 2 years ago)
  • I have float noise values, between -1 and 1, for every x,y coordinate in a 3D 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 implement this efficiently?
  • I have float noise values, between -1 and 1, for every x,y coordinate in a 3D 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?
#3: Post edited by user avatar cuzzo‭ · 2022-12-13T18:45:31Z (about 2 years ago)
  • How to proportionally convert a number in the range of -1 and 1 to a number between 0 and 255
  • How to proportionally convert a number in the range of -1 and 1 to a number between 0 and 319
#2: Post edited by user avatar cuzzo‭ · 2022-12-13T18:45:18Z (about 2 years ago)
  • I have float noise values, between -1 and 1, for every x,y coordinate in a 3D area and I am trying to convert that to a whole number between 0 and 255 which represents a vertical z coordinate to render.
  • For example,
  • ```
  • -1 = 0 and
  • 1 = 255 but
  • 0.12345 = ???
  • ```
  • How would I implement this efficiently?
  • I have float noise values, between -1 and 1, for every x,y coordinate in a 3D 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 implement this efficiently?
#1: Initial revision by user avatar cuzzo‭ · 2022-12-13T18:44:31Z (about 2 years ago)
How to proportionally convert a number in the range of -1 and 1 to a number between 0 and 255
I have float noise values, between -1 and 1, for every x,y coordinate in a 3D area and I am trying to convert that to a whole number between 0 and 255 which represents a vertical z coordinate to render.

For example,  
``` 
-1 = 0 and   
1 = 255 but    
0.12345 = ???
```

How would I implement this efficiently?