Studio Matrx Monthly · Volume 1 · Issue 3 · August 2026
Amogh N P
 In loving memory of Amogh N P — Architect · Designer · Visionary 
Vectors and TransformationsLesson 5.2
PSD for Architecture, Planning & Urban Design/Module 5 · Geometry & Math for Design

Lesson 5.2 · Geometry & Math for Design

Vectors and Transformations

Give geometry a direction and a length, then move, copy and rotate whole shapes with a little arithmetic

13 min Interactive lessonFree · open lessonByAmogh N P· Architect & interior designer
The hook

A point says where something is. A vector says how to get from here to there - and once a move is arithmetic, you can copy, rotate and array anything.

In the last lesson a point was a place. Now we need the other half of geometry: the move. When CAD copies a window ten times along a wall, arrays chairs around a table, or rotates a panel to face the sun, it is doing arithmetic on coordinates - and the idea that organises that arithmetic is the vector.

A vector is not a place; it is a direction with a length - a recipe for getting from one point to another. Add vectors, scale them, and you can translate, array and morph geometry at will. This lesson builds that up gently: vectors as moves, adding and scaling, the dot product for angle, and the three transformations - translate, rotate, scale - that underlie every operation in a modeller.

Translate = add. Scale = multiply. Rotate = sin/cos sandwich. Matrix = all of it, packed.

A vector is a direction and a distance

Two points can look identical on paper yet mean different things: (4, 3) as a place is a spot on the plane, but (4, 3) as a vector is a move - go 4 across and 3 up - that you can apply starting from anywhere. That double life trips up beginners, so hold the distinction firmly: a point answers where, a vector answers which way and how far.

You get a vector by subtracting one point from another. The vector from a to b is (b[0] - a[0], b[1] - a[1]) - exactly the dx, dy you used for distance, now treated as a thing in its own right. Its magnitude (length) is that same math.hypot, and its direction is the way it points.

python
import math

def vector(a, b):
    return (b[0] - a[0], b[1] - a[1])   # the move from a to b

def magnitude(v):
    return math.hypot(v[0], v[1])

v = vector((2, 1), (6, 4))
print(v)              # (4, 3)
print(magnitude(v))   # 5.0

The payoff of thinking in moves is reuse: the vector from a door to its handle is the same move whether the door is here or across the building, so you compute it once and apply it wherever the door lands. That is the seed of copying and arraying geometry, which the rest of the lesson grows.

Two more ideas make vectors easier to reason about. A vector has a direction independent of its length: divide a vector by its magnitude and you get a unit vector, a pure direction of length one, useful whenever you care about which way something points but not how far. And because a vector is just its components, it works the same in 3D - (dx, dy, dz) - so everything here carries straight into three dimensions with one extra number, exactly as points did in the last lesson.

python
def unit(v):
    m = magnitude(v)
    return (v[0] / m, v[1] / m)   # same direction, length 1

print(unit((3, 4)))   # (0.6, 0.8)

Think of a unit vector as an arrow that only tells you a heading. Multiply it by any length and you get a move of exactly that distance in that direction - which is precisely how you step along a wall, offset a line, or march a fixed distance toward a target.

A VECTOR = DIRECTION + LENGTHstartdx = 8dy = 3length = hypot(dx, dy)A vector is not a place, it is a move: go dx across and dy up. Same move works from anywhere.
Zoom
A vector is a move, not a place: an arrow with a horizontal part (dx) and a vertical part (dy). Its length is math.hypot(dx, dy) and its direction is where it points. The same move can be applied starting from anywhere, which is what makes copying and arraying geometry possible.

Point = where. Vector = which way + how far. Subtract points to get the move.

Adding and scaling vectors

Two operations make vectors useful, and both are just componentwise arithmetic. Adding two vectors means doing one move then the other: add the x parts and add the y parts. Scaling a vector by a number stretches or shrinks the move while keeping its direction: multiply both parts by the number.

python
def add(u, v):
    return (u[0] + v[0], u[1] + v[1])

def scale(v, k):
    return (v[0] * k, v[1] * k)

step = (5, 0)                 # move 5 to the right
print(add((1, 1), step))      # (6, 1): start at (1,1), apply the move
print(scale(step, 3))         # (15, 0): the same move, three times as far

These two little functions already do real work. To translate (slide) a point, add a vector to it. To place a row of copies along a wall, scale a step vector by 0, 1, 2, 3 and add each to a start point - which is exactly an array command written as arithmetic.

python
start = (0, 0)
step = (2.5, 0)
row = [add(start, scale(step, i)) for i in range(5)]
print(row)   # [(0.0, 0.0), (2.5, 0.0), (5.0, 0.0), (7.5, 0.0), (10.0, 0.0)]

Change step to (0, 3) and the row becomes a column; change it to (2, 2) and it marches diagonally. The array logic never changes - only the vector does. This is the first taste of how much geometry collapses into add and scale.

Subtracting vectors is just as useful as adding them, and it is where the point-versus-vector distinction pays off. Subtracting one point from another gives the move between them (which is how vector above works); subtracting two vectors gives the difference in their moves. A neat consequence: the midpoint of two points is their average, which you can read as start, then go half the way there.

python
def midpoint(a, b):
    return ((a[0] + b[0]) / 2, (a[1] + b[1]) / 2)

print(midpoint((0, 0), (4, 6)))   # (2.0, 3.0)

Generalise that halfway idea and you can find any point along a line between two others - a quarter of the way, three-fifths of the way - by scaling the move and adding it to the start. This single pattern, called linear interpolation, is how you distribute points evenly along an edge, place balusters on a stair, or blend between two values, and it is nothing more than the add-and-scale you just met.

THREE MOVES ON GEOMETRYTRANSLATEslide by (dx, dy)ROTATEturn about a pivotSCALEgrow or shrink by kEvery move a mouse makes in CAD is one of these, expressed as arithmetic on coordinates.
Zoom
The three transformations behind every modelling operation. Translate slides a shape by a vector, rotate turns it about a pivot, and scale grows or shrinks it by a factor. Translation is addition, scaling is multiplication, and only rotation needs the sine and cosine of the angle.

The dot product — reading the angle between moves

Sometimes you do not want to move geometry but to ask about it: are these two walls parallel, is this panel facing the sun, what is the angle between two directions? The tool for that is the dot product - one number computed from two vectors that quietly encodes the angle between them. You multiply matching components and add: u[0]*v[0] + u[1]*v[1].

The useful facts are simple. If the dot product is zero, the vectors are perpendicular. If it is positive, they point broadly the same way; if negative, broadly opposite. And divided by the two magnitudes it gives the cosine of the angle, so math.acos recovers the angle itself.

python
import math

def dot(u, v):
    return u[0] * v[0] + u[1] * v[1]

def angle_between(u, v):
    cos_t = dot(u, v) / (math.hypot(*u) * math.hypot(*v))
    return math.degrees(math.acos(cos_t))

print(dot((1, 0), (0, 1)))        # 0  -> perpendicular
print(round(angle_between((1, 0), (1, 1)), 1))   # 45.0

This is the one place a little trigonometry earns its keep, and you rarely compute the sines and cosines yourself - math does. With angle_between you can check whether elements are square to each other, sort directions, or find how far a surface normal is off from due south. It is a small function that answers a surprising number of spatial questions.

The dot product has a second, quieter use: projection - how much of one vector points along another. That is exactly what you need to find how far a point lies along a wall, or the shadow one direction casts on another, and it too is built from the same multiply-and-add. You will not need the projection formula today, but it is worth knowing that this one small operation - a couple of multiplications and an addition - is doing the heavy lifting behind angles, perpendicularity checks and projections alike.

dot = 0 -> perpendicular. dot > 0 same-ish way, dot < 0 opposite. Angle from acos.

Translate, rotate, scale — the three moves

Almost every operation in a modeller is one of three transformations: translate (slide), rotate (turn), and scale (resize). You have already met translate - it is just adding a vector. Scale multiplies coordinates by a factor, usually about a chosen centre. Rotate is the one that needs trigonometry: to turn a point by an angle you combine its coordinates with the sine and cosine of that angle.

python
import math

def translate(p, dx, dy):
    return (p[0] + dx, p[1] + dy)

def scale(p, k, about=(0, 0)):
    return (about[0] + (p[0] - about[0]) * k,
            about[1] + (p[1] - about[1]) * k)

def rotate(p, degrees, about=(0, 0)):
    a = math.radians(degrees)
    x, y = p[0] - about[0], p[1] - about[1]
    rx = x * math.cos(a) - y * math.sin(a)
    ry = x * math.sin(a) + y * math.cos(a)
    return (rx + about[0], ry + about[1])

print(rotate((1, 0), 90))   # (~0.0, 1.0): a quarter turn

Notice the shared pattern in scale and rotate: shift so the centre is at the origin, do the maths, shift back. That move-to-origin, act, move-back sandwich is how every transformation about an arbitrary point works, and it explains a common source of confusion - rotate or scale without choosing a centre and everything happens about the origin (0, 0), which can fling your geometry far across the drawing. Deciding the pivot deliberately is half of getting transformations right.

Order matters, too, and this trips up beginners constantly. Rotating then translating is not the same as translating then rotating - the second turns the shape about a different effective point. Whenever a transformed result lands somewhere surprising, the cause is almost always the order of operations or the choice of centre, not the arithmetic. Apply a transform to every point of a shape and the whole shape moves together.

python
room = [(0, 0), (4, 0), (4, 3), (0, 3)]
turned = [rotate(p, 30) for p in room]
copies = [[translate(p, i * 5, 0) for p in room] for i in range(4)]
print(len(copies))   # 4 copies of the room, 5 units apart
THREE MOVES ON GEOMETRYTRANSLATEslide by (dx, dy)ROTATEturn about a pivotSCALEgrow or shrink by kEvery move a mouse makes in CAD is one of these, expressed as arithmetic on coordinates.
Zoom
The three transformations behind every modelling operation. Translate slides a shape by a vector, rotate turns it about a pivot, and scale grows or shrinks it by a factor. Translation is addition, scaling is multiplication, and only rotation needs the sine and cosine of the angle.

Why matrices — a glimpse ahead

If translate, rotate and scale are each a bit of arithmetic, why does every graphics textbook and every CAD API talk about matrices? Because a matrix is a way to pack a whole transformation into one tidy object, and - crucially - to combine several into one. Rotate then move then scale becomes a single matrix you build once and apply to thousands of points, which is both faster and cleaner than juggling three separate steps.

You do not need to hand-multiply matrices to be productive; NumPy and every geometry library do it for you, and Rhino, Grasshopper and Revit hand you ready-made transformation objects. But it helps to know the shape of the idea: a transformation matrix is the professional packaging of exactly the translate-rotate-scale arithmetic you just wrote by hand. Libraries also fold translation in using a small trick (an extra coordinate, called homogeneous coordinates) so that even sliding fits the same matrix machinery.

The honest takeaway is this: for a lot of design scripting, the plain functions above are enough, and they keep the logic visible. When you start transforming large amounts of geometry, or chaining many moves, reach for NumPy or your CAD tool's transform objects - they are the same maths, industrialised. What matters is that you now understand what those objects do, so they stop being magic and become a convenience you can reason about.

Tools & terms you'll meet in this lesson

vector

A direction and a length - the move from one point to another

Got by subtracting points; applied by adding it to a point. The idea that turns copying and arraying into arithmetic.

dot product

One number from two vectors that encodes the angle between them

Zero means perpendicular. Divided by the magnitudes and passed to math.acos it gives the actual angle.

math.sin / math.cos

Trigonometric functions used to rotate a point

Work in radians, so convert with math.radians. You copy the rotation formula rather than deriving it.

transformation matrix

One object packing a whole translate/rotate/scale, ready to combine

The professional packaging of this lesson's arithmetic. NumPy and every CAD API give them to you; you rarely multiply them by hand.

Hands-on workshop

Workshop — array and rotate a room outline

Turn a rectangle of points into copies and rotations using only vector arithmetic. You will feel translate, rotate and scale as the plain functions they are before any library hides them.

Python 3 and the `math` module. No CAD required. Optional: matplotlib to plot the before and after outlines and see the transforms.

Given & goal
Goal: transform a shape with translate, rotate and scale
Inputs: a room outline as a list of points
Time: ~35 minutes
  1. 1Define room = [(0, 0), (4, 0), (4, 3), (0, 3)] and write translate, scale and rotate functions as shown in the lesson.
  2. 2Make a row of four copies of the room, each 5 units to the right of the last, using a list comprehension and translate.
  3. 3Rotate the whole room by 45 degrees about its first corner and print the transformed points; sanity-check that the shape looks turned but the same size.
  4. 4Scale the room by 1.5 about its centre (2, 1.5) and confirm the outline grew but stayed put around the centre.
  5. 5Write angle_between(u, v) with the dot product and use it to confirm two adjacent edges of the original room are 90 degrees apart. Stretch: array the room in a circle by rotating one copy through 0, 45, 90 ... degrees about a shared centre.

You’ll walk away with
A script that translates a room into a row of copies, rotates and scales it about chosen centres, and uses the dot product to verify a right angle - all with hand-written vector functions.

The worked example

Three altitudes on the same idea

Read the band that fits you — or all three.

For the architectAutomate busywork & build custom tools

Arrays, mirrors and rotations are the daily grammar of a set of drawings, and they are all vector arithmetic. Repeating a bay along a grid, arraying louvres across a façade, rotating a wing about a courtyard, mirroring a plan - each is translate, rotate or scale applied to a list of points. Understanding the maths means that when a Grasshopper array or a Revit transform behaves oddly, you can reason about why instead of nudging sliders.

For the interior designerScripts for data, schedules & layouts

Every repeated element - a run of pendants, a grid of tiles, chairs arrayed around a table, a mirrored joinery unit - is a start point plus a repeated move. Scale a step vector and add it, and you have spacing; rotate about a centre and you have a circular arrangement. Even for schedules and layouts that never leave 2D, thinking in vectors turns fiddly manual placement into a couple of lines you can re-run when the spacing changes.

For the studentA hireable computational skill

Vectors and transformations are the bedrock of parametric and generative design. Grasshopper, Dynamo and every creative-coding framework assume you know that a move is a vector and that translate/rotate/scale are the core operations. Write these functions by hand once, watch a rotated room come out correct, and the matrix-heavy material in later modules and in the Computational Design course will read as familiar packaging rather than new mathematics.

Misconception check

You must be fluent in trigonometry and matrix algebra before you can transform geometry in code.

You need far less than the fear suggests. Translation is pure addition; scaling is multiplication; only rotation touches trigonometry, and even there you never compute a sine or cosine by hand - math.cos and math.sin do it, and you copy a five-line formula. Matrices are a convenience for packing and combining transformations, not a prerequisite: NumPy and every CAD API supply them ready-made. You can write correct, useful translate, rotate and scale functions today with nothing more than the arithmetic in this lesson. Understanding the little formulas first is exactly what makes the matrix-based tools later feel like sensible shortcuts rather than intimidating magic.
Try it

Do it yourself

Work these out, then verify with a print.

  1. 1In one sentence, how does a vector differ from a point?
  2. 2How do you get the vector that moves from point a to point b?
  3. 3What does a dot product of zero tell you about two vectors?
  4. 4Which of translate, rotate and scale needs trigonometry, and why?
  5. 5Why do scale and rotate shift to the origin, act, then shift back?
Take this with you

The one line to carry out

A vector is a move - a direction and a length - and translate, rotate and scale are just arithmetic on coordinates; matrices are the tidy packaging of that same maths. Learn the moves by hand and every array, mirror and rotation in CAD becomes something you understand.
Take it further
References & further reading

Peer-reviewed journals & authoritative standards

  1. 01Euclidean vectorWikipedia, 2026.
  2. 02Transformation matrixWikipedia, 2026.
  3. 03TrigonometryWikipedia, 2026.
  4. 04NumPyNumPy developers, 2026.
Related lessons
Recap
A vector is a direction and a distance, found by subtracting points and applied by adding. Add and scale vectors to array geometry; the dot product reads the angle between them, and is zero for perpendicular. The three transformations - translate, rotate, scale - are the arithmetic behind every CAD move, with only rotation needing trigonometry. Matrices simply pack and combine these, and libraries supply them ready-made.
Carry forward →

We can now place and move points and shapes. Next we step up to the geometry designers actually model with - polylines and NURBS curves, surfaces, and meshes of vertices and faces - and see the data structures behind a model.

A

The author

Amogh N P

Architect, interior designer, and creative polymath. Studio Matrx began in his notebooks — his vision of design made honest, useful, and open to everyone. Its Academy is written and taught in his memory, and free, forever.

More about Amogh →