Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8960649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:42:23+00:00 2026-06-15T15:42:23+00:00

map(-30, -89.75, 89.75, 0, 360) I’m looking for something like this where: -30 is

  • 0
map(-30, -89.75, 89.75, 0, 360) 

I’m looking for something like this where:

  • -30 is the input value.
  • -89.75 to 89.75 is the range of possible input values
  • 0 – 360 is the final range to be mapped to

I was told there is a way to do this using http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-map

.. however its not readily apparent !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:42:24+00:00Added an answer on June 15, 2026 at 3:42 pm

    If I’m understanding correctly, I think you just want to uniformly map one range onto another. So, we just need to calculate how far through the input range it is, and return that fraction of the output range.

    def map_range(input, in_low, in_high, out_low, out_high)
      # map onto [0,1] using input range
      frac = (input - in_low) / (in_high-in_low)
      # map onto output range
      frac * (out_high-out_low) + out_low
    end
    

    Also, I should note that map has a bit of a different meaning in ruby, and a more appropriate description would probably be transform.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does map() iterate through the list like for would? Is there a value in
A Map maps from keys to values and provides quick access based on the
I am trying to map a texture to a circle using GL_POLYGON using this
Map session = ActionContext.getContext().getSession(); session.put(user, user); This code generates a warning: Type safety: The
I am trying to superimpose an image to a world map. This is may
this code given bellow will read a binary file and simply visualize the map
Map<K,V<List<K>> graph = new HashMap<K,V<List<K>>(); Are there any major obstacles to using this to
I have plotted a contour map but i need to make some improvements. This
Map<Integer, Map<String, String>> movie = new HashMap<Integer,Map<String, String>>(); Map<String,String> sub = new HashMap<String,String>(); I'm
Map<String, List<String>> words = new HashMap<String, List<String>>(); List<Map> listOfHash = new ArrayList<Map>(); for (int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.