# Dot Product for Facing and Projection

Use dot product to answer practical questions: is one thing facing another, how much motion points forward, or how much light hits a surface.

## Outcome
Use dot product as a yes/no or how-much signal for facing, projection, lighting, and control problems.

## Safe first step
Normalize direction vectors first when you want an angle-like comparison instead of a size-weighted number.

## Ladder steps
### 1. Start with two arrows
Dot product compares two directions or one direction against a surface normal.

Check: You can name both vectors and what each represents.

### 2. Normalize for direction checks
If length should not matter, use unit vectors before comparing.

Check: The result sits in a predictable range from -1 to 1.

### 3. Read the sign
Positive means broadly same direction, zero means sideways, negative means opposite.

Check: You can explain what a positive, zero, or negative result means for the build.

### 4. Use thresholds deliberately
Projects often need a cutoff, not exact equality.

Check: Your note explains why the chosen threshold fits the behavior.

## Examples
### Check if an object broadly faces a target
```sh
facing = forward.normalized().dot(to_target.normalized())
```
Expected signal: Near 1 means aligned, near 0 means sideways, below 0 means behind

### Measure how much velocity points forward
```sh
forward_speed = velocity.dot(forward.normalized())
```
Expected signal: Positive forward component, negative backward component

### Estimate simple surface lighting
```sh
brightness = max(0, normal.dot(light_direction))
```
Expected signal: A value closer to 1 means stronger alignment with light

## Common traps
- Forgetting to normalize when length should not affect the answer.
- Comparing floating-point values to exactly zero.
- Using dot product before naming what each arrow means.

## Practice task
Draw a player forward arrow and a target direction arrow. Predict whether the dot product should be positive, near zero, or negative before calculating it.

## Next steps
- Use vectors for maker projects first if the arrows are unclear.
- Use cross product when left/right or surface normal matters.
- Use trig when the project starts from degrees or radians.

## Related
- [Vectors for maker projects](/learn/vectors-for-maker-projects/)
- [First playable game loop](/learn/godot-first-playable-loop/)
- [Maker Math](/topics/math/)
- [Games and interactive tools](/topics/games/)

## Obsidian backlinks

Use these wiki links to connect this note inside a local maker vault:

- [[TopicLadder]]
- [[Maker Learning]]
- [[Dot Product for Facing and Projection]]
- [[Maker Math]]
- [[math]]
- [[applied-foundation]]
- [[Start with two arrows]]
- [[Normalize for direction checks]]
- [[Read the sign]]
- [[Use thresholds deliberately]]
- [[Vectors for maker projects]]
- [[First playable game loop]]

## Source and next routes

Source: https://topicladder.com/learn/dot-product-for-facing-and-projection/

- [Vectors for maker projects](/learn/vectors-for-maker-projects/)
- [First playable game loop](/learn/godot-first-playable-loop/)
- [Maker Math](/topics/math/)
- [Games and interactive tools](/topics/games/)
