class library: Volume - remove debug message
[supercollider.git] / SCClassLibrary / Common / Math / Polar.sc
blob6ee88f47b399e1a655b628ac15c60c72c083da01
1 Polar : Number {
2         var <>rho, <>theta;
4         *new { arg rho, theta;
5                 ^super.newCopyArgs(rho, theta)
6         }
8         magnitude { ^rho }
10         angle { ^theta }
11         phase { ^theta }
13         real { ^rho * cos(theta) }
14         imag { ^rho * sin(theta) }
16         asPolar { ^this }
17         asComplex { ^Complex.new(this.real, this.imag) }
18         asPoint { ^Point.new(this.real, this.imag) }
20         scale { arg scale;
21                 ^Polar.new(rho * scale, theta)
22         }
23         rotate { arg angle; // in radians
24                 ^Polar.new(rho, theta + angle)
25         }
27         // do math as Complex
28         + { arg aNumber;  ^this.asComplex + aNumber  }
29         - { arg aNumber;  ^this.asComplex - aNumber  }
30         * { arg aNumber;  ^this.asComplex * aNumber  }
31         / { arg aNumber;  ^this.asComplex / aNumber  }
33         == { arg aPolar;
34                 ^aPolar respondsTo: #[\rho, \theta] and: {
35                         rho == aPolar.rho and: { theta == aPolar.theta }
36                 }
37         }
39         hash {
40                 ^rho.hash bitXor: theta.hash
41         }
43         neg { ^Polar.new(rho, theta + pi) }
45         performBinaryOpOnSomething { |aSelector, thing, adverb|
46                 ^thing.asComplex.perform(aSelector, this, adverb)
47         }
49         performBinaryOpOnUGen { arg aSelector, aUGen;
50                 ^Complex.new(
51                         BinaryOpUGen.new(aSelector, aUGen, this.real),
52                         BinaryOpUGen.new(aSelector, aUGen, this.imag)
53                 );
54         }
56         printOn { arg stream;
57                 stream << "Polar( " << rho << ", " << theta << " )";
58         }
59         storeArgs { ^[rho,theta] }