Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a polyline with a large number of points and would like to move + stretch it without having to do a for cycle on each point. Is there a geometry translate transform which allows me to do it in a faster way?

At the moment, have selected a curve I recalculate ALL POINTS through:

//1. Move + Stretch
if (newWidth != 0 && newHeight != 0)
{
    Xfactor = (double)newWidth / oldWidth;
    Yfactor = (double)newHeight / oldHeight;
    messages.Add("Moving and Stretching");
}
else
//2. Move only
{
    Xfactor = Yfactor = 1;
    messages.Add("Moving only");
}

PolyLineSegment plDepo = new PolyLineSegment();
PolyLineSegment plSelectedLocal = new PolyLineSegment();
plSelectedLocal = GetPolyLineSegmentFromSelectedPath();

for (int iii = 0; iii < plSelectedLocal.Points.Count(); iii++)
{
    //Per each point I calculate the distance X and Y from the center,
    //I normalize and AFTER I move
    Point prevPoint = new Point(plSelectedLocal.Points[iii].X, plSelectedLocal.Points[iii].Y);
    Point newPoint = new Point((prevPoint.X - piSelected.Center.X) * Xfactor + newCenter.X, (prevPoint.Y - piSelected.Center.Y) * Yfactor + newCenter.Y);
    plDepo.Points.Add(newPoint);
}

SelectedPath.Data = GetGeometryFromPolyLineSegment(plDepo);



so as you can see this implies a lot of calculation iterating on each point. What I would like it would be to work on the Geometry of the curve. That is only one transformation in terms of stretch and move so that i can be achieved more quickly.

Additionally I have to say that all transformation have to be made in code behind and that, since I have several shapes I can't use a viewPort for each of them.

thanks Patrick
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900