need to scale a shape without losing information

Posted on 2006-11-06
Medium Priority
Last Modified: 2010-04-16
I have a list of points which define a shape
I need to shrink the shape
I know which direction to move the points
because if the angle is concave or convex
but sometimes if the points are too close to each other
they overlap and produce the wrong results

does anyone know of a good scaling algorithm that can avoid or compensate for this problem?
Question by:DangerMode
  • 5
  • 3
  • 2
  • +1
LVL 85

Expert Comment

ID: 17886556
multiplying the coordinates of all the points by a constant will scale the shape

Author Comment

ID: 17886807
It must be done on a point by point basis
A uniform scale doesnt preserve the original shape but it does keep it proportional.
Therefore when computing the new point based on a cross vector at certain angles if the scale is to big
the points overlap themselves.

LVL 85

Expert Comment

ID: 17886826
Multiplying on a point by point basis is what I said.
A uniform scale preserves the original shape and keeps it proportional,
(which I thought were the same thing, unless you are using "shape" or "proportional" in a way I don't understand)
Points have 0 size, so the only way they can overlap is if they are the same point.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Expert Comment

ID: 17887747
How do you interpolate the points? with splines? Maybe you should make an image of the image in normal mode, and then
scale it down (undersample, take for subsampling 2 times, every second pixel).

Expert Comment

ID: 17892281
I agree with ozo from what youv said...

Another way to do it would be to calculate or store the centre point of the shape and use this to determine the distance of each point in the shape boundary for which you have a reading from that point.  This way you could scale the shape by directly calculating the new size in proportion to its original position along the vector between it and the centre point.

It really depends on your original design and the complexity of the shapes you are drawing...

I created a shape drawing program, which deals with simple geometric forms such as squares, circles, triangles, diamonds and stars...  I treated each as a circle...

A square is a circle with only 4 points on its circumference recorded, a triangle has 3 points recorded... etc

The method I outlined for resizing worked well in this approach, proportionality was always maintained...  Rotating the shape was also simple...  
To draw the shape you just need the centre point, the radius or the circle and the angle of rotation, the draw method is identical regardless of the shape type, using these parameters, using oom

More complex shapes may require a different approach

Expert Comment

ID: 17892300
To draw the shape you just need the centre point, the radius or the circle and the angle of rotation, the draw method is identical regardless of the shape type, using these parameters, using oom

And the number of points on the circumference....   Sorry...

Author Comment

ID: 17892907
I apologize for not being able to articulate what I need, it is hard to say in words so I have created a couple pictures to show you.
Basically, I dont want uniform proportional scaling as that doesnt maintain a uniform distance away from the line. (contraction or erosion scaling) not sure the proper term for this either?
LVL 85

Accepted Solution

ozo earned 2000 total points
ID: 17893713
given points (x0,y0) (x1,y1) (x2,y2) in clockwise order, and constant distance d
A01 = y1-y0;
B01 = x0-x1;
A12 = y2-y1;
B12 = x1-x2;
C01 = A01*x0+B01*y0+d*sqrt(A01*A01+B01*B01);
C12 = A12*x1+B12*y1+d*sqrt(A12*A12+B12*B12);
newX1= (B12*C01-B01*C12)/Det;
newY1= (A01*C12-A12*C01)/Det;

Author Comment

ID: 17894676
You are awesome finally someone who understands!
that is what I am doing

1) do you know the name of this algorithm, what would you call this?

So the problem arises when the distance is bigger then the point density and then points overlap
like in this case
(sorry the point numbers are upside down, but they show where the algorithm breaks down)

2) I thought of several approaches to fix it like removing those points and making a point at intersection etc
and all have other problems with them,
If you have any leads or ideas on how to fix this I would really really appreciated it.
LVL 85

Expert Comment

ID: 17894835
It looks like you want to take the boundary defined by the black line (adding points were lines intersect) and eliminate all points contained inside that boundary. (using a non-zero or poitive winding number definition of inside)
LVL 85

Expert Comment

ID: 17894866
Here's how postscript defines different kinds of line joins

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question