Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can someone pls advice me how can i map a semi-circle into a rectangle. In other words i want to a part of a 360 degree image (half of it) and convert the points to rectangle image.

really appreciate any help or suggestions on this. is there any algortigm, sample codes or even math formula?

thank you
Posted

what about
{x,y}->{sqrt(x*x+y*y), atan2(y,x)}

?
:)
 
Share this answer
 
The max possible up-half of the circle
placed on the bottom of the bounding rectangle :) :
void GetCenterAndRadius(const CRect& cRect, // in-parameter
                        CPoint& cpCenter,   // out-parameter
                        int& iRadius)       // out-parameter
{
  cRect.NormalizeRect();
  iRadius = min(cRect.Width() / 2, cRect.Height());
  cpCenter.y = cRect.bottom;
  cpCenter.x = (cRect.right - cRect.left) / 2;
}
 
Share this answer
 

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