# Cartesian to polar CSV converter

Convert a whole CSV of (x, y) points to polar (r, θ) coordinates in your browser, in degrees or radians, keeping your other columns intact.

## Run it

- **CLI:** `gizza tool cartesian-to-polar-csv "x,y
3,4
-1,1
0,-2.5"`
- **Web:** https://gizza.ai/tools/cartesian-to-polar-csv/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/cartesian-to-polar-csv/tool.json

## Inputs

- `csv` — CSV of points _(field)_
- `direction` — Direction _(field)_
- `x_column` — X / R column _(field)_
- `y_column` — Y / θ column _(field)_
- `angle_unit` — Angle unit _(field)_
- `angle_range` — Angle range _(field)_
- `decimals` — Decimal places _(field)_
- `delimiter` — Delimiter _(field)_
- `has_header` — First row is a header _(field)_
- `keep_columns` — Keep other columns _(field)_
- `output` — Output format _(field)_

## Output

- Converted coordinates (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `csv` — CSV of points
- `direction` — Direction
- `x_column` — X / R column
- `y_column` — Y / θ column
- `angle_unit` — Angle unit
- `angle_range` — Angle range
- `decimals` — Decimal places
- `delimiter` — Delimiter
- `has_header` — First row is a header
- `keep_columns` — Keep other columns
- `output` — Output format

Example: `https://gizza.ai/tools/cartesian-to-polar-csv/?csv=x%2Cy%0A3%2C4%0A-1%2C1%0A0%2C-2.5&direction=cartesian_to_polar&x_column=auto%20%E2%80%94%20e.g.%20x%2C%20easting%20or%202&y_column=auto%20%E2%80%94%20e.g.%20y%2C%20northing%20or%203&angle_unit=degrees&angle_range=signed&decimals=6&delimiter=auto&has_header=true&keep_columns=true&output=csv`

---

## About this tool

Polar coordinates describe a point by how far it is from the origin (`r`) and which way it lies (`θ`), instead of by how far along each axis it sits. The conversion itself is two lines of maths — `r = √(x² + y²)` and `θ = atan2(y, x)` — but doing it by hand for a few hundred survey points, antenna bearings, or scatter-plot samples is tedious and easy to get wrong in the second and third quadrants.

This converter runs the maths over a whole CSV at once, locally in your browser. It reads your header row, finds the coordinate columns (by name, by 1-based number, or by auto-detecting the usual spellings such as `x`/`y`, `easting`/`northing`, `r`/`rho`, `theta`/`phi`), converts every data row, and carries the columns it did not touch straight through to the output. Set the direction to **Polar → Cartesian** to go back the other way with `x = r·cos θ` and `y = r·sin θ`.

**Worked example.** Paste this:

```
id,x,y
p1,3,4
p2,-3,-4
p3,-1,0
```

with the angle unit set to degrees, the range set to signed, and 2 decimal places. The result is:

```
id,r,theta
p1,5.00,53.13
p2,5.00,-126.87
p3,1.00,180.00
```

`p1` and `p2` are the same distance from the origin but sit in opposite quadrants, and the angles differ by 180° — that is `atan2` doing its job. Switch the range to *positive* and `p2`'s angle becomes `233.13` instead.

**Angle units and ranges.** Degrees (a full turn is 360), radians (2π), gradians (400) and turns (1) are all available, and the same setting is used to *read* the angle when you convert polar → Cartesian. The signed range is `atan2`'s natural `(−180°, 180°]`; the positive range wraps negative angles up into `[0°, 360°)`. Both scale with whichever unit you pick.

**Limits and edge cases.** Input is capped at 5 MB and 200,000 data rows. Numbers are 64-bit floats, so about 15–17 significant digits are meaningful and the decimal-places control tops out at 15. The origin `(0, 0)` returns `r = 0` and `θ = 0`, since no direction is defined there. A cell that is empty or is not a number stops the run and names the offending row and column rather than quietly emitting a blank. Delimiters are sniffed from the first non-empty line (comma, semicolon, tab or pipe) and CSV output is written back with the same one. This tool is planar only — it does not do 3D, cylindrical, spherical, or geodetic (lat/lon) coordinate systems, and it does not draw plots.

## FAQ

<details>
<summary>Why is my angle negative?</summary>

The default range is the signed one, `(−180°, 180°]`, which is what `atan2` returns and what most maths libraries use. Points below the x-axis therefore get a negative angle: `(3, −4)` is `−53.13°`. If you would rather see compass-style values from 0 up to a full turn, set the angle range to *positive* and that same point becomes `306.87°`.

</details>

<details>
<summary>Does it handle all four quadrants correctly?</summary>

Yes. The conversion uses `atan2(y, x)`, not `arctan(y / x)`. Plain `arctan` only produces angles between −90° and 90°, so it collapses `(3, 4)` and `(−3, −4)` onto the same answer and blows up when `x` is 0. `atan2` looks at the signs of both coordinates, so `(3, 4)` gives `53.13°`, `(−3, −4)` gives `−126.87°`, and `(0, 5)` gives exactly `90°`.

</details>

<details>
<summary>My CSV has id and label columns — will they survive?</summary>

Yes, as long as *Keep other columns* stays on. Every column that is not one of the two coordinate columns is copied through in its original order, and the two converted values are appended after them. So `id,x,y` becomes `id,r,theta`. Turn the option off if you want just the converted pair and nothing else.

</details>

<details>
<summary>How do I tell it which columns to use?</summary>

Leave both column fields empty and it auto-detects common header names — `x`, `y`, `easting`, `northing` for Cartesian input, and `r`, `rho`, `radius`, `theta`, `phi`, `angle` for polar input. If your headers are unusual, type the exact header name (matching is case-insensitive) or a 1-based column number, such as `2` and `3`. With *First row is a header* turned off, the columns are named `column1`, `column2`, … and the first two are used by default.

</details>

<details>
<summary>Can it convert polar coordinates back to x and y?</summary>

Yes — set the direction to **Polar (r, θ) → Cartesian (x, y)**. It reads the radius and angle columns, interprets the angle in whichever unit you selected, and emits `x = r·cos θ` and `y = r·sin θ`. Round-tripping `(3, 4)` through polar and back returns `3` and `4` again, subject to the decimal places you asked for.

</details>

<details>
<summary>Is my data uploaded anywhere?</summary>

No. The conversion is a small WebAssembly module that runs entirely in your browser tab. The CSV you paste is never sent to a server, and the same code is what the command-line version runs locally.

</details>

## Related tools

- [ARFF Converter](https://gizza.ai/tools/arff-converter/): Convert Weka ARFF datasets to CSV and CSV tables back to ARFF locally — nominal attributes, numeric types, dates, sparse rows, missing values, and type rows.
- [Beancount to CSV Converter](https://gizza.ai/tools/beancount-to-csv/): Flatten Beancount or Ledger journal postings into spreadsheet-ready CSV, then rebuild a simple journal from that flat CSV schema.
- [CSV Cell Diff](https://gizza.ai/tools/csv-cell-diff/): Compare two CSVs column-by-column and highlight every individual cell that changed, plus added and removed rows and columns.
- [CSV timeline viewer](https://gizza.ai/tools/csv-timeline-viewer/): Paste a CSV, TSV or JSON Lines event log and filter it by time range, search every column, sort, pick columns and page through the matches locally.
- [Identify a data sample's format, delimiter and columns](https://gizza.ai/tools/data-format-sniffer/): Paste a data sample and find out what it is: CSV, TSV, JSON, JSON Lines, XML, HTML, fixed-width or binary, plus delimiter, quote char, encoding and column types.
