- class Polar
- {
- float deg;
- float radius;
- }
- class Cartesian
- {
- float x;
- float y;
- }
- Cartesian polarToCartesian(float deg,float pradius)
- {
- Cartesian cartesianval=new Cartesian();
- deg=deg-90;
- cartesianval.x = cos(radians(deg))*pradius;
- cartesianval.y = sin(radians(deg))*pradius;
- return cartesianval;
- }
- Polar cartesianToPolar(float x, float y)
- {
- Polar polarVal=new Polar();
- polarVal.deg=degrees(atan2(x,y));
- if (polarVal.deg<0) { polarVal.deg=360+polarVal.deg; }
- polarVal.radius=sqrt( (x*x)+(y*y));
- return polarVal;
- }

Cartesian to Polar Processing.org

Posted by Anonymous on Sat 14th Jan 2012 15:24

raw | new post

**Submit a correction or amendment below (click here to make a fresh posting)**

After submitting an amendment, you'll be able to view the differences between the old and new posts easily.