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.
On Tue, Aug 15, 2017 at 12:47:48PM -0500, Vincent Povirk wrote:
I wrote a test program (attached), and it doesn't work when the start point isn't 0,0.
Right, I got the sign on the offset in blend_line_gradient backwards. Thanks for the test program.
- 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.
Yeah, I just took that straight from Mono's libgdiplus without understanding it. I'll study it some more and see if I can simplify it.
Andrew