+static inline void calc_unit_vector(FT_Vector *vec) +{
- FT_Fixed len;
- len = pFT_Vector_Length(vec);
- vec->x = (vec->x << 6) / len;
- vec->y = (vec->y << 6) / len;
+}
For what it's worth, that's usually called normalisation. Given how this is used, there's probably something to be said for not modifying the input vector and just having an output variable instead.
On 5 Nov 2015, at 14:23, Henri Verbeet wrote:
+static inline void calc_unit_vector(FT_Vector *vec) +{
- FT_Fixed len;
- len = pFT_Vector_Length(vec);
- vec->x = (vec->x << 6) / len;
- vec->y = (vec->y << 6) / len;
+}
For what it's worth, that's usually called normalisation.
Right, but the result is also called a unit vector, so I'm happy with either.
Given how this is used, there's probably something to be said for not modifying the input vector and just having an output variable instead.
Yes, good point.
Huw.