# class ROOT::Math::Polar2D<double>

```
Class describing a polar 2D coordinate system based on r and phi
Phi is restricted to be in the range [-PI,PI)

@ingroup GenVector

```

#### This class is also known as (typedefs to this class)

ROOT::Math::DisplacementVector2D<ROOT::Math::Polar2D<double>,ROOT::Math::DefaultCoordinateSystemTag>::CoordinateType, ROOT::Math::PositionVector2D<ROOT::Math::Polar2D<double>,ROOT::Math::DefaultCoordinateSystemTag>::CoordinateType

## Function Members (Methods)

public:
 ~Polar2D() void GetCoordinates(ROOT::Math::Polar2D::Scalar& r, ROOT::Math::Polar2D::Scalar& phi) const ROOT::Math::Polar2D::Scalar Mag2() const void Negate() bool operator!=(const ROOT::Math::Polar2D& rhs) const ROOT::Math::Polar2D& operator=(const ROOT::Math::Polar2D& v) bool operator==(const ROOT::Math::Polar2D& rhs) const ROOT::Math::Polar2D::Scalar Phi() const ROOT::Math::Polar2D Polar2D() ROOT::Math::Polar2D Polar2D(const ROOT::Math::Polar2D& v) ROOT::Math::Polar2D Polar2D(double r, double phi) ROOT::Math::Polar2D::Scalar R() const void Rotate(double angle) void Scale(double a) void SetCoordinates(ROOT::Math::Polar2D::Scalar r, ROOT::Math::Polar2D::Scalar phi) void SetPhi(const double& phi) void SetR(const double& r) void SetX(ROOT::Math::Polar2D::Scalar a) void SetXY(ROOT::Math::Polar2D::Scalar a, ROOT::Math::Polar2D::Scalar b) void SetY(ROOT::Math::Polar2D::Scalar a) ROOT::Math::Polar2D::Scalar X() const double x() const ROOT::Math::Polar2D::Scalar Y() const double y() const
private:
 static double pi() void Restrict()

## Data Members

private:
 double fPhi double fR

## Function documentation

Polar2D & operator=(const ROOT::Math::Polar2D<double>& v)
```      assignment operator

```
void SetCoordinates(ROOT::Math::Polar2D<double>::Scalar r, ROOT::Math::Polar2D<double>::Scalar phi)
```      Set internal data based on 2 Scalar numbers

```
`{ fR=r; fPhi=phi; Restrict(); }`
void GetCoordinates(ROOT::Math::Polar2D<double>::Scalar& r, ROOT::Math::Polar2D<double>::Scalar& phi) const
```      get internal data into 2 Scalar numbers

```
`{r=fR; phi=fPhi;}`
Scalar R() const
`{ return fR;}`
Scalar Phi() const
`{ return fPhi; }`
Scalar X() const
`{ return fR*std::cos(fPhi);}`
Scalar Y() const
`{ return fR*std::sin(fPhi);}`
Scalar Mag2() const
`{ return fR*fR;}`
void SetR(const double& r)
``` setters (only for data members)

set the r coordinate value keeping phi constant

```
void SetPhi(const double& phi)
```       set the phi coordinate value keeping r constant

```
Restrict()
void SetXY(ROOT::Math::Polar2D<double>::Scalar a, ROOT::Math::Polar2D<double>::Scalar b)
```       set all values using cartesian coordinates

```
double pi()
`{ return M_PI; }`
void Scale(double a)
```       scale by a scalar quantity - for polar coordinates r changes

```
Negate()
void Rotate(double angle)
```      rotate the vector

```
bool operator==(const ROOT::Math::Polar2D<double>& rhs) const
```      Exact equality

```
bool operator!=(const ROOT::Math::Polar2D<double>& rhs) const
`{return !(operator==(rhs));}`
T x() const
``` ============= Compatibility section ==================
The following make this coordinate system look enough like a CLHEP
vector that an assignment member template can work with either
```
`{ return X();}`
T y() const
`{ return Y();}`
void SetX(ROOT::Math::Polar2D<double>::Scalar a)
``` ============= Specializations for improved speed ==================
(none)
====== Set member functions for coordinates in other systems =======
```
void SetY(ROOT::Math::Polar2D<double>::Scalar a)