Ask Your Question
1

Multiply a vector<Point2f>

asked 2012-12-27 16:25:40 -0600

gary gravatar image

updated 2012-12-27 16:26:20 -0600

All of my points in my vector<point2f> are halved, so I'd like to double them. Is there a better way to do this other than looping through all the points and multiplying each x, y value by 2?

Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-12-28 02:20:25 -0600

Michael Burdinov gravatar image

You don't have to multiply x, y values by 2. Instead you can multiply each point by 2. So your code will be:

for(i=0; i<points.size(); i++)
    points[i] *= 2;

I don't think you can write the multiplication shorter and clearer than that.

edit flag offensive delete link more

Comments

thank you!

gary gravatar imagegary ( 2012-12-28 11:34:24 -0600 )edit

Question Tools

Stats

Asked: 2012-12-27 16:25:40 -0600

Seen: 2,105 times

Last updated: Dec 28 '12