Jump to content
• Advertisement

Inverse scaling, how to do it?

This topic is 3489 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

Hi, I'm working on a flash map at the moment, I have a map movieclip with points of interest movieclips within it, when I scale the map up or down the POI scale down or up as expected. What I would like to do is keep them the same size, I thought that I could just scale the points the opposite amount of what I scaled the map but this doesn't provide the right result as the amount the points are scaled is different when applied to them individually as opposed to when they are scaled with the map. What I need is some maths for scaling the points inversely to the amount the map is scaled, does anyone know how to do this? I'm also trying to learn more about geometry and how it applies to flash so please be as verbose as possible. Thanks! eb_dev

Share this post

Share on other sites
Advertisement
If you want to keep them the same size, and not scaling them at all isn't an option, then scale them by (1/scaleValue) to return them to their initial size.

Share this post

Share on other sites
Hi Winegums thanks for your reply.

Yes I want to keep the points of interest the same size but the same position on the map also as the map movieclip is scaled up or down.

I'm not sure I follow what you mean, are you saying that I should do the following:

point_of_interest._width = point_of_interest._width * (1 / scaleValue) ?

What is this actually doing? You'll have to forgive me, I really struggle visualising this stuff properly.

Thanks

eb_dev

Share this post

Share on other sites
Hi Winegums thanks for your reply.

Yes I want to keep the points of interest the same size but the same position on the map also as the map movieclip is scaled up or down.

I'm not sure I follow what you mean, are you saying that I should do the following:

point_of_interest._width = point_of_interest._width * (1 / scaleValue) ?

What is this actually doing? You'll have to forgive me, I really struggle visualising this stuff properly.

Thanks

eb_dev

Share this post

Share on other sites
Scaling by 1/scaleValue returns the number to its original value.

ie x * 1/x = 1, so multiplying something by scaleValue then 1/scaleValue is analogous to multiplying your something by 1 (assuming scaleValue isn't zero).

eg

float x = 5.0f;float scaleValue = 2.0f;x = x * scaleValue;   //x now equals 10x = x * (1.0f/scaleValue) // x = x * (1.0f/2.0f)    ... (1.0f/2.0f) = 0.5f//so //x = x * 0.5  -> x = 10 * 0.5 -> x = 5 ...which is what we started with

I would imagine you could do the same thing to the positions.

Share this post

Share on other sites
Several possibilities (but notice that I'm less familiar with Flash):

(1) Attach the POIs as children to the map and scale the whole thing. Due to the attachment, the position as well as the size of the POIs will be effected. The re-positioning is wanted, but the resizing not. So un-resize the POI individually each one multiplying their width and height by 1/scale. (EDIT: This is in fact what Winegums already has mentioned. /EDIT)

(2) Scale the map without the POIs already attached. Compute the new position of each individual POI as
x' := x * scale
y' := y * scale
and attach the POI using this corrected position (here x and y are the position co-ordinates in the unscaled map, of course).

For both methods the origin of the POI markers should be located in their centers.

Share this post

Share on other sites
Ah I see that's made scaling alot clearer now, I think my zoom function is working correctly now. Very much appreciated!

Share this post

Share on other sites

• Advertisement
• Advertisement

• Popular Contributors

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 11
• 12
• 12
• 14
• 9
• Forum Statistics

• Total Topics
633351
• Total Posts
3011478
• Who's Online (See full list)

There are no registered users currently online

×

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!