Advertisement Jump to content
Sign in to follow this  

scaling to aunit cube

This topic is 4377 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
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.

[Edit: Bingo.]

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!