Drawing My Way Into Vector Mathematics

July, 28

For the past few days, I've been building the mathematics layer of VEngine.

At first, it was just another programming task.

Implement vector addition.

Implement subtraction.

Implement normalization.

Implement length.

Simple enough.

But something kept bothering me.

I didn't really understand why they mattered.

So I decided to stop writing math.

Instead, I started drawing it.


A Vector Is More Than Two Numbers

When most people first learn vectors, they're introduced like this:

v = (3, 2)

Or maybe:

Vector2 v(3, 2);

That's useful.

But it doesn't feel real.

When I started drawing them on a coordinate system, something changed.

          y
          ↑

          │
          │      ● v = (3,2)
          │     ↗
          │    /
          │   /
──────────●────────────────→ x

Now the vector wasn't just numbers.

It became a direction.

A distance.

A movement.


The First Question

One function kept appearing everywhere.

Normalized()

Every graphics library has it.

Every game engine has it.

But I kept asking myself:

Why would I ever want a vector whose length is exactly 1?

Then I built a visualization.


Original vs Normalized

Original

           ↗
         /
       /
     /
   ●

Length = 5
Normalized

      ↗
    /
  ●

Length = 1

✓ Same direction

✗ Different length

The normalized vector always points exactly where the original vector points.

The only thing that disappears is its magnitude.

That was the moment normalization finally made sense.

I wasn't creating a shorter vector.

I was separating direction from distance.


Why Is That Useful?

Imagine two completely different vectors.

Small

      ↗
     /
    ●

Length = 12
Large

                ↗
              /
            /
          /
        ●

Length = 350

After normalization:

      ↗
     /
    ●

Length = 1

Both become exactly the same size.

Now I can choose any length I want.

direction * 10
direction * 50
direction * 200

The direction never changes.

Only the distance changes.


Discovering Perpendicular Vectors

While drawing vectors, I wanted to draw proper arrows instead of simple lines.

That raised another question.

How do you move left if you only know which way is forward?

The answer was a perpendicular vector.

(x, y)

one perpendicular vector is

(-y, x)

Building an Arrow

Drawing an arrow turned out to be a surprisingly fun geometry problem.

"How do I draw an arrow?"

I started asking much smaller questions.


Move backwards from the tip.

start ●──────────────●────────●
                 arrowStart   end

Move left and right.

                 end
                  ●
                 / \
                /   \
               ●     ●

Connect the points.

                  ●
                 / \
                /   \
───────────────●─────

No complicated trigonometry.

Just small pieces of vector mathematics working together.


The Best Part

Eventually, everything came together inside VEngine.

                 ↑ Perpendicular

                 │

        ------→  ●──────────────► 

              (Normalized)      (Original)

The arrowhead is built using the perpendicular vector.

Everything updates in real time as I move the vector around.


What I Learned

Definitions tell you what something is.

Visualization teaches you why it exists.

Those are two very different kinds of understanding.


What's Next?

This is only the beginning.

Next I'll be exploring the dot product.

Not by memorizing

x₁x₂ + y₁y₂

but by building another interactive visualization inside VEngine until the idea becomes intuitive.

Don't just implement mathematics.

Draw it.

Move it.

Experiment with it.

Because once you can see it, it stops feeling abstract.

go back to tech