Sorry, this content is no longer available

Ask Your Question
1

Multiply a vector<Point2f>

asked Dec 27 '12

gary gravatar image

updated Dec 27 '12

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!

Preview: (hide)

1 answer

Sort by » oldest newest most voted
2

answered Dec 28 '12

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.

Preview: (hide)

Comments

thank you!

gary gravatar imagegary (Dec 28 '12)edit

Question Tools

Stats

Asked: Dec 27 '12

Seen: 2,273 times

Last updated: Dec 28 '12