# Vector addition and rotation in asymptote

I am not sure this is the right place to post questions about asymptote, but if not I can delete it later.

Here is the code I am playing with:

``````//sangaku.asy
unitsize(5mm);

pair A=(0,0);
pair B=(3,0);
pair C=(2,1);
pair D, E, F, G, H, I, J, K;

F = rotate(90, A)*C;
G = C + F;
I = rotate(-90, B)*C;
H = (C-B) + I;
J = rotate(90, G)*H;
/*K = (H-G) + (J-G);*/
K = rotate(-90, H) * G;
D = rotate(-90, A) * B;
E = D + B;

picture sangaku;
path vierkantac=A--C--G--F--cycle;;
path vierkantbc=C--B--I--H--cycle;;
path vierkantgh=G--H--K--J--cycle;
path vierkantab=B--A--D--E--cycle;

path driehoekae=A--B--E--cycle;
path driehoekgh=G--H--K--cycle;

pen p1=orange;
pen p2=cyan;

filldraw (sangaku, vierkantac, p1);
filldraw (sangaku, vierkantbc, p1);
draw (sangaku, vierkantgh);
draw (sangaku, vierkantab);

pair positie=(2, 12);
``````

The line `K = (H-G) + (J-G);`, which I have commented out, is giving me trouble:

With the rotate function I get the right result:

But why should they not be equivalent?

In this case a correct would be `K = G+(H-G) + (J-G);`. The error comes from common misconception that points an vectors are the same, while in fact they are not. It is easy to grasp the difference, with one more coordinate added to mark it: it is `0` for vectors, and `1` for a valid point. Then it is clear, that any sum (+/-) of vectors will result in a valid vector, the difference of two points is a vector, and to get a valid point, the vector has to be added to another point. (Sum of the points are only valid, if the mentioned extra coordinate of the result is also `1`). In particular, in the commented line `K` clearly is a sum of two vectors `(H-G)` and `(J-G)`, to make it a point, another proper point has to be added, in this case it is `G`.