Jump to content
  • Advertisement
Sign in to follow this  
jazztuffy

scaling to aunit cube

This topic is 4278 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am rendering an image from a ply file. The vertices are inbetween[-1, 1]. I want to transform the entire set to fit inside a unit cube [0, 1]. Can any of you give me an idea on this.... Thanks

Share this post


Link to post
Share on other sites
Advertisement
There was a thread about mapping a range of numbers to another range of numbers recently, but until I can dig up a link...

There are two steps. The first is a scale, to make the first set of numbers fit in the same amount of numbers that there are in the second set. Then comes an offset, to move the beginning to the beginning, and the end to the end.

Part one: The vertices are in between [-1, 1]. This is a range of (1 - (-1)) = 2. The required range is (1 - 0) = 1. The ratio, then is 1 / 2 = 0.5. So, multiply the original vertices by 0.5. Step one: complete!

Part two: The vertices are now between [-0.5, 0.5]. The required range is [0, 1]. The difference between these two is 0.5. So, add 0.5 to the newly transformed vertices.

Part three: Say "Presto!" and have a drink.
-jouley

[Edit: Bingo.]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!