Visual Unit Circle Sine and Cosine Without Math Libraries

By dan • June 1, 2026 • 2 min read

# Visual Unit Circle Sine and Cosine Without Math Libraries

![Trig from the unit circle — sine as y-coordinate, cosine as x-coordinate](https://askrobots.com/files/public/e24224dd-2ddd-41c1-9dc2-13f71b776a4b/)

## One picture
Put a point on a circle of radius `1`. Rotate it by angle `θ`.

- `cos(θ)` is the point's **x-coordinate** (horizontal distance from center)
- `sin(θ)` is the point's **y-coordinate** (vertical distance from center)

```text
point = (cos θ, sin θ)
```

## Simple idea
Cosine is sideways position. Sine is vertical position. That's the whole thing.

## Key angles
| Angle | cos | sin |
|-------|----------|----------|
| 0° | 1 | 0 |
| 30° | √3/2 ≈ 0.866 | 0.5 |
| 45° | √2/2 ≈ 0.707 | √2/2 ≈ 0.707 |
| 60° | 0.5 | √3/2 ≈ 0.866 |
| 90° | 0 | 1 |
| 180° | -1 | 0 |
| 270° | 0 | -1 |
| 360° | 1 | 0 |

## Quadrant signs
| Quadrant | x (cos) | y (sin) |
|----------|---------|---------|
| I (0–90°) | + | + |
| II (90–180°) | – | + |
| III (180–270°)| – | – |
| IV (270–360°)| + | – |

Memory: "All Students Take Calculus" — All / Sin / Tan / Cos are positive in quadrants I/II/III/IV respectively.

## Lookup table implementation
```python
import math # only for building the table — remove for production

# Build a table at startup for 0–360 degrees
SIN_TABLE = [math.sin(math.radians(d)) for d in range(361)]
COS_TABLE = [math.cos(math.radians(d)) for d in range(361)]

def sin_lookup(degrees):
d = int(degrees) % 360
return SIN_TABLE[d]

def cos_lookup(degrees):
d = int(degrees) % 360
return COS_TABLE[d]
```

For truly no-library sine, use the Taylor series approximation:

```python
PI = 3.141592653589793

def sin_approx(x):
"""Taylor series for sin(x), x in radians. Works well for small x."""
x = x % (2 * PI) # wrap to [0, 2π]
return x - x**3/6 + x**5/120 - x**7/5040

def cos_approx(x):
"""Taylor series for cos(x), x in radians."""
x = x % (2 * PI)
return 1 - x**2/2 + x**4/24 - x**6/720
```

## Using sine and cosine for rotation
To move a point in a circle (e.g., orbiting, rotating a sprite):

```python
def point_on_circle(cx, cy, radius, angle_degrees):
PI = 3.141592653589793
theta = angle_degrees * PI / 180
x = cx + radius * cos_approx(theta)
y = cy + radius * sin_approx(theta)
return x, y
```

## Common mistakes
- Confusing which is x and which is y. **Cosine = x (horizontal), Sine = y (vertical)**.
- Passing degrees to functions that expect radians (Python's `math.sin` expects radians).
- Forgetting that both repeat with period 360° (or 2π radians) — values outside this range wrap around.

## See also
- [Visual Tangent Without Math Libraries](/articles/79e757c8-e0c8-44b1-b6ad-07587c459af5)
- [Visual Radians Without Math Libraries](/articles/7090a8d6-5f02-456e-82ec-31741bd1fe38)
- [Visual Inverse Trig and atan2 Without Math Libraries](/articles/85a06148-c2a9-429d-93e4-3b8ffcb93089)
- [Visual Geometry and Trigonometry — Table of Contents](/articles/6e6fe0ba-ee87-48bd-9734-6fc7196323ac)