I wrote a test program (attached), and it doesn't work when the start point isn't 0,0.
- if (line->startpoint.X == line->endpoint.X)
t = line->startpoint.Y > line->endpoint.Y ? 3.f * M_PI / 2.f : M_PI / 2.f;
- else
t = atanf((line->endpoint.Y - line->startpoint.Y) / (line->endpoint.X - line->startpoint.X));
- t_cos = cosf(t);
- t_sin = sinf(t);
This seems like an oddly complicated and fragile way to normalize a vector.