# HP Forums

Full Version: How to autoscale a shape?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I just completed a program that outputs some points that i'd like to draw on a GROB (or whatever name we'd like to call them in the PRIME :+)).

Let's say that i do not have the control of the range of these numbers before the output.

How can i autoscale these numbers in order to represent them on a plane?
I found a scale factor for the X range and then a scale factor for the Y range but I loose the height/width ratio of the drawing.

Which is the right procedure to find a scale factor for both X and Y axis maintaining the correct ratio between the two axis?

Thanks

Giancarlo
(12-30-2014 01:48 PM)Giancarlo Wrote: [ -> ]Hello,
I just completed a program that outputs some points that i'd like to draw on a GROB (or whatever name we'd like to call them in the PRIME :+)).

Let's say that i do not have the control of the range of these numbers before the output.

How can i autoscale these numbers in order to represent them on a plane?
I found a scale factor for the X range and then a scale factor for the Y range but I loose the height/width ratio of the drawing.

Which is the right procedure to find a scale factor for both X and Y axis maintaining the correct ratio between the two axis?

Thanks

Giancarlo

The HP Prime's screen is 320:240 = 4:3. Suppose your X values are in $$[a,b]$$ and your Y values are in $$[c,d]$$. You can either keep the X-range at $$[a,b]$$ and then scale the Y-range to
$\left[ \frac{c+d}{2}- \frac{1}{2}\left( \frac{3}{4}(b-a)\right), \frac{c+d}{2}+ \frac{1}{2}\left( \frac{3}{4}(b-a)\right) \right].$
Or you can keep the Y-range at $$[c,d]$$ and scale the X-range
$\left[ \frac{a+b}{2}- \frac{1}{2}\left( \frac{4}{3}(d-c)\right), \frac{a+b}{2}+ \frac{1}{2}\left( \frac{4}{3}(d-c)\right) \right].$
I purposely left the math unsimplified so you can check the derivation yourself. The decision as to which axis to scale can be made by determining whether $$\frac{3}{4}(b-a) > (d-c)$$. That way, you will maintain the 4:3 ratio and ensure that all points are displayed.
Hello Han,
Thank you very much for your answer. This is exactly what i was looking for.

Since i am calculating the mechanical properties for plane section shapes and i have to input all the coordinates, i would like to add the drawing of the shape along with the results of the calculations of the centroid of the shape, surface, moments of inertia and so on.

Thanks

Giancarlo
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :